Ansible Basic Course: Lab – Ansible Variables and Facts - 8

Error:

Lab – Ansible Variables and Facts - 8

lab-ansible-variables-and-facts

Question: 8

/home/bob/playbooks/app_install.yaml

I got DEPRECATION WARNINGs and CHECK fails.

[bob@student-node playbooks]$ cat app_install.yaml

  • hosts: all
    become: yes
    tasks:
    • name: Install applications
      yum:
      name: “{{ item }}”
      state: present
      with_items:
      • “{{ app_list }}”

[bob@student-node playbooks]$ ansible-playbook -i inventory app_install.yaml

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [localhost]
ok: [node02]
ok: [node01]

TASK [Install applications] ****************************************************
[DEPRECATION WARNING]: Invoking “yum” 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: ['{{ app_list }}'] and
remove the loop. This feature will be removed in version 2.11. Deprecation
warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: Invoking “yum” 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: ['{{ app_list }}'] and
remove the loop. This feature will be removed in version 2.11. Deprecation
warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: Invoking “yum” 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: ['{{ app_list }}'] and
remove the loop. This feature will be removed in version 2.11. Deprecation
warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
changed: [localhost] => (item=[‘vim’, ‘sqlite’, ‘jq’])
changed: [node02] => (item=[‘vim’, ‘sqlite’, ‘jq’])
changed: [node01] => (item=[‘vim’, ‘sqlite’, ‘jq’])

PLAY RECAP *********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
node01 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
node02 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

[bob@student-node playbooks]$

FAILS - Replaced the hardcoded list of packages in “app_install.yaml” playbook to use the values from the “app_list” variable defined in the inventory file?

OK - Run the playbook to make sure it works fine.

Comment:
Is this a good idea in a folder name: :sparkles: : “%e2%9c%a8” ?

It is both deprecated and the lab check fails.
+1

1 Like

First check fails because it looks for the following 2 strings on the same line “with_items” and “{{app_list}}”.
I was able to work around this odd check by using an in-line list
e.g. with_items: [“{{ app_list }}”]
I still got the depreciation warning, but was able to get both green checks.

1 Like