programs
Ansible

Ansible

Install

macOS

brew install ansible
pip install ansible-lint # linter, integrates with the VSCode extension

Debian

sudo apt-add-repository ppa:ansible/ansible -y
sudo apt update
sudo apt install ansible -y

Usage

Run a playbook

ansible-playbook $PLAYBOOK_FILE -K # prompts for password for `sudo`

Syntax

Loops

- name: Add several users
  ansible.builtin.user:
    name: "{{ item }}"
  loop:
    - testuser1
    - testuser2

Conditionals

- ansible.builtin.command: ls -a
  register: ls_output
 
- command: someothercommand
  when: ls_output.stdout == ""

Modules

file

ansible.builtin.file:
  path: "~/Pictures/Screenshots"
  state: directory
  mode: "0755"