Ansible

Modify the following task to use a variable instead of the value "zlib" and have "zlib" as the default in case the variable is not defined

- name: Install a package
  package:
    name: "zlib"
    state: present

Difficulty: unrated

Source: bregman-arie/devops-exercises by Arie Bregman

Answer

- name: Install a package
  package:
    name: "{{ package_name|default('zlib') }}"
    state: present