Simple template/vars file issue

I apologise now for the simplicity of this query… I’ve read a lot of related posts but I am still no closer to understanding the problem.

I have a very simple play.

The specific issue I am stuck on only started on Friday. I must have ‘tweaked’ something and I am darned if I can work out what - this step worked on Thursday after we upgraded to latest version.

Anyway - it’s a template step.

  • name: Templates to appropriate HNAS share
    template: src=$environmentDirectory/templates/$model/Munich.yaml dest=/mnt/brlhnas/workgroup_cfg/$env/$model/Munich.yaml

The calling play references vars here:

vars:
env: UAT
model: GLORIA

vars_files:

  • …/global_vars.yml
  • …/vars/SetupConfigVars_$env_$model.yml

My global_vars file contains this;

environmentDirectory: /home/sysadmin

My file vars/SetupConfigVars_UAT_GLORIA.yml, contains the following;

Can you share the template?

BTW, I should point out you are using old style variables ($foo).

Change $environment to {{ environment }} and this will be more consistent with up to date playbooks.

At some point in the future support for this will be removed so it makes sense to get in the habit now.

Old style variables can also be disabled in ansible.cfg to make this easier.

I would also avoid using 'environment' as it is an ansible reserved keyword.

Thank you both.

I think I misread the jinja document on the variables - {{env}} works nicely!

Fortunately, we’re not too far along in our little demo project here so I can make your recommended changes in no time.

I appreciate the help.