AnsiblePlaybooksRemoteInstalling packages

Installing APT packages

Creating the playbook

Executed:

aadmin@uvm0:~/code/it-wiz/devops/ansible/projects/remote/playbooks$ touch install_packages.yml

Brought install_packages.yml to the following form:

- name: Install APT packages
  hosts: all
  become: yes
  tasks:
    - name: Update APT cache
      apt:
        update_cache: yes

    - name: Install mc and iotop
      apt:
        name:
          - mc
          - iotop
        state: present

Equivalent Bash commands

root@uvm26:~# sudo apt update && sudo apt install -y mc iotop
root@uvm27:~# sudo apt update && sudo apt install -y mc iotop

Execution of the playbook

Executed:

aadmin@uvm0:~/code/it-wiz/devops/ansible/projects/remote$ ansible-playbook playbooks/install_packages.yml --ask-vault-pass

Details

    aadmin@uvm0:~/code/it-wiz/devops/ansible/projects/remote$ ansible-playbook playbooks/install_packages.yml --ask-vault-pass
    Vault password:
 
    PLAY [Install APT packages] **************************************************************************************
 
    TASK [Gathering Facts] *******************************************************************************************
    ok: [uvm27]
    ok: [uvm26]
 
    TASK [Update APT cache] ******************************************************************************************
    changed: [uvm27]
    changed: [uvm26]
 
    TASK [Install mc and iotop] **************************************************************************************
    changed: [uvm27]
    changed: [uvm26]
 
    PLAY RECAP *******************************************************************************************************
    uvm26                      : ok=3    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
    uvm27                      : ok=3    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Result

The APT packages got installed.