I've run into a deprecation error related to an undefined variable in a
with_items loop. The task definition is below:

name: template syslog config snippets
template:
  src: "{{ item }}.conf.j2"
  dest: "/etc/rsyslog.d/{{ item }}.conf"
  mode: 0644
with_items: "{{ syslog.snippets|default(1) }}"
when: syslog is defined
notify:
  - restart rsyslog

The "when" clause was originally 'when: syslog is defined and
syslog.snippets is defined', but I was getting the deprecation warning for
both syslog and syslog.snippets and I found various threads which explained
the issue with when clauses and loops, so I adjusted it as suggested.
However, because the list I'm referencing is actually a value of a dict
key, I still need to test that 'syslog' is defined, but I'm still getting
the deprecation warning about 'syslog' not being defined.

[DEPRECATION WARNING]: Skipping task due to undefined Error, in the future
this will be a fatal error.: 'syslog' is undefined.
This
feature will be removed in a future release.

Is there a way to test for this effectively, or is my only option to define
a 'fake' syslog var for servers that don't have it, so that it passes the
test for syslog, but not syslog.snippets?

Thanks,
Guy

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CANNH9mvCU6x1kgZa%2Bt3Zu4ZO%2B6n4%2BoNAd8HM99tbz-D7SWa3kw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to