practical 5

Develop a playbook - /home/thor/playbooks/install_packages.yml - to install an extra package htop on web2 node. The package name htop must be passed as a value to a variable extra_packages with the -e option in the command line while running the playbook. The playbook install_packages.yml already has some exiting code, modify the task install extra packages so that it only runs if extra_packages variable is defined and it has value htop. At the end playbook must be able to install this extra package on web2 node while passing correct values in the extra vars i.e -e.


Use inventory from /home/thor/playbooks/inventory

 


=================

- hosts: web2

  gather_facts: no

  tasks:

    - name: install nginx

      apt: name=nginx state=present

      tags: [install_core]


    - name: install extra packages

      apt: name={{item}}

      with_items: "{{extra_packages}}"

      when: extra_packages is defined and extra_packages == "htop"

Comments

Popular posts from this blog

exam 16

ansible 5

practical 3