Ansible 2.19 template change

Hi,
I upgraded to ansible 2.19.0 and start issuing lazy templating error.

Current task

    - name: Setting conf file location
      ansible.builtin.set_fact:
        _autoConfFile: "{{ tmpDir }}/silent_installation_auto.conf"

    - name: Creating the configuration file from template for installation
      ansible.builtin.template:
        src: "silent_installation.conf.in"
        dest: "{{ _autoConfFile }}"
        mode: "u=xrw,g=r,o=r"

where contains of “silent_installation.conf.in” is just key = variable settings

startDaemon="{{ service.enable | ansible.builtin.ternary('1', '0') }}"
daemonUser="{{ service.userName }}"
port="{{ service.port }}"
serviceName="{{ service.name }}"
storageDir="{{ service.storageDir }}"
storageLogDir="{{ servicestorageLogDir }}"

With this setup Im fine on 2.18 ansible but on 2.19 its start failing on lazy template dict

184         - name: Creating the configuration file from template for installation
              ^ column 11

<<< caused by >>>

'ansible._internal._templating._lazy_containers._AnsibleLazyTemplateDict object' has no attribute ''
Origin: /ansible/playbooks/roles/myrole/templates/silent_installation.conf.in

fatal: [instance-01]: FAILED! => {"changed": false, "msg": "Task failed: 'ansible._internal._templating._lazy_containers._AnsibleLazyTemplateDict object' has no attribute ''"}

Right now Im really not sure what to do. Can you give me some hint? Im thinking about trust variables but according to documentation my setup should be ok because all the values are inside vars.yml

Thanks for any advice
Karel
@lazy_containers
@template

Can you provide the full error that you received, instead of cutting off the beginning? It might also be useful to see how service, servicestorageLogDir, and any variables they reference are defined (assuming it’s failing during templating and not during task var finalization.)

Also you might want to try ansible-core 2.19.1rc1, released earlier this week, since it fixes some similar problems.

Hi, Allready done that, same result. I will post the variables and full log soon

Task itself>

If i cutoff something importat sorry about that (but the error is just duplicated)

TASK [myrole: Creating the configuration file from template for installation] ***
[ERROR]: Task failed: 'ansible._internal._templating._lazy_containers._AnsibleLazyTemplateDict object' has no attribute ''

Task failed.
Origin: /ansible/playbooks/roles/myrole/tasks/install.yml:184:11

182               ips: "{{ ips | combine({'runForWeb': runForWeb}, recursive=false) }}"
183
184         - name: Creating the configuration file from template for installation
                  ^ column 11

<<< caused by >>>

'ansible._internal._templating._lazy_containers._AnsibleLazyTemplateDict object' has no attribute ''
Origin: /ansible/playbooks/roles/myrole/templates/silent_installation.conf.in

fatal: [instance-01]: FAILED! => {"changed": false, "msg": "Task failed: 'ansible._internal._templating._lazy_containers._AnsibleLazyTemplateDict object' has no attribute ''"}

vars.yml

service:
  enable: true
  name: "Manager-30353"
  userName: myUser
  port: 30353
  storageDir: /tmp/storage

storageLogDir: "/home/myUser/log/InspireContentManager-30353/"

Path for the template file “silent_installation.conf.in” is correct i double checked it.

To be absolutely honest I dont know how to answer the:
“(assuming it’s failing during templating and not during task var finalization.)” question.

I will run it in the morning with debug -vvvv and post the debug run

I cannot replicate your issue in 2.19.0. If I use the values and template you provided I get the expected 'Task failed: ''servicestorageLogDir'' is undefined' error, if I define the missing variable the template works as expected.

Are you sure you’re looking at the correct location in your code? The context provided by the error does not match the pair of tasks in your initial post.

I’m referring to the actual error, which you cut out of your initial message:

[ERROR]: Task failed: 'ansible._internal._templating._lazy_containers._AnsibleLazyTemplateDict object' has no attribute ''

This tells us when the error occurred (“Task failed”) and what it is. Compare to:

[ERROR]: Task failed: Finalization of task args for 'ansible.builtin.template' failed: Error while resolving value for 'dest': Syntax error in template: No filter named 'nonexistentfilter'.

when the error occurs before the task even runs.

This is why it’s best to provide the full error output. It might contain information that’s useful to the people you’re asking for help.