#ansible (2023-09)
Discussions related to ansible configuration management
2023-09-05
Anyone have any recommendations for roles for java & tomcat?
This looks an active one, https://galaxy.ansible.com/robertdebock/tomcat
Jump start your automation project with great content from the Ansible community
Thanks, have you used it? I was looking more for opinions based on personal experience.
I used one of tomcat playbooks but not sure if this is the one. Ansible is easy to work with, and you can also take a look into their codes
2023-09-06
2023-09-15
Hey all, few weeks ago we decided to use AWS profiles (not to use the default one) but I’m not sure how to set profile (and region) in ansible.
There is no such configuration in ansible.cfg (https://docs.ansible.com/ansible/latest/reference_appendices/config.html). So instead of this:
- debug: var="{{ lookup('amazon.aws.aws_secret', 'redis/access') }}"
we have to do this:
- debug: var="{{ lookup('amazon.aws.aws_secret', 'redis/access', profile='xxx', region='eu-central-1') }}"
which is annoying.
As a workaround we can use environmental variables (AWS_PROFILE
and AWS_REGION
) but setting it globally or prepending to every ansible-playbook call is not ideal.
is there a way ho to set environmental variables in ansible.cfg or ansible in general
Thanks @bradym, not exactly what I was looking for. I’d have to set variables in each playbook. Something like ChatGTP suggests would be great, but it seems it doesn’t work that way:
Yeah, ChatGPT does tend to make stuff up
Another option would be to use group variables that you set in your inventory. https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html#adding-variables-to-inventory
Yeah, thanks, we use that too…
But I actually need to set the env vars for the control machine per infra repository. Basically the ansible.cfg
would be ideal place for that, but there seems to be no support for that
Maybe I’ll just have to source some env.sh file before each playbook run
If they are separate folders/repos you could use https://direnv.net/ to automatically set env vars when switching into the folder. For an automated job you’d just source the .envrc file first
unclutter your .profile
perfect! thanks