-
Notifications
You must be signed in to change notification settings - Fork 1
/
CentOS7x_Install-Ansible-playbook.yml
323 lines (248 loc) · 8.75 KB
/
CentOS7x_Install-Ansible-playbook.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
---
################################################################################
# description: Installs Ansible with CenturyLink Cloud kit on CentOS7x
# usage: ansible-playbook CentOS7x_Install-Ansible-playbook.yml --extra-vars 'HostOrGroup=YourServerOrGroupNameGoesHere'
# or: ansible-playbook CentOS7x_Install-Ansible-playbook.yml --extra-vars 'HostOrGroup=YourServerOrGroupNameGoesHere CLC_V2_API_USERNAME=YourCenturyLinkCloudControlUsername CLC_V2_API_PASSWD=YourCenturyLinkCloudControlPassword'
# author: Ernest G. Wilson II <ErnestGWilsonII@gmail.com> (https://github.com/ernestgwilsonii)
# license: MIT
################################################################################
# Ansible Playbook options
# REF: http://docs.ansible.com/ansible/playbooks.html
#####################################################
- name: Install Ansible with CenturyLink Cloud kit on CentOS7x
hosts: "{{ HostOrGroup|default ('FATAL ERROR --> HostOrGroup NOT SET! You must specify either a Host or a Group name!') }}"
serial: "100%"
gather_facts: False
tasks:
# Install yum packages (listed in alphabetical order)
# REF: http://docs.ansible.com/ansible/yum_module.html
######################################################
- name: Install gcc
yum:
name=gcc
state=latest
- name: Install gcc-c++
yum:
name=gcc-c++
state=latest
- name: Install git
yum:
name=git
state=latest
- name: Install krb5-devel
yum:
name=krb5-devel
state=latest
- name: Install krb5-libs
yum:
name=krb5-libs
state=latest
- name: Install krb5-workstation
yum:
name=krb5-workstation
state=latest
- name: Install libffi-devel
yum:
name=libffi-devel
state=latest
- name: Install make
yum:
name=make
state=latest
- name: Install openssl-devel
yum:
name=openssl-devel
state=latest
- name: Install python-devel
yum:
name=python-devel
state=latest
- name: Install python-setuptools
yum:
name=python-setuptools
state=latest
- name: Install sshpass
yum:
name=sshpass
state=latest
# Execute command(s)
# REF: http://docs.ansible.com/ansible/command_module.html
##########################################################
- name: Use easy_install to install pip
command: /usr/bin/easy_install pip
# Use pip to install and manage Python dependencies
# REF: http://docs.ansible.com/ansible/pip_module.html
######################################################
- name: Use pip to install pybuilder
pip:
name=pybuilder
- name: Use pip to install mock
pip:
name=mock
- name: Use pip to install nose
pip:
name=nose
- name: Use pip to install coverage
pip:
name=coverage
- name: Use pip to install cryptography
pip:
name=cryptography
- name: Use pip to install xmltodict
pip:
name=xmltodict
- name: Use pip to install pywinrm
pip:
name=pywinrm
version=0.1.1
- name: Use pip to install kerberos
pip:
name=kerberos
- name: Use pip to install httplib2
pip:
name=httplib2
- name: Use pip to install requests
pip:
name=requests
- name: Use pip to install simplejson
pip:
name=simplejson
- name: Use pip to install docker-cloud
pip:
name=docker-cloud
- name: Use pip to install docker-py
pip:
name=docker-py
- name: Use pip to install ansible
pip:
name=ansible
- name: Use pip to install clc-sdk
pip:
name=clc-sdk
- name: Use pip to install clc-ansible-module
pip:
name=clc-ansible-module
# See: https://github.com/CenturyLinkCloud/clc-ansible-module
# Use the file module to create a directory and symbolic links if they don't exist
# REF: http://docs.ansible.com/ansible/file_module.html
##################################################################################
- name: Create directory /etc/ansible if it does not exist - mkdir -p /etc/ansible
file:
path=/etc/ansible
state=directory
mode=0755
- name: Create directory /etc/ansible/group_vars if it does not exist - mkdir -p /etc/ansible/group_vars
file:
path=/etc/ansible/group_vars
state=directory
mode=0755
- name: Create directory /etc/ansible/host_vars if it does not exist - mkdir -p /etc/ansible/host_vars
file:
path=/etc/ansible/host_vars
state=directory
mode=0755
- name: Create symbolic link if it does not exist - ln -s /usr/bin/clc_inv.py /etc/ansible/hosts
file:
src=/usr/bin/clc_inv.py
dest=/etc/ansible/hosts
state=link
- name: Create symbolic link if it does not exist - ln -s /usr/bin/clc_inv.py /usr/local/bin/clc_inv.py
file:
src=/usr/bin/clc_inv.py
dest=/usr/local/bin/clc_inv.py
state=link
- name: Create directory /etc/ansible/vault if it does not exist - mkdir -p /etc/ansible/vault
file:
path=/etc/ansible/vault
state=directory
mode=0755
- name: Create empty file used later - /etc/ansible/vault/vault_pass.txt
file:
path=/etc/ansible/vault/vault_pass.txt
state=touch
mode=0644
- name: Create empty file used later - /etc/ansible/.gitignore
file:
path=/etc/ansible/.gitignore
state=touch
mode=0644
# Set attributes of files
# REF: http://docs.ansible.com/ansible/file_module.html
#######################################################
- name: Create a blank Ansible configuration - /etc/ansible/ansible.cfg
file:
path=/etc/ansible/ansible.cfg
state=touch
mode=0644
# Update various configuration files
# REF: http://docs.ansible.com/ansible/lineinfile_module.html
#############################################################
# Populate values in /etc/ansible/ansible.cfg
- name: Populate values in /etc/ansible/ansible.cfg with - [defaults]
lineinfile:
dest=/etc/ansible/ansible.cfg
state=present
line='[defaults]'
- name: Populate values in /etc/ansible/ansible.cfg with - library=/usr/lib/python2.7/site-packages/clc_ansible_module
lineinfile:
dest=/etc/ansible/ansible.cfg
state=present
line='library=/usr/lib/python2.7/site-packages/clc_ansible_module'
- name: Populate values in /etc/ansible/ansible.cfg with - inventory=/etc/ansible/hosts
lineinfile:
dest=/etc/ansible/ansible.cfg
state=present
line='inventory=/etc/ansible/hosts'
- name: Populate values in /etc/ansible/ansible.cfg with - host_key_checking=False
lineinfile:
dest=/etc/ansible/ansible.cfg
state=present
line='host_key_checking=False'
- name: Populate values in /etc/ansible/ansible.cfg with - retry_files_enabled=False
lineinfile:
dest=/etc/ansible/ansible.cfg
state=present
line='retry_files_enabled=False'
- name: Populate values in /etc/ansible/ansible.cfg with - forks=100
lineinfile:
dest=/etc/ansible/ansible.cfg
state=present
line='forks=100'
# Populate values in /root/.bashrc
- name: Populate values in /root/.bashrc with - export ANSIBLE_LIBRARY=/usr/lib/python2.7/site-packages/clc_ansible_module
lineinfile:
dest=/root/.bashrc
state=present
line='export ANSIBLE_LIBRARY=/usr/lib/python2.7/site-packages/clc_ansible_module'
- name: Populate values in /root/.bashrc with - export ANSIBLE_HOST_KEY_CHECKING=False
lineinfile:
dest=/root/.bashrc
state=present
line='export ANSIBLE_HOST_KEY_CHECKING=False'
- name: Populate values in /root/.bashrc with - export ANSIBLE_VAULT_PASSWORD_FILE=/etc/ansible/vault/vault_pass.txt
lineinfile:
dest=/root/.bashrc
state=present
line='export ANSIBLE_VAULT_PASSWORD_FILE=/etc/ansible/vault/vault_pass.txt'
- name: Populate values in /root/.bashrc with - export CLC_V2_API_USERNAME='YourCenturyLinkCloudControlUsername'
lineinfile:
dest=/root/.bashrc
state=present
line='export CLC_V2_API_USERNAME='{{ CLC_V2_API_USERNAME|default ('YourCenturyLinkCloudControlUsername') }}''
- name: Populate values in /root/.bashrc with - export CLC_V2_API_PASSWD='YourCenturyLinkCloudControlPassword'
lineinfile:
dest=/root/.bashrc
state=present
line='export CLC_V2_API_PASSWD='{{ CLC_V2_API_PASSWD|default ('YourCenturyLinkCloudControlPassword') }}''
# Populate values in /etc/ansible/vault/vault_pass.txt
- name: Populate values in /etc/ansible/vault/vault_pass.txt with - YourVaultPasswordGoesHere
lineinfile:
dest=/etc/ansible/vault/vault_pass.txt
state=present
line='YourVaultPasswordGoesHere'
# Populate values in /etc/ansible/.gitignore
- name: Populate values in /etc/ansible/.gitignore with - vault
lineinfile:
dest=/etc/ansible/.gitignore
state=present
line='vault'