Files
ansible/conditionals.md

314 B

Conditionals

Run tasks based on conditions:

tasks:
  - name: Install on Debian
    apt:
      name: apache2
      state: present
    when: ansible_facts.os_family == "Debian"

  - name: Install on RedHat
    yum:
      name: httpd
      state: present
    when: ansible_facts.os_family == "RedHat"