-
Notifications
You must be signed in to change notification settings - Fork 0
/
loop_deploy.yml
50 lines (35 loc) · 1.21 KB
/
loop_deploy.yml
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
- name: install Apache and upload simple web page
hosts: all
become: yes
vars:
source_folder: ./for_deploy
destin_folder: /var/www/html
tasks:
- name: Print linux distribution family
debug: var=ansible_os_family
- block: # RedHat block
- name: Install Apache package on RedHat
yum: name=httpd state=latest
- name: Start and enable Apache service on RedHat
service: name=httpd state=started enabled=yes
when: ansible_os_family == "RedHat"
- block: # Debian block
- name: Install Apache package on Debian
apt: name=apache2 state=latest
- name: Start and enable Apache service on Debian
service: name=apache2 state=started enabled=yes
when: ansible_os_family == "Debian"
- name: Upload web page
copy: src={{ item }} dest={{ destin_folder }} mode=055
with_fileglob: "{{ source_folder }}/*.*"
notify:
- Restart Apache service RedHat
- Restart Apache service Debian
handlers:
- name: Restart Apache service RedHat
service: name=httpd state=restarted
when: ansible_os_family == "RedHat"
- name: Restart Apache service Debian
service: name=apache2 state=restarted
when: ansible_os_family == "Debian"