Skip to content

Writing Your First Playbook

---
- name: Install Apache on webservers
  hosts: webservers
  become: yes
  tasks:
    - name: Ensure Apache is installed
      apt:
        name: apache2
        state: present
      when: ansible_os_family == "Debian"

Run Playbook

ansible-playbook -i hosts.ini playbook.yml