Skip to content

Commit 09d47ba

Browse files
authored
Merge pull request #10 from simondecaestecker/master
Adding bundle-xenial-icehrm
2 parents d557f6b + fa2d4a5 commit 09d47ba

File tree

12 files changed

+514
-3
lines changed

12 files changed

+514
-3
lines changed

images/build.packer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
"type": "shell",
2727
"inline": [
2828
"sudo DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::=\"--force-confold\" purge python-pip -y",
29-
"sudo apt-get update",
30-
"sudo DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::=\"--force-confold\" upgrade -y",
31-
"sudo DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::=\"--force-confold\" install aptitude git gcc libffi-dev libssl-dev python-dev python-pip -y",
3229
"sudo pip install -U pip ansible"
3330

3431
]
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
- hosts: local
3+
become: yes
4+
5+
tasks:
6+
- name: Adding APT key
7+
apt_key:
8+
keyserver: keyserver.ubuntu.com
9+
id: "0xcbcb082a1bb943db"
10+
11+
- name: Adding a repository
12+
apt_repository:
13+
repo: deb http://mirror.aarnet.edu.au/pub/MariaDB/repo/5.5/debian wheezy main
14+
state: present
15+
16+
- name: Unlock apt
17+
shell: rm /var/lib/dpkg/lock && dpkg --configure -a
18+
19+
- name: Installation de Apache2, PHP, MariaDB, Galera, rsync, GlusterFS et des divers modules et dépendances
20+
apt:
21+
name: "{{item}}"
22+
update_cache: yes
23+
force: yes
24+
with_items:
25+
- apache2
26+
- php
27+
- mariadb-galera-server
28+
- libapache2-mod-php
29+
- php7.0-mysql
30+
- python-mysqldb
31+
- rsync
32+
- galera
33+
- glusterfs-server
34+
35+
- name: Téléchargement du zip de iceHRM
36+
get_url:
37+
url: https://github.com/gamonoid/icehrm/releases/download/v18.0.OS/icehrm_v18.0.OS.zip
38+
dest: /root/icehrm.zip
39+
40+
- name: Ajout des playbooks et scripts à exécuter
41+
copy:
42+
src: "files/{{item}}"
43+
dest: /root/
44+
with_items:
45+
- format
46+
- mariadb_inst1.cnf
47+
- mariadb_inst2.cnf
48+
- config.yml
49+
- config_inst1.yml
50+
- config_inst2.yml
51+
- rc.local
52+
- testmysql
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
- name: Fixing boot script
3+
lineinfile:
4+
dest: /etc/rc.local
5+
regexp: "^/opt/testmysql INSTANCE_NAME"
6+
line: "/opt/testmysql inst2"
7+
8+
- name: Starting MariaDB and creating the cluster
9+
shell: service mysql start --wsrep-new-cluster
10+
11+
- name: Disabling Foreign Key checks
12+
shell: mysql --execute="SET GLOBAL FOREIGN_KEY_CHECKS=0;"
13+
14+
- name: Creating iceHRM's database
15+
mysql_db:
16+
name: icehrmdb
17+
state: present
18+
19+
- name: Creating iceHRM's default DB user
20+
mysql_user:
21+
name: icehrmuser
22+
password: "{{sqlpass}}"
23+
priv: "icehrmdb.*:ALL"
24+
state: present
25+
26+
- name: Waiting for inst2 to continue
27+
wait_for:
28+
host: inst2
29+
port: 4567
30+
delay: 1
31+
timeout: 300
32+
33+
- name: Adding GlusterFS peer
34+
shell: gluster peer probe inst2
35+
36+
- name: Creating GlusterFS cluster
37+
shell: gluster volume create gfscluster_icehrm replica 2 inst1:/srv/icehrm/data inst2:/srv/icehrm/data
38+
39+
- name: Setting GlusterFS cluster
40+
shell: gluster volume set gfscluster_icehrm network.ping-timeout 2
41+
42+
- name: Starting GlusterFS cluster
43+
shell: gluster volume start gfscluster_icehrm
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
- name: Fixing boot script
3+
lineinfile:
4+
dest: /etc/rc.local
5+
regexp: "^/opt/testmysql INSTANCE_NAME"
6+
line: "/opt/testmysql inst1"
7+
8+
- name: Waiting for inst1 to continue
9+
wait_for:
10+
host: inst1
11+
port: 4567
12+
delay: 1
13+
timeout: 300
14+
15+
- name: Starting MariaDB
16+
service:
17+
name: mysql
18+
state: started
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
eval $(sudo blkid /dev/vdb | awk '{print $3}')
3+
if [ "$TYPE" != "ext4" ]; then
4+
wipefs -f /dev/vdb
5+
mkfs.ext4 -F /dev/vdb
6+
fi
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[mysqld]
2+
#mysql settings
3+
binlog_format=ROW
4+
default-storage-engine=innodb
5+
innodb_autoinc_lock_mode=2
6+
query_cache_size=0
7+
query_cache_type=0
8+
bind-address=0.0.0.0
9+
#galera settings
10+
wsrep_provider=/usr/lib/galera/libgalera_smm.so
11+
wsrep_provider_options="pc.ignore_sb=true"
12+
wsrep_cluster_name="sqlcluster_icehrm"
13+
wsrep_cluster_address="gcomm://"
14+
wsrep_sst_method=rsync
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[mysqld]
2+
#mysql settings
3+
binlog_format=ROW
4+
default-storage-engine=innodb
5+
innodb_autoinc_lock_mode=2
6+
query_cache_size=0
7+
query_cache_type=0
8+
bind-address=0.0.0.0
9+
#galera settings
10+
wsrep_provider=/usr/lib/galera/libgalera_smm.so
11+
wsrep_provider_options="pc.ignore_sb=true"
12+
wsrep_cluster_name="sqlcluster_icehrm"
13+
wsrep_cluster_address="gcomm://inst1,inst2"
14+
wsrep_sst_method=rsync
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh -e
2+
#
3+
# rc.local
4+
#
5+
# This script is executed at the end of each multiuser runlevel.
6+
# Make sure that the script will "exit 0" on success or any other
7+
# value on error.
8+
#
9+
# In order to enable or disable this script just change the execution
10+
# bits.
11+
#
12+
# By default this script does nothing.
13+
14+
gluster volume start gfscluster_icehrm force
15+
mount -t glusterfs localhost:/gfscluster_icehrm /var/www/html/app
16+
17+
/opt/testmysql INSTANCE_NAME
18+
19+
exit 0
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
sed "/wsrep_cluster_address/d" /etc/mysql/conf.d/mariadb.cnf > /etc/mysql/conf.d/mariadbcnf
4+
rm /etc/mysql/conf.d/mariadb.cnf
5+
mv /etc/mysql/conf.d/mariadbcnf /etc/mysql/conf.d/mariadb.cnf
6+
7+
if nc -z $1 4567
8+
then
9+
echo -e "wsrep_cluster_address=\"gcomm://inst1,inst2\"" >> /etc/mysql/conf.d/mariadb.cnf
10+
/etc/init.d/mysql start
11+
else
12+
echo -e "wsrep_cluster_address=\"gcomm://\"" >> /etc/mysql/conf.d/mariadb.cnf
13+
/etc/init.d/mysql start --wsrep-new-cluster
14+
fi

0 commit comments

Comments
 (0)