-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite_before_roles.yml
178 lines (151 loc) · 3.81 KB
/
site_before_roles.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
---
- hosts: all
become: true
pre_tasks:
- name: update repo cache (Alma Linux)
tags: always
dnf:
update_only: yes
update_cache: yes
changed_when: false
when: ansible_distribution == "AlmaLinux"
- name: update repo cache (Centos)
tags: always
dnf:
update_only: yes
update_cache: yes
changed_when: false
when: ansible_distribution == "CentOS"
- name: update repo cache (Ubuntu)
tags: always
apt:
update_cache: yes
changed_when: false
when: ansible_distribution == "Ubuntu"
- hosts: all
become: true
tasks:
- name: add ssh key for simone
tags: always
authorized_key:
user: simone
key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMAn3oWEjSIMU4uGRqnxe9dxcJFXzuw6LI/rQ04gT6ZQ ansible"
- hosts: workstations
become: true
tasks:
- name: install unzip
package:
name: unzip
- name: install terraform
unarchive:
src: https://releases.hashicorp.com/terraform/0.12.28/terraform_0.12.28_linux_amd64.zip
dest: /usr/local/bin
remote_src: yes
mode: 0755
owner: root
group: root
- hosts: web_servers
become: true
tasks:
- name: install apache and php packages for Centos
tags: apache,apache2,centos
dnf:
name:
- httpd
- php
state: latest
when: ansible_distribution == "CentOS"
- name: install apache and PHP packages for Ubuntu Linux
tags: apache,centos,httpd
apt:
name:
- apache2
- libapache2-mod-php
state: latest
when: ansible_distribution == "Ubuntu"
- name: install apache and php packages for Alma Linux
tags: apache,almalinux,httpd
dnf:
name:
- httpd
- php
state: latest
when: ansible_distribution == "AlmaLinux"
- name: start httpd (CentOS)
tags: apache,centos,httpd
service:
name: httpd
state: started
enabled: yes
when: ansible_distribution == "CentOS"
- name: start httpd (AlmaLinux)
tags: apache,almalinux,httpd
service:
name: httpd
state: started
enabled: yes
when: ansible_distribution == "AlmaLinux"
- name: change email address for admin
tags: apache,centos,httpd
lineinfile:
path: /etc/httpd/conf/httpd.conf
regexp: '^ServerAdmin'
line: ServerAdmin [email protected]
when: ansible_distribution == "CentoOS"
- name: change email address for admin (AlmaLinux)
tags: apache,alma,httpd
lineinfile:
path: /etc/httpd/conf/httpd.conf
regexp: '^ServerAdmin'
line: ServerAdmin [email protected]
when: ansible_distribution == "AlmaLinux"
register: httpd
- name: restart httpd (Centos)
tags: apache,Centos,httpd
service:
name: httpd
state: restarted
when: httpd.changed
- name: restart httpd (AlmaLinux)
tags: apache,AlmaLinux,httpd
service:
name: httpd
state: restarted
when: httpd.changed
- name: copy default html file for site
tags: apache,apache2,httpd
copy:
src: default_site.html
dest: /var/www/html/index.html
owner: root
group: root
mode: 0644
- hosts: db_servers
become: true
tasks:
- name: install mariadb package (Centos)
tags: centos,db,mariadb
dnf:
name: mariadb
state: lastest
when: ansible_distribution == "CentOS"
- name: install mariadb package (Ubuntu)
tags: ubuntu,db,mariadb
apt:
name: mariadb-server
state: latest
when: ansible_distribution == "Ubuntu"
- name: install mariadb package (Alma Linux)
tags: alma,db,mariadb
dnf:
name: mariadb
state: latest
when: ansible_distribution == "AlmaLinux"
- hosts: file_servers
become: true
tasks:
- name: install samba package
tags: samba
package:
name: samba
state: latest