Skip to content

Ansible Playbook examples

Reboot hosts playbook

cat <<EOF > playbook_reboot.yml
- name: "Reboot"
  hosts: all
  become: yes
  become_method: sudo
  gather_facts: no
  tasks:
  - reboot:
EOF

Debug variables

- name: Display all variables/facts known for a host
  debug:
    var: hostvars[inventory_hostname]