-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathwp.yaml
More file actions
102 lines (84 loc) · 1.96 KB
/
wp.yaml
File metadata and controls
102 lines (84 loc) · 1.96 KB
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
---
- hosts: aws_linux_vm
become: yes
vars:
db_name: wordpress
db_user: wordpress
db_password: secure-123
db_host: 18.209.168.230 # added DB_HOST
wp_table_prefix: wp_ # added wp_table_prefix
tasks:
- name: Update all packages to the latest version
yum:
name: '*'
state: latest
- name: Install python3-pip
yum:
name: python3-pip
state: present
- name: Install PyMySQL
pip:
name: pymysql
state: present
- name: Install PHP 7.2 from Amazon Linux Extras
command: amazon-linux-extras install -y php7.2
- name: Install necessary packages
yum:
name:
- httpd
- mariadb-server
state: latest
- name: Start and enable Apache and MariaDB services
systemd:
name: "{{ item }}"
state: started
enabled: yes
loop:
- httpd
- mariadb
- name: Remove anonymous MySQL user
mysql_user:
name: ''
host_all:
state: absent
notify: restart mysql
- name: Remove MySQL test database
mysql_db:
name: test
state: absent
notify: restart mysql
- name: Create new MySQL database
mysql_db:
name: "{{ db_name }}"
state: present
- name: Create new MySQL user
mysql_user:
name: "{{ db_user }}"
password: "{{ db_password }}"
priv: "*.*:ALL"
host: '%'
state: present
notify: restart mysql
- name: Download WordPress
get_url:
url: https://wordpress.org/latest.tar.gz
dest: /tmp/wordpress.tar.gz
mode: 0644
- name: Extract WordPress
unarchive:
src: /tmp/wordpress.tar.gz
dest: /var/www/html/
remote_src: yes
- name: Update WordPress config file
template:
src: ./wp-config.php.j2
dest: /var/www/html/wordpress/wp-config.php
- name: Restart Apache
systemd:
name: httpd
state: restarted
handlers:
- name: restart mysql
systemd:
name: mariadb
state: restarted