forked from carrier-io/installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
carrierbook.yml
172 lines (141 loc) · 6.32 KB
/
carrierbook.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
---
- hosts: myhost
become: yes
vars_files:
- vars/default.yml
tasks:
- name: Install aptitude using apt
apt: name=aptitude state=latest update_cache=yes force_apt_get=yes
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Install required system packages
apt: name={{ item }} state=latest update_cache=yes
loop: [ 'apt-transport-https', 'git', 'ca-certificates', 'curl', 'software-properties-common']
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Add docker GPG apt key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Add docker repository
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu bionic stable
state: present
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Update apt and install docker-ce
yum: update_cache=yes name=docker-ce state=latest
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Install required system packages
yum: name={{ item }} state=latest update_cache=true
loop: [ 'epel-release', 'yum-utils', 'lvm2', 'git', 'ca-certificates', 'curl' ]
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Add docker repo
get_url:
url: https://download.docker.com/linux/centos/docker-ce.repo
dest: /etc/yum.repos.d/docker-ce.repo
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Install docker
package:
name: docker-ce
state: latest
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Start docker service
service:
name: docker
state: started
enabled: yes
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Create docker mount
shell: service docker stop && mkdir "{{ CARRIER_PATH }}/docker" && mount --rbind "{{ CARRIER_PATH }}/docker" /var/lib/docker && service docker start
- name: Install docker-compose
apt:
name: docker-compose
state: present
update_cache: yes
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Install docker-compose
get_url:
url : https://github.com/docker/compose/releases/download/1.25.1-rc1/docker-compose-Linux-x86_64
dest: /usr/local/bin/docker-compose
mode: 'u+x,g+x'
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
- name: Copy Files
shell: git clone https://github.com/carrier-io/installer.git --branch v.2.5 && mv ./installer/carrier "{{ CARRIER_PATH }}/carrier" && mkdir /installer && mv ./installer/grafana /installer/grafana && rm -rf ./installer
- name: Replace app host
replace:
path: "{{ CARRIER_PATH }}/carrier/.env"
regexp: 'http://localhost'
replace: "http://{{ APP_HOST }}"
- name: Replace install path
replace:
path: "{{ CARRIER_PATH }}/carrier/.env"
regexp: '/opt/carrier'
replace: "{{ CARRIER_PATH }}/carrier"
- name: Replace redis password
replace:
path: "{{ CARRIER_PATH }}/carrier/.env"
regexp: 'REDIS_PASSWORD=password'
replace: "REDIS_PASSWORD={{ REDIS_PASSWORD }}"
- name: Replace rabbit password
replace:
path: "{{ CARRIER_PATH }}/carrier/.env"
regexp: 'RABBIT_PASSWORD=password'
replace: "RABBIT_PASSWORD={{ RABBIT_PASSWORD }}"
- name: Replace influx password
replace:
path: "{{ CARRIER_PATH }}/carrier/.env"
regexp: 'INFLUX_PASSWORD=password'
replace: "INFLUX_PASSWORD={{ INFLUX_PASSWORD }}"
- name: Replace influx username
replace:
path: "{{ CARRIER_PATH }}/carrier/.env"
regexp: 'INFLUX_USERNAME=admin'
replace: "INFLUX_USERNAME={{ INFLUX_USERNAME }}"
- name: Replace influx host in telegraf config
replace:
path: "{{ CARRIER_PATH }}/carrier/telegraf/telegraf.conf"
regexp: 'INFLUX_HOST'
replace: "http://{{ APP_HOST }}:8086"
- name: Replace influx username in telegraf config
replace:
path: "{{ CARRIER_PATH }}/carrier/telegraf/telegraf.conf"
regexp: 'INFLUX_USER'
replace: "{{ INFLUX_USERNAME }}"
- name: Replace influx password in telegraf config
replace:
path: "{{ CARRIER_PATH }}/carrier/telegraf/telegraf.conf"
regexp: 'INFLUX_PASSWORD'
replace: "{{ INFLUX_PASSWORD }}"
- name: Create and start services
shell: cd "{{ CARRIER_PATH }}/carrier" && docker-compose up -d
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
register: output
- name: Create and start services
shell: cd "{{ CARRIER_PATH }}/carrier" && /usr/local/bin/docker-compose up -d
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
register: output
- name: Wait until the services fully load
command: sleep 35
- name: Replace influx password
replace:
path: "{{ CARRIER_PATH }}/carrier/bootstrap.sh"
regexp: 'INFLUXPASSWORD'
replace: "{{ INFLUX_PASSWORD }}"
- name: Bootstrap influx username
replace:
path: "{{ CARRIER_PATH }}/carrier/bootstrap.sh"
regexp: 'INFLUXUSERNAME'
replace: "{{ INFLUX_USERNAME }}"
- name: Restart services
shell: docker restart carrier-vault && sleep 30 && docker restart carrier-galloper
- name: bootstrap
shell: bash "{{ CARRIER_PATH }}/carrier/bootstrap.sh" http {{ APP_HOST }} {{ CARRIER_PATH }}
- name: Restart services
shell: cd "{{ CARRIER_PATH }}/carrier" && docker-compose up -d
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
register: output
- name: Restart services
shell: cd "{{ CARRIER_PATH }}/carrier" && /usr/local/bin/docker-compose up -d
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
register: output
- debug:
var: output