-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpTwo.yml
154 lines (129 loc) · 3.87 KB
/
wpTwo.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
---
- name: Configuring server for web hosting
hosts: wp_server_two
become: true
vars_files:
- wp_server/vars.yml
handlers:
- name: restart apache
service:
name: apache2
state: restarted
tasks:
- name: Ensure Apache, MySQL-cli and WordPress packets are installed.
apt:
name:
- apache2
- ghostscript
- libapache2-mod-php
- mysql-client
- php
- php-bcmath
- php-curl
- php-imagick
- php-intl
- php-json
- php-mbstring
- php-mysql
- php-xml
- php-zip
update_cache: yes
cache_valid_time: 3600
state: present
- name: Make sure Apache is running.
service:
name: apache2
state: started
- name: Change nameserver.
copy:
src: "{{ wordpress_server_location }}/{{ nameserver_files_folder }}/resolv.conf"
dest: /etc/resolv.conf
remote_src: false
- name: Create a www directory for WordPress installation.
file:
path: /srv/www
owner: www-data
state: directory
- name: Download unzip command.
apt:
name: unzip
state: present
update_cache: yes
cache_valid_time: 3600
- name: Download WordPress.
get_url:
url: "{{ wp_download_link }}"
dest: /srv/www/latest.zip
- name: Unzip downloaded latest.zip folder for site1.
unarchive:
src: /srv/www/latest.zip
dest: "/srv/www"
remote_src: true
#creates??
- name: Rename wordpress folders for site1.
shell: " mv /srv/www/wordpress /srv/www/{{ item.value }}"
args:
creates: "/srv/www/{{ site_one_subdomain }}"
with_items:
- value: "{{ site_one_subdomain }}"
- name: Unzip downloaded latest.zip folder for site2.
unarchive:
src: /srv/www/latest.zip
dest: "/srv/www"
remote_src: true
- name: Rename wordpress folders for site2.
shell: " mv /srv/www/wordpress /srv/www/{{ item.value }}"
args:
creates: "/srv/www/{{ site_two_subdomain }}"
with_items:
- value: "{{ site_two_subdomain }}"
- name: Disable 000-default.conf Apache default web page.
file:
path: "/etc/apache2/sites-enabled/000-default.conf"
state: absent
notify:
- restart apache
- name: Make WordPress configuration file.
file:
path: "/etc/apache2/sites-available/{{ item.value }}.conf"
state: touch
with_items:
- value: "{{ site_one_subdomain }}"
- value: "{{ site_two_subdomain }}"
- name: Fill .conf files from sites-available with data.
copy:
src: "{{ wordpress_server_location }}/{{ item.value }}/{{ item.value }}.conf"
dest: "/etc/apache2/sites-available/{{ item.value }}.conf"
remote_src: false
with_items:
- value: "{{ site_one_subdomain }}"
- value: "{{ site_two_subdomain }}"
- name: Make a symlinks for .conf files from sites-available to sites-enabled.
file:
src: "/etc/apache2/sites-available/{{ item.value }}.conf"
dest: "/etc/apache2/sites-enabled/{{ item.value }}.conf"
state: link
notify:
- restart apache
with_items:
- value: "{{ site_one_subdomain }}"
- value: "{{ site_two_subdomain }}"
- name: Make wp-config.php files for site1.
file:
path: "/srv/www/{{ item.value }}/wp-config.conf"
state: touch
with_items:
- value: "{{ site_one_subdomain }}"
- name: Make wp-config.php files for site2.
file:
path: "/srv/www/{{ item.value }}/wp-config.conf"
state: touch
with_items:
- value: "{{ site_two_subdomain }}"
- name: Edit wp-config.php file for both sites.
copy:
src: "{{ wordpress_server_location }}/{{ item.value }}/wp-config.php"
dest: "/srv/www/{{ item.value }}/wp-config.php"
with_items:
- value: "{{ site_one_subdomain }}"
- value: "{{site_two_subdomain }}"