I’m upgrading a few Ansible scripts from 1.8 to 2.0 and I’m not sure how to solve this deprecation issue:
"[DEPRECATION WARNING]: Using variables for task params is unsafe, especially if the variables come from an external source like facts. This feature will be
removed in a future release. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg."
I’ve read the porting guide and a few posts here and on GitHub, but I can’t use “items” in my case.
In my group_vars I define the defaults for the apt task:
apt_defaults:
cache_valid_time: 3600
install_recommends: no
update_cache: yes
In my script I refer to them:
name: Install server and helper packages
apt: pkg={{item}} state=installed
args: “{{apt_defaults}}”
with_items:
Your solution however forces pkg as a separate argument on a new line.
How would I supply install_recommends to that (specific) task? This for example doesn’t work:
…
apt:
<<: *apt_defaults
pkg: “{{item}}”
install_recommends: yes
It would be nice if it was possible to simply set defaults for tasks.
Something like:
defaults:
apt:
cache_valid_time: 3600
And then allowing these defaults to be overridden by the actual task.
Even better if you could specify these defaults in the group_vars.