Hello Community,
I could really use some help here. First of all, I would like to say, that I am with ansible for couple of days, so sorry in advance
My use case:
I am setting up ssh configuration for all hosts. I want to have default AcceptEnv for CentOS, but I have one hosts group which needs some extra AcceptEnv lines.
I am using sshd role https://galaxy.ansible.com/willshersystems/sshd
What I have:
I have group_vars/all with the following code
sshd:
AcceptEnv:
- LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
- LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
- LC_IDENTIFICATION LC_ALL LANGUAGE
- XMODIFIERS
I also have group_vars/mygroup which needs to add extra line. If I just copy all info from group_vars/all and add my extra lines, it is working.
What I want to achieve in group_vars/mygroup is something like
`
sshd:
AcceptEnv: {{existing AcceptENV} + {{ my_lines or temp_var with lines }}
`
This is not working
temp_var:
AcceptNewEnv:
- EXTRA_ENV_VAR
sshd:
AcceptEnv: “{{ sshd.AcceptEnv }} + {{ temp_var.AcceptNewEnv }}”
I tried bunch of situations, didn’t get this to work. Any suggestions, I am a bit lost here.
Btw an error I get is
Error was a <class 'ansible.errors.AnsibleError'>, original message: An unhandled exception occurred while templating '{u'AcceptEnv': u'{{ sshd.AcceptEnv }} + {{ temp_var.AcceptNewEnv }}'}'
I’ve googled a lot about this error and I get the point, that’s a recursive call, but I do not think of a way to get existing value and add something more…