Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing ansible loop due to v2.11 deprecation

Tags:

I'm running a playbook which defined several packages to install via apt:

    - name: Install utility packages common to all hosts       apt:         name: "{{ item }}"         state: present         autoclean: yes       with_items:         - aptitude         - jq         - curl         - git-core         - at ... 

A recent ansible update on my system now renders this message concerning the playbook above:

[DEPRECATION WARNING]: Invoking "apt" only once while using a loop via squash_actions is deprecated. Instead of  using a loop to supply multiple items and specifying `name: {{ item }}`, please use `name: [u'aptitude',  u'jq', u'curl', u'git-core', u'at', u'heirloom-mailx', u'sudo-ldap', u'sysstat', u'vim', u'at', u'ntp',  u'stunnel', u'sysstat', u'arping', u'net-tools', u'lshw', u'screen', u'tmux', u'lsscsi']` and remove the loop.  

If I'm understanding this correctly, Ansible now wants this list of packages as an array which leaves this:

name: [u'aptitude', u'jq', u'curl', u'git-core', u'at','heirloom-mailx', u'sudo-ldap', u'sysstat', u'vim', u'at', u'ntp',u'stunnel', u'sysstat', u'arping', u'net-tools', u'lshw', u'screen', u'tmux', u'lsscsi'] 

Is there a better way? Just seems like I'll be scrolling right forever in VIM trying to maintain this. Either that, or word wrap it and deal with a word-cloud of packages.

like image 511
Server Fault Avatar asked Oct 10 '18 14:10

Server Fault


1 Answers

You can code the array in YAML style to make it more readable:

- name: Install utility packages common to all hosts   apt:     name:       - aptitude       - jq       - curl       - git-core       - at     state: present     autoclean: yes 
like image 200
Ignacio Millán Avatar answered Sep 28 '22 12:09

Ignacio Millán