-
Notifications
You must be signed in to change notification settings - Fork 29
/
when.yaml
28 lines (27 loc) · 962 Bytes
/
when.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
---
- hosts: localhost
#gather_facts: no
become: yes
tasks:
- name: Install Apache HTTP server on RedHat Server
yum:
name: httpd
state: present
when: ansible_os_family == "RedHat"
- name: Install Apache HTTP server on Ubuntu server
apt:
name: apache2
state: present
when: ansible_os_family == "Debian"
- name: Install Apache HTTP server on CentOS server
yum:
name: httpd
state: present
when:
- ansible_facts['distribution'] == "CentOS"
- ansible_facts['distribution_major_version'] == "6"
- name: Shutdown CentOS 6 and Debian 7 Servers
command: /sbin/shutdown -t now
when: (ansible_facts['distribution'] == "CentOS" and ansible_facts['distribution_major_version'] == "6") or
(ansible_facts['distribution'] == "Debian" and ansible_facts['distribution_major_version'] == "7")
#https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html