Hi!
I have a role that clean my /etc/cron.d , /etc/cron.daily, etc… and installs new crons that I have defined in the role. For this duty I’ve do a simple but powerfull playbook but in version 2.0 instead of skeep a steep, I see a deprecation warning.
Example:
LOOK IF PLACEHOLDER FILE EXISTS AND REGISTER IN A VAR
- stat:
path=/etc/cron.d/placeholder
register: placeholdercrond
tags: [“cron.all”, “cron.d”]
IF NOT EXISTS, LIST ALL FILES AND STORE THEM IN A VAR
- shell: ls -1 /etc/cron.d
register: crond
when: placeholdercrond.stat.exists == False
tags: [“cron.all”, “cron.d”]
DELETE EVERY FILE IF LAST COMMAND WHERE TRUE BECAUSE crond VAR HAS VALUES
-
file:
path=/etc/cron.d/{{ item }}
state=absent
with_items: crond.stdout_lines
when: crond.changed == True
tags: [“cron.all”, “cron.d”] -
WHEN NOT PLACEHOLDER FILE: PLAYBOOK RUN OK
-
WHEN THERE IS A PLACEHOLDER FILE: PLAYBOOK SHOWS A DEPRECATION, FUTURE ERROR IN FILE MODULE
PLAY ***************************************************************************
TASK [setup] *******************************************************************
TASK [cron : stat] *************************************************************
ok: [testserver]
TASK [cron : command] **********************************************************
ok: [testserver]
TASK [cron : file] *************************************************************
[DEPRECATION WARNING]: Skipping task due to undefined attribute, in the future this will be a fatal error… This feature will be removed in a future release. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
This is because {{ item }} is empty, but this steep should be skipped because the when: condition is not meeted.
Any ideas?