1+ ---
2+ - hosts : local
3+ become : yes
4+
5+ tasks :
6+ - name : Stopping MariaDB
7+ service :
8+ name : mysql
9+ state : stopped
10+
11+ - name : Adding MariaDB conf
12+ copy :
13+ remote_src : true
14+ src : " /root/mariadb_{{instance_name}}.cnf"
15+ dest : /etc/mysql/conf.d/mariadb.cnf
16+
17+ - name : Chmoding format script
18+ file :
19+ path : /root/format
20+ state : file
21+ mode : a+x
22+
23+ - name : Making mount folder
24+ file :
25+ path : /srv/icehrm
26+ state : directory
27+
28+ - name : Formatting volume
29+ shell : /root/format
30+
31+ - name : Mounting volume
32+ mount :
33+ src : /dev/vdb
34+ name : /srv/icehrm
35+ fstype : ext4
36+ state : mounted
37+
38+ - name : Making some folders
39+ file :
40+ path : " {{item}}"
41+ state : directory
42+ with_items :
43+ - /srv/icehrm/data
44+ - /srv/icehrm/mysql
45+
46+ - name : Copying MySQL files
47+ synchronize :
48+ src : /var/lib/mysql/
49+ dest : /srv/icehrm/mysql/
50+ recursive : yes
51+ perms : yes
52+
53+ - name : Removing old MySQL files
54+ file :
55+ path : /var/lib/mysql
56+ state : absent
57+
58+ - name : Mounting MySQL folder
59+ mount :
60+ opts : bind
61+ fstype : none
62+ src : /srv/icehrm/mysql
63+ name : /var/lib/mysql
64+ state : mounted
65+
66+ - name : Adding mounting at boot
67+ lineinfile :
68+ dest : /etc/fstab
69+ line : " /dev/vdb /srv/icehrm ext4 defaults 0 0"
70+
71+ - name : Adding boot script
72+ copy :
73+ remote_src : true
74+ src : /root/rc.local
75+ dest : /etc/rc.local
76+
77+ - name : Adding Galera boot script
78+ copy :
79+ remote_src : true
80+ src : /root/testmysql
81+ dest : /opt/testmysql
82+
83+ - name : Chmoding Galera boot script
84+ file :
85+ path : /opt/testmysql
86+ state : file
87+ mode : a+x
88+
89+ - name : Disabling MySQL at boot
90+ service :
91+ name : mysql
92+ enabled : no
93+
94+ - name : Including customs tasks
95+ include : " /root/config_{{instance_name}}.yml"
96+ vars :
97+ sqlpass : " {{sqlpass}}"
98+
99+ - name : Removing any Apache2 content
100+ shell : rm -rf /var/www/html/*
101+
102+ - name : Creating GlusterFS client directory
103+ file :
104+ path : /var/www/html/app
105+ state : directory
106+
107+ - name : Waiting for inst1 to continue
108+ wait_for :
109+ host : inst1
110+ port : 49152
111+ delay : 1
112+ timeout : 300
113+
114+ - name : Mounting GlusterFS client
115+ shell : mount -t glusterfs inst1:/gfscluster_icehrm /var/www/html/app
116+
117+ - name : Extracting iceHRM's zip file
118+ unarchive :
119+ src : /root/icehrm.zip
120+ dest : /root/
121+ remote_src : yes
122+
123+ - name : Moving iceHRM's files in the right folder
124+ shell : cp -R /root/icehrm_v18.0.OS/* /var/www/html/ && rm /root/icehrm.zip && rm -rf /root/icehrm_v18.0.OS
125+
126+ - name : Changing owner of iceHRM's files
127+ file :
128+ path : /var/www/html/
129+ owner : www-data
130+ group : www-data
131+ recurse : yes
0 commit comments