#ansible (2023-09)

ansible

Discussions related to ansible configuration management

2023-09-05

jonjitsu avatar
jonjitsu

Anyone have any recommendations for roles for java & tomcat?

Hao Wang avatar
Hao Wang
Ansible Galaxy

Jump start your automation project with great content from the Ansible community

jonjitsu avatar
jonjitsu

Thanks, have you used it? I was looking more for opinions based on personal experience.

Hao Wang avatar
Hao Wang

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

ikar avatar

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

ikar avatar

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:

bradym avatar

Yeah, ChatGPT does tend to make stuff up

bradym avatar

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

ikar avatar

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

1
bradym avatar

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

direnv – unclutter your .profile

unclutter your .profile

ikar avatar

perfect! thanks

2023-09-18

2023-09-19

2023-09-20

    keyboard_arrow_up