Ansible

Create a play book

If we want that jq is installed on a Debian machine, the following playbook can be used:

---
- name: Provision my machine with goodies
  hosts: localhost

  tasks:
  - name: Install jq
    apt:
      name: jq

Run it:

sudo ansible-playbook my-playbook.yml -vvvv

Removing packages

Ansible is stateless so it doesn’t know when a package is removed. If you want to remove a package, it needs to be explicitly stated in task the playbook:

tasks:
- name: Remove jq
  apt:
    name: jq
    state: absent         # Make sure that the package isn't available

References