ironicbadger / ansible-role-docker-compose-generator Goto Github PK
View Code? Open in Web Editor NEWAn Ansible role which procedurally generates docker-compose.yml files
An Ansible role which procedurally generates docker-compose.yml files
When passing environment vars in the format of:
environment:
TZ: Europe/London
the output in the docker-compose appears as
environment:
- TZ
When passed in the older format of:
environment:
- 'TZ=Europe/London'
The correct vars are created
The initial task to check the destination passes, but I receive the following error when Ansible tries to generate a docker compose file.
TASK [ironicbadger.docker_compose_generator : write docker-compose file] ******************** An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'containers' is undefined. 'containers' is undefined fatal: [192.168.110.10]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'containers' is undefined. 'containers' is undefined"}
I am not sure why Ansible says containers is undefined. I double checked the syntax and indentation, which look okay. I used your example to A/B test and receive the same error.
I can send my playbook yaml and requirements yaml if that will be helpful.
Ansible: 2.14.4
Docker on remote host: 26.0.2
Docker compose on remote host: 2.26.1
I tried to have 2 dashes but it doesn't work, something like:
command: --nocacerts
Good day!
Thank you very much for this role, I have noticed a small problem though.
When I try to specify a logging configuration for a container, it never shows up in the output. Now, this very much could be a problem with my syntax and such, but I see no errors being thrown and everything else gets generated appropriately into the resulting Compose file.
Digging thru the template file, I can see where the loop exists to handle the logging settings, but they never trigger.
Example:
First off, I may not have thanked you yet for this amazing role. I'm using it for almost all my infrastructure. Thank you!
Wanted to open an issue for better visibility.
c5836ad is a breaking change for the command
option. Might it be better to do something along these lines?
{% if container.command is defined %}
{% if container.command is string %}
command: {{ container.command }}
{% else %}
command:
{% for command in container.command %}
- {{ command }}
{% endfor %}
{% endif %}
{% endif %}
I'd still like to see arrays neatly generated in my docker-compose
file, as I use this to pass options to Traefik. Maybe I should be using a separate file rather than my host_vars monolith, but that's a different issue :)
Is there a functional difference in docker-compose that I'm missing? I defer to your expertise. I'd be happy to submit a PR if you're in agreement.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.