-
Notifications
You must be signed in to change notification settings - Fork 1
/
CentOS7x_Install-Zenoss526-playbook.yml
704 lines (572 loc) · 21.1 KB
/
CentOS7x_Install-Zenoss526-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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
---
################################################################################
# description: Installs Zenoss 5x on CentOS7x
# usage: ansible-playbook CentOS7x_Install-Zenoss526-playbook.yml --extra-vars 'HostOrGroup=YourServerOrGroupNameGoesHere'
# 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 Zenoss Core 5.2.6 and Control Center 1.3.3 on CentOS7x REF https://www.zenoss.com/sites/default/files/Control_Center_Installation_Guide_r1.3.3_d1320.17.206.pdf
hosts: "{{ HostOrGroup|default ('FATAL ERROR --> HostOrGroup NOT SET! You must specify either a Host or a Group name!') }}"
serial: "100%"
gather_facts: False
tasks:
# Execute command(s)
# REF: http://docs.ansible.com/ansible/command_module.html
##########################################################
- name: Enable IPv4 Forwarding
command: /usr/sbin/sysctl -w net.ipv4.ip_forward=1
# Install or configure repository used on the OS by yum
# REF: https://docs.ansible.com/ansible/yum_repository_module.html
##################################################################
# /etc/yum.repos.d/docker-ce.repo
# https://docs.docker.com/engine/installation/linux/docker-ce/centos/#install-docker-ce
- name: Install repository Docker CE Stable
yum_repository:
name: docker-ce-stable
description: Docker CE Stable
file: docker-ce
baseurl: https://download.docker.com/linux/centos/7/$basearch/stable
enabled: yes
gpgcheck: yes
gpgkey: https://download.docker.com/linux/centos/gpg
# # Old Docker Repo - Do not use!
# # /etc/yum.repos.d/docker.repo
# - name: Install dockerrepo repository
# yum_repository:
# name: dockerrepo
# description: Docker Repository
# file: docker
# baseurl: https://yum.dockerproject.org/repo/main/centos/7
# enabled: yes
# gpgcheck: yes
# gpgkey: https://yum.dockerproject.org/gpg
# /etc/yum.repos.d/zenoss-stable.repo
- name: Install Zenoss Stable repository
yum_repository:
name: zenoss-stable
description: Zenoss Stable Repository
file: zenoss-stable
baseurl: http://get.zenoss.io/yum/zenoss/stable/centos/el7/os/x86_64
enabled: yes
gpgcheck: no
# Install yum packages
# REF: http://docs.ansible.com/ansible/yum_module.html
######################################################
# Zenoss is broken and cannot find this dependancy, so we manually install hit here first as a work-around:
- name: Install docker-ce-selinux-17.03.1.ce-1.el7.centos.noarch.rpm
yum:
name: https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.1.ce-1.el7.centos.noarch.rpm
state: present
# Install Zenoss first so it can select which version of Docker it likes today:
- name: Install zenoss-core-service
yum:
name: zenoss-core-service
state: latest
# # Download and install a specific supported Docker version for Zenoss
# - name: Install specific / Zenoss approved docker-engine
# yum:
# name: docker-engine-17.03.1.ce-1.el7.centos
# state: present
# # REF: https://yum.dockerproject.org/repo/main/centos/7/Packages/
- name: Install bind-utils
yum:
name: bind-utils
state: latest
- name: Install bridge-utils
yum:
name: bridge-utils
state: latest
# brctl show
- name: Install dnsmasq
yum:
name: dnsmasq
state: latest
- name: Install htop
yum:
name: htop
state: latest
- name: Install lvm2
yum:
name: lvm2.x86_64
state: latest
- name: Install python-pip
yum:
name: python-pip
state: latest
# Execute command(s)
# REF: http://docs.ansible.com/ansible/command_module.html
##########################################################
- name: Use pip to update and ensure pip is at the latest version
command: /usr/bin/pip install --upgrade pip
# Use pip to install and manage Python dependencies
# REF: http://docs.ansible.com/ansible/pip_module.html
######################################################
- name: Use pip to install docker-py
pip:
name: docker-py
# get_url - Downloads files from HTTP, HTTPS, or FTP to node
# REF: http://docs.ansible.com/ansible/get_url_module.html
############################################################
# https://github.com/docker/machine/releases
- name: Download and install docker-machine
get_url:
url: https://github.com/docker/machine/releases/download/v0.10.0/docker-machine-Linux-x86_64
dest: /usr/local/bin/docker-machine
mode: 777
force: yes
# https://github.com/docker/compose/releases
- name: Download and install docker-compose
get_url:
url: https://github.com/docker/compose/releases/download/1.12.0/docker-compose-Linux-x86_64
dest: /usr/local/bin/docker-compose
mode: 777
force: yes
# command - Executes a command on a remote node
# REF: http://docs.ansible.com/ansible/command_module.html
##########################################################
# Use the Zenoss serviced-storage tool to create a thinpool LVM volume group called docker on /dev/sdc
- name: "serviced-storage create-thin-pool docker {{DockerBlkDev|default ('/dev/sdc')}}"
command: "serviced-storage create-thin-pool docker {{DockerBlkDev|default ('/dev/sdc')}}"
# file - Sets attributes of files and directories
# http://docs.ansible.com/ansible/file_module.html
##################################################
- name: Create directory /etc/docker if it does not already exist
file:
path: /etc/docker
owner: root
group: root
mode: 0755
state: directory
# Use the copy module to copy various files into place
# REF: http://docs.ansible.com/ansible/copy_module.html
#######################################################
# /etc/docker/daemon.json
- name: Copy Docker configuration file daemon.json from Ansible files/Docker/etc_docker_daemon.json.ZENOSS to Zenoss remote /etc/docker/daemon.json
copy:
src=files/Docker/etc_docker_daemon.json.ZENOSS
dest=/etc/docker/daemon.json
owner=root
group=root
mode=0444
# command - Executes a command on a remote node
# REF: http://docs.ansible.com/ansible/command_module.html
##########################################################
# Use the Zenoss serviced-storage tool to create a thinpool LVM volume group called serviced on /dev/sdd
- name: "serviced-storage create-thin-pool serviced {{ZenossAppDataBlkDev|default ('/dev/sdd')}}"
command: "serviced-storage create-thin-pool serviced {{ZenossAppDataBlkDev|default ('/dev/sdd')}}"
# command - Executes a command on a remote node
# REF: http://docs.ansible.com/ansible/command_module.html
##########################################################
# Create LVM physical volume on {{ZenossControlCenterBlkDev|default ('/dev/sde')}}
- name: "pvcreate {{ZenossControlCenterBlkDev|default ('/dev/sde')}}"
command: "/usr/sbin/pvcreate {{ZenossControlCenterBlkDev|default ('/dev/sde')}}"
# Create LVM volume group vg_zenoss_control_center
- name: "vgcreate vg_zenoss_control_center {{ZenossControlCenterBlkDev|default ('/dev/sde')}}"
command: "/usr/sbin/vgcreate vg_zenoss_control_center {{ZenossControlCenterBlkDev|default ('/dev/sde')}}"
# Create LVM physical volume on {{ZenossBackupsBlkDev|default ('/dev/sdf')}}
- name: "pvcreate {{ZenossBackupsBlkDev|default ('/dev/sdf')}}"
command: "/usr/sbin/pvcreate {{ZenossBackupsBlkDev|default ('/dev/sdf')}}"
# Create LVM volume group vg_zenoss_backups
- name: "vgcreate vg_zenoss_backups {{ZenossBackupsBlkDev|default ('/dev/sdf')}}"
command: "/usr/sbin/vgcreate vg_zenoss_backups {{ZenossBackupsBlkDev|default ('/dev/sdf')}}"
# file - Sets attributes of files and directories
# http://docs.ansible.com/ansible/file_module.html
##################################################
- name: Create directory /opt/serviced/var/backups if it does not already exist
file:
path: /opt/serviced/var/backups
owner: root
group: root
mode: 0755
state: directory
- name: Create directory /opt/serviced/var/isvcs if it does not already exist
file:
path: /opt/serviced/var/isvcs
owner: root
group: root
mode: 0755
state: directory
- name: Create directory /opt/serviced/var/volumes if it does not already exist
file:
path: /opt/serviced/var/volumes
owner: root
group: root
mode: 0755
state: directory
# lvol - Configure LVM logical volumes
# REF: http://docs.ansible.com/ansible/lvol_module.html
#######################################################
- name: Create a 150GB logical volume lv_ZENOSS_BACKUPS on vg_zenoss_backups
lvol:
vg: vg_zenoss_backups
lv: lv_ZENOSS_BACKUPS
size: 150g
- name: Create a 50GB logical volume lv_ZENOSS_ISVCS on vg_zenoss_control_center
lvol:
vg: vg_zenoss_control_center
lv: lv_ZENOSS_ISVCS
size: 50g
# command - Executes a command on a remote node
# REF: http://docs.ansible.com/ansible/command_module.html
##########################################################
- name: mkfs -t xfs /dev/vg_zenoss_backups/lv_ZENOSS_BACKUPS
command: "/sbin/mkfs -t xfs /dev/vg_zenoss_backups/lv_ZENOSS_BACKUPS"
- name: mkfs -t xfs /dev/vg_zenoss_control_center/lv_ZENOSS_ISVCS
command: "/sbin/mkfs -t xfs /dev/vg_zenoss_control_center/lv_ZENOSS_ISVCS"
# mount - Control active and configured mount points
# REF: http://docs.ansible.com/ansible/mount_module.html
########################################################
- name: Mount path /opt/serviced/var/backups to LVM /dev/vg_zenoss_backups/lv_ZENOSS_BACKUPS as XFS
mount:
path: /opt/serviced/var/backups
src: /dev/vg_zenoss_backups/lv_ZENOSS_BACKUPS
fstype: xfs
opts: defaults
state: mounted
- name: Mount path /opt/serviced/var/isvcs to LVM /dev/vg_zenoss_control_center/lv_ZENOSS_ISVCS as XFS
mount:
path: /opt/serviced/var/isvcs
src: /dev/vg_zenoss_control_center/lv_ZENOSS_ISVCS
fstype: xfs
opts: defaults
state: mounted
# Tweak settings in INI files
# REF: http://docs.ansible.com/ansible/ini_file_module.html
###########################################################
# REF: http://docs.rancher.com/rancher/v1.5/en/hosts/#supported-docker-versions
- name: Set value in /etc/yum.conf to exclude auto upgrades of docker-engine so we stay on a version compatible with Zenoss
ini_file:
dest: /etc/yum.conf
section: main
option: exclude
value: 'docker-engine'
# Restart firewalld to make sure it is running OK before changing any rules
# REF: http://docs.ansible.com/ansible/service_module.html
##########################################################
- name: Ensure the firewalld service is enabled and re-started before changing any rules
service:
name: firewalld
enabled: yes
state: restarted
# Update the firewalld configuration
# REF: http://docs.ansible.com/ansible/firewalld_module.html
############################################################
- name: Update firewall to allow port TCP 22 for incoming Zenoss sshd connections
firewalld:
port: 22/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 80 for incoming Zenoss Control Center connections
firewalld:
port: 80/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 443 for incoming Zenoss HTTPS connections
firewalld:
port: 443/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 2048 for incoming Zenoss Optional connections
firewalld:
port: 2048/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 2049 for incoming Zenoss NFS connections
firewalld:
port: 2049/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 2181 for incoming Zenoss Zookeeper connections
firewalld:
port: 2181/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 2375 for incoming Docker Cloud connections
firewalld:
port: 2375/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 2376 for incoming docker-machine connections
firewalld:
port: 2376/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 2377 for incoming Docker cluster management connections
firewalld:
port: 2377/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 2888 for incoming Zenoss Zookeeper connections
firewalld:
port: 2888/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 3888 for incoming Zenoss Zookeeper connections
firewalld:
port: 3888/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 4789 for incoming Docker overlay network connections
firewalld:
port: 4789/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port UDP 4789 for incoming Docker overlay network connections
firewalld:
port: 4789/udp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 4979 for incoming Zenoss serviced RPC connections
firewalld:
port: 4979/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 5000 for incoming Zenoss Docker registry connections
firewalld:
port: 5000/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 5042 for incoming Zenoss logstash connections
firewalld:
port: 5042/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 5043 for incoming Zenoss logstash connections
firewalld:
port: 5043/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 6783 for incoming Docker overlay network connections
firewalld:
port: 6783/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port UDP 6783 for incoming Docker overlay network connections
firewalld:
port: 6783/udp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 7946 for incoming Docker communication among nodes
firewalld:
port: 7946/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port UDP 7946 for incoming Docker communication among nodes
firewalld:
port: 7946/udp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 8443 for incoming Zenoss metric consumer connections
firewalld:
port: 8443/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow port TCP 22250 for incoming Zenoss mux connections
firewalld:
port: 22250/tcp
permanent: true
immediate: yes
state: enabled
zone: public
- name: Update firewall to allow ports TCP 30000-32767 for incoming Docker swarm manager PublishedPort connections
firewalld:
port: 30000-32767/tcp
permanent: true
immediate: yes
state: enabled
zone: public
# copy - Copies files to remote locations
# http://docs.ansible.com/ansible/copy_module.html
##################################################
- name: Copy /etc/default/serviced to /etc/default/serviced.ORIGINAL
copy:
remote_src: True
src: /etc/default/serviced
dest: /etc/default/serviced.ORIGINAL
owner: root
group: serviced
mode: 0440
- name: Copy /etc/dnsmasq.conf to /etc/dnsmasq.conf.ORIGINAL
copy:
remote_src: True
src: /etc/dnsmasq.conf
dest: /etc/dnsmasq.conf.ORIGINAL
owner: root
group: root
mode: 0644
# file - Sets attributes of files and directories
# http://docs.ansible.com/ansible/file_module.html
##################################################
- name: Delete file /etc/default/serviced
file:
path: /etc/default/serviced
state: absent
- name: Delete file /etc/dnsmasq.conf
file:
path: /etc/dnsmasq.conf
state: absent
# Use the copy module to copy various files into place
# REF: http://docs.ansible.com/ansible/copy_module.html
#######################################################
# /etc/dnsmasq.conf
- name: Copy dnsmasq configuration file dnsmasq.conf from Ansible files/dnsmasq/etc_dnsmasq.conf.ZENOSS to Zenoss remote /etc/dnsmasq.conf
copy:
src=files/dnsmasq/etc_dnsmasq.conf.ZENOSS
dest=/etc/dnsmasq.conf
owner=root
group=root
mode=0444
# command - Executes a command on a remote node
# REF: http://docs.ansible.com/ansible/command_module.html
##########################################################
- name: systemctl daemon-reload
command: "systemctl daemon-reload"
# Enable and start dsnmasq and docker
# REF: http://docs.ansible.com/ansible/service_module.html
##########################################################
- name: Enable and start the dnsmasq service
service:
name: dnsmasq
enabled: yes
state: restarted
# systemctl status dnsmasq
# cat /etc/dnsmasq.conf
- name: Enable and start (or restart) the docker service
service:
name: docker
enabled: yes
state: restarted
# Note: Verify docker via SSH command line:
# systemctl status docker
# docker run hello-world
#
# More advanced verification:
# docker run -it ubuntu bash
# cat /etc/lsb-release
#
# To run docker as a normal user, add that user to the docker group:
# usermod -aG docker your_username
# Update various configuration files
# REF: http://docs.ansible.com/ansible/lineinfile_module.html
#############################################################
- name: Populate values in /etc/default/serviced with - SERVICED_ALLOW_LOOP_BACK=true
lineinfile:
dest: /etc/default/serviced
state: present
create: yes
backup: yes
owner: root
group: serviced
mode: 0640
line: 'SERVICED_ALLOW_LOOP_BACK=true'
- name: Populate values in /etc/default/serviced with - SERVICED_FS_TYPE=devicemapper
lineinfile:
dest: /etc/default/serviced
state: present
create: yes
backup: yes
owner: root
group: serviced
mode: 0640
line: 'SERVICED_FS_TYPE=devicemapper'
- name: Populate values in /etc/default/serviced with - SERVICED_DM_THINPOOLDEV=/dev/mapper/serviced-serviced--pool
lineinfile:
dest: /etc/default/serviced
state: present
create: yes
backup: yes
owner: root
group: serviced
mode: 0640
line: 'SERVICED_DM_THINPOOLDEV=/dev/mapper/serviced-serviced--pool'
- name: Populate values in /etc/default/serviced with - SERVICED_DM_BASESIZE=88G
lineinfile:
dest: /etc/default/serviced
state: present
create: yes
backup: yes
owner: root
group: serviced
mode: 0640
line: 'SERVICED_DM_BASESIZE=88G'
- name: Populate values in /etc/default/serviced with - SERVICED_MASTER=1
lineinfile:
dest: /etc/default/serviced
state: present
create: yes
backup: yes
owner: root
group: serviced
mode: 0640
line: 'SERVICED_MASTER=1'
# command - Executes a command on a remote node
# REF: http://docs.ansible.com/ansible/command_module.html
##########################################################
- name: systemctl daemon-reload
command: "systemctl daemon-reload"
# Enable and start Zenoss
# REF: http://docs.ansible.com/ansible/service_module.html
##########################################################
- name: Enable and start the Zenoss serviced service
service:
name: serviced
enabled: yes
state: restarted
# systemctl status serviced
# cat /etc/default/serviced
# htop
# df -h
# pvs; vgs; lvs
# pvdisplay; vgdisplay; lvdisplay
# lsblk
# mount
# docker ps
# serviced host add --register IPAddressHere:4979 default
# http://IPAddressHere