-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos_lab.yml
1606 lines (1435 loc) · 46.1 KB
/
os_lab.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
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
## OpenStack on OpenStack lab setup
## Author: Cees Moerkerken
##
## Will create a virtual openstack setup on top of openstack
## Only intended for testing purposes!!!
##
## Run as
## TF_STATE=./tf_openstack/terraform.tfstate ansible-playbook os_lab.yml"
## When using a vault add: "--ask-vault-pass"
##
## ASCII genereted with pyfiglet -f basic "name"
---
## install python via raw module
- hosts: type_openstack_compute_instance_v2
gather_facts: False
tasks:
- name: install python 2
raw: |
test -e /usr/bin/python || \
(sudo apt -y update && sudo apt install -y python-minimal)
tags: firstrun
#######################################################################
# .o88b. .d88b. .88b d88. .88b d88. .d88b. d8b db
# d8P Y8 .8P Y8. 88'YbdP`88 88'YbdP`88 .8P Y8. 888o 88
# 8P 88 88 88 88 88 88 88 88 88 88 88V8o 88
# 8b 88 88 88 88 88 88 88 88 88 88 88 V8o88
# Y8b d8 `8b d8' 88 88 88 88 88 88 `8b d8' 88 V888
# `Y88P' `Y88P' YP YP YP YP YP YP `Y88P' VP V8P
#
## common stuff
#######################################################################
- hosts: all
gather_facts: True
tasks:
- name: "Ansible setup"
setup:
tags: always
- hosts: type_openstack_compute_instance_v2
tasks:
- name: "Build hosts file"
lineinfile:
dest=/etc/hosts
regexp='{{ hostvars[item].access_ip_v4 }}.*'
line="{{ hostvars[item].access_ip_v4 }} {{ hostvars[item].ansible_hostname }}"
state=present
with_items:
- "{{ groups['type_openstack_compute_instance_v2'] }}"
tags:
- firstrun
- hostsfile
- name: "fix slow ssh on ubuntu"
lineinfile:
dest=/etc/pam.d/common-session
regexp='.*session.*optional.*pam_systemd.so'
line='#session optional pam_systemd.so'
insertbefore='# end of pam-auth-update config'
firstmatch=yes
state=present
tags:
- firstrun
- pam-fix
notify: restart-sshd
- name: apt repositories and packages
block:
- name: add apt keys
apt_key:
id: "{{openstack_apt_key}}"
keyserver: keyserver.ubuntu.com
state: present
- name: add-apt-repository for OpenStack
apt_repository:
repo: "{{openstack_repo}}"
tags: add-apt-repository
- name: add ceph apt keys
apt_key:
url: https://download.ceph.com/keys/release.asc
state: present
tags:
- add-apt-repository
- ceph
- name: add-apt-repository ceph
apt_repository:
repo: "{{ceph_repo}}"
filename: ceph.list
tags:
- add-apt-repository
- ceph
# - name: enable auto-updates and reboot since this is for testing
# copy:
# src: 50unattended-upgrades
# dest: /etc/apt/apt.conf.d/50unattended-upgrades
# tags: auto-updates
- name: dist-upgrade
apt:
upgrade: dist
update_cache: yes
dpkg_options: 'force-confold,force-confdef'
autoremove: yes
tags: firstrun
##retry so we can use forking
register: apt_result
retries: 10
until: apt_result is success
- name: ensure common packages are installed
apt:
pkg:
- chrony
- software-properties-common
- python-openstackclient
state: present
update_cache: yes
autoremove: yes
register: apt_result
retries: 10
until: apt_result is success
- name: ensure group_vars specific packages are installed
apt: pkg={{packages}} state=present update_cache=yes
register: apt_result
retries: 10
until: apt_result is success
tags: packages
- name: configure chrony
lineinfile:
path=/etc/chrony/chrony.conf
regexp='^allow'
line='allow 10.0.0.0/24'
notify: restart-chrony
- name: configure vim (syntax highligt .conf files as ini)
lineinfile:
path=/etc/vim/vimrc
line='autocmd BufRead,BufNewFile *.conf setf dosini'
- name: set timezone
timezone:
name: Europe/Bratislava
- name: template rc files on all nodes (might come in handy)
template:
src=files/{{item}}.j2
dest=/root/{{item}}
backup=yes
with_items:
- adminrc
- userrc
- demorc
tags: rc
- name: template rc files on all nodes (might come in handy)
template:
src=files/{{item}}.j2
dest=/home/ubuntu/{{item}}
backup=yes
with_items:
- adminrc
- userrc
- demorc
tags: rc
- name: add adminrc to bashrc on all nodes
lineinfile:
path={{item}}
line='. ~/adminrc'
with_items:
- /home/ubuntu/.bashrc
tags: rc
- name: configure sysctl
sysctl:
name: "{{item.key}}"
value: "{{item.value}}"
with_dict:
- net.bridge.bridge-nf-call-iptables: 1
- net.bridge.bridge-nf-call-ip6tables: 1
- vm.overcommit_memory: 1
- net.core.somaxconn: 1
- net.ipv6.conf.all.disable_ipv6: 1
- net.ipv6.conf.default.disable_ipv6: 1
- net.ipv6.conf.lo.disable_ipv6: 1
register: sysctl_result
tags: sysctl
##fails and retry doesnt work, so ignore errors
ignore_errors: yes
##and try again the ugly way
- name: configure sysctl
sysctl:
name: "{{item.key}}"
value: "{{item.value}}"
with_dict:
- net.bridge.bridge-nf-call-iptables: 1
- net.bridge.bridge-nf-call-ip6tables: 1
- vm.overcommit_memory: 1
- net.core.somaxconn: 1
- net.ipv6.conf.all.disable_ipv6: 1
- net.ipv6.conf.default.disable_ipv6: 1
- net.ipv6.conf.lo.disable_ipv6: 1
tags: sysctl
when: sysctl_result is not success
ignore_errors: yes
handlers:
- name: restart-chrony
service: name=chrony state=restarted
- name: restart-sshd
service: name=sshd state=restarted
#######################################################################
# .o88b. d88888b d8888b. db db
# d8P Y8 88' 88 `8D 88 88
# 8P 88ooooo 88oodD' 88ooo88
# 8b 88~~~~~ 88~~~ 88~~~88
# Y8b d8 88. 88 88 88
# `Y88P' Y88888P 88 YP YP
#
## Ceph - ssh keys for ceph-deploy (not really used)
#######################################################################
- hosts: control
tasks:
# Wont work untill 2.8
# - name: gen ssh key on control
# openssh_keypair:
# path: /root/.ssh/id_rsa
# type: rsa
# tags: ceph
# Should be replaced with previous step when 2.8 is out
- name: gen ssh key on control
shell: ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""
args:
creates: /root/.ssh/id_rsa
tags:
- ceph
- ssh-keys
- name: register privkey
slurp:
src: /root/.ssh/id_rsa
register: privkey
tags:
- ceph
- ssh-keys
- name: register pubkey
slurp:
src: /root/.ssh/id_rsa.pub
register: pubkey
tags:
- ceph
- ssh-keys
#######################################################################
## Ceph
#######################################################################
- hosts: type_openstack_compute_instance_v2
tasks:
- name: distribute ssh keys
block:
- name: Set authorized key taken from file for ceph-deploy
authorized_key:
user: root
state: present
key: "{{ hostvars[item]['pubkey']['content']|b64decode }}"
with_items: '{{control_node_ip}}'
- name: Set authorized key taken from file for ceph-deploy
authorized_key:
user: ubuntu
state: present
key: "{{ hostvars[item]['pubkey']['content']|b64decode }}"
with_items: '{{control_node_ip}}'
tags:
- ceph
- ssh-keys
# http://docs.ceph.com/docs/mimic/install/manual-deployment/
- name: create ceph config on all nodes
block:
- name: 2. Ensure you have a directory for the Ceph configuration file.
file:
path: /etc/ceph
state: directory
owner: root
group: root
mode: 0755
- name: 3-7. Create a Ceph configuration file.
template:
src=files/ceph/ceph.conf.j2
dest=/etc/ceph/ceph.conf
mode=0644
owner=root
group=root
tags:
- ceph
- ceph-config
- hosts: ceph-mon.0
tasks:
- name: create keyring with users on first mon
block:
- name: 8. Create a keyring for your cluster and secret key.
shell: |
ceph-authtool \
--create-keyring /etc/ceph/tmp_ceph.mon.keyring \
--gen-key -n mon. \
--cap mon 'allow *'
args:
creates: /etc/ceph/tmp_ceph.mon.keyring
register: tmpcephmonkeyring
- name: 9. Gen an administrator keyring and client.admin user.
shell: |
ceph-authtool \
--create-keyring /etc/ceph/ceph.client.admin.keyring \
--gen-key -n client.admin \
--set-uid=0 \
--cap mon 'allow *' \
--cap osd 'allow *' \
--cap mds 'allow *' \
--cap mgr 'allow *'
args:
creates: /etc/ceph/ceph.client.admin.keyring
register: cephadminkeyring
- name: 10. Gen a bootstrap-osd keyring and client.bootstrap-osd user.
shell: |
ceph-authtool \
--create-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring \
--gen-key -n client.bootstrap-osd \
--cap mon 'profile bootstrap-osd'
args:
creates: /var/lib/ceph/bootstrap-osd/ceph.keyring
register: cephbootstrapkeyring
- name: 11. Add the generated keys to tmp_ceph.mon.keyring.
shell: |
ceph-authtool /etc/ceph/tmp_ceph.mon.keyring \
--import-keyring /etc/ceph/ceph.client.admin.keyring
when: cephadminkeyring.changed or tmpcephmonkeyring.changed
- name: 11. Add the generated keys to tmp_ceph.mon.keyring.
shell: |
ceph-authtool /etc/ceph/tmp_ceph.mon.keyring \
--import-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring
when: cephbootstrapkeyring.changed or tmpcephmonkeyring.changed
- name: 12. Gen a monitor map. Save it as /etc/ceph/tmp_monmap
shell: |
monmaptool --create \
--add {{ ansible_hostname }} {{ access_ip_v4 }} \
--fsid {{ ceph_fsid }} /etc/ceph/tmp_monmap
args:
creates: /etc/ceph/tmp_monmap
register: monmap
- name: 12. Add other hosts to monmap
shell: |
monmaptool \
--add {{ hostvars[item].ansible_hostname }} {{ hostvars[item].access_ip_v4 }} \
--fsid {{ ceph_fsid }} /etc/ceph/tmp_monmap
loop: "{{ query('inventory_hostnames', 'ceph-mon') }}"
ignore_errors: true
- name: 13. Create a default data directory on the monitor host(s).
file:
path: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}
state: directory
owner: ceph
group: ceph
mode: 0755
- name: 14. Populate the mons with the monmap and keyring.
shell: |
sudo -u ceph ceph-mon --cluster ceph \
--mkfs -i {{ ansible_hostname }} \
--monmap /etc/ceph/tmp_monmap \
--keyring /etc/ceph/tmp_ceph.mon.keyring
args:
creates: /var/lib/ceph/mon/{{ ansible_hostname }}/store.db
when: cephbootstrapkeyring.changed or tmpcephmonkeyring.changed or cephadminkeyring.changed
- name: 16. Touch the done file.
copy:
content: ""
dest: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/done
force: no
owner: ceph
group: ceph
mode: 0644
- name: start ceph-mon
service:
name=ceph-mon@{{ ansible_hostname }}
state=started
- name: copy keyring tmp files locally
fetch:
src: /etc/ceph/{{ item }}
dest: .tmp/
with_items:
- tmp_ceph.mon.keyring
- tmp_monmap
tags:
- ceph
- keyring
- hosts: ceph-mon:!ceph-mon.0
tasks:
- name: finish mon install on other nodes
block:
- name: copy keyring tmp files
copy:
src: .tmp/{{ groups['ceph-mon'][0] }}/etc/ceph/{{ item }}
dest: /etc/ceph/
with_items:
- tmp_ceph.mon.keyring
- tmp_monmap
register: keyringcopy
- name: 13. Create a default data directory on the monitor host(s).
file:
path: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}
state: directory
owner: ceph
group: ceph
mode: 0755
- name: 14. Populate the mons with the monmap and keyring.
become: yes
become_user: ceph
shell: |
ceph-mon --cluster ceph \
--mkfs -i {{ ansible_hostname }} \
--monmap /etc/ceph/tmp_monmap \
--keyring /etc/ceph/tmp_ceph.mon.keyring
args:
creates: /var/lib/ceph/mon/{{ ansible_hostname }}/store.db
- name: 16. Touch the done file.
copy:
content: ""
dest: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/done
force: no
owner: ceph
group: ceph
mode: 0644
- name: start ceph-mon
service:
name=ceph-mon@{{ ansible_hostname }}
state=started
tags:
- ceph
- keyring
- name: create manager
block:
- name: Create an authentication key for your mgr daemon
shell: |
ceph auth get-or-create mgr.{{ ansible_hostname }} mon \
'allow profile mgr' osd 'allow *' mds 'allow *' \
-o /var/lib/ceph/mgr/ceph-{{ ansible_hostname }}
args:
creates: /var/lib/ceph/mgr/ceph-{{ ansible_hostname }}
register: mgrauthkey
- name: start ceph-mgr
shell: |
ceph-mgr -i {{ ansible_hostname }}
when: mgrauthkey.changed
tags:
- ceph
- ceph-mgr
## create the ceph-deploy script
- hosts: control
tasks:
- name: template ceph-deploy.sh
template:
src=files/ceph/ceph-deploy.sh.j2
dest=/root/ceph-deploy.sh
mode=0740
owner=root
group=root
tags: ceph-deploy
register: cephdeploysh
- name: zap OSDs and create pools
shell: /root/ceph-deploy.sh | tee /root/ceph-deploy.log
tags: ceph
when: cephdeploysh.changed
#######################################################################
# .o88b. .d88b. d8b db d888888b d8888b. .d88b. db
# d8P Y8 .8P Y8. 888o 88 `~~88~~' 88 `8D .8P Y8. 88
# 8P 88 88 88V8o 88 88 88oobY' 88 88 88
# 8b 88 88 88 V8o88 88 88`8b 88 88 88
# Y8b d8 `8b d8' 88 V888 88 88 `88. `8b d8' 88booo.
# `Y88P' `Y88P' VP V8P YP 88 YD `Y88P' Y88888P
#
#
# d8b db .d88b. d8888b. d88888b .d8888.
# 888o 88 .8P Y8. 88 `8D 88' 88' YP
# 88V8o 88 88 88 88 88 88ooooo `8bo.
# 88 V8o88 88 88 88 88 88~~~~~ `Y8b.
# 88 V888 `8b d8' 88 .8D 88. db 8D
# VP V8P `Y88P' Y8888D' Y88888P `8888Y'
#
## Control node with Core components:
# Nova, Glance, Horizon, Keystone, Neutron, Cinder, Ceilometer
# Gnocchi
#
## Core components TODO:
# Swift, Heat, Trove, Sahara, Ironic, Zaqar, Manila, Designate,
# Barbican, Searchlight, Magnum, aodh, cloudkitty, congress, freezer,
# mistral, monasca-api, monasca-log-api, murano, panko, senlin, solum,
# tacker, vitrage, Watcher, blazar, ceilometer-powervm, karbor,
# octavia, storlets, tricircle, zun, Cyborg, ec2-api, Masakari, Qinling
#######################################################################
- hosts: control
tasks:
## Set facts by stripping "metadata." and joining with _
- name: Set fact from terraform metadata
set_fact:
"{{item.key.split('.')[1:10] | join('_') }}": "{{ item.value }}"
with_dict: "{{ hostvars[inventory_hostname] }}"
when:
- '"metadata" in item.key'
- '"%" not in item.key'
tags: always
## Configure haproxy
- name: template haproxy.cfg
template:
src=files/haproxy.cfg.j2
dest=/etc/haproxy/haproxy.cfg
mode=0640
owner=root
group=root
backup=yes
validate='haproxy -c -f %s'
notify: reload-haproxy
tags: haproxy
register: haproxyconfig
- name: restart haproxy before next steps
service:
name=haproxy
state=restarted
when: haproxyconfig.changed
## MySQL
- name: template 99-openstack.cnf
template:
src=files/99-openstack.cnf.j2
dest=/etc/mysql/mariadb.conf.d/99-openstack.cnf
backup=yes
tags: database
register: mysqlconfig
- name: reload mysql before next steps
service:
name=mysql
state=restarted
when: mysqlconfig.changed
- name: create databases
mysql_db:
config_file=/etc/mysql/debian.cnf
name={{ item }}
encoding=utf8
collation=utf8_general_ci
with_items: "{{mysql_databases}}"
tags: database
# grant every user all privileges since ansible cant provide multiple
# grants thats needed for nova_cell0 etc.
- name: create users
mysql_user:
config_file=/etc/mysql/debian.cnf
name={{item}}
host='%'
password="{{ DATABASE_PASS }}"
priv='*.*:ALL'
# priv='{{item}}.*:ALL'
with_items: "{{mysql_databases}}"
tags: database
## RabbitMQ
- rabbitmq_user:
user: guest
state: absent
tags: rabbitmq
- name: Enables the rabbitmq_management plugin
rabbitmq_plugin:
names: rabbitmq_management
state: enabled
tags: rabbitmq
- name: add openstack user to rabbitmq
rabbitmq_user:
user: openstack
password: "{{RABBIT_PASS}}"
vhost: /
configure_priv: .*
read_priv: .*
write_priv: .*
state: present
tags: rabbitmq
- name: add admin user to rabbitmq
rabbitmq_user:
user: admin
password: "{{RABBIT_PASS}}"
vhost: /
configure_priv: .*
read_priv: .*
write_priv: .*
tags: administrator
state: present
tags: rabbitmq
## Redis
- name: template redis.conf
template:
src=files/redis.conf.j2
dest=/etc/redis/redis.conf
backup=yes
notify: restart-redis
tags: redis
- name: chmod /var/lib/redis/ directory
file:
path: /var/lib/redis/
state: directory
owner: redis
group: redis
mode: 0775
notify: restart-redis
tags: redis
# - name: chmod /var/lib/redis/dump.rdb
# file:
# path: /var/lib/redis/dump.rdb
# state: file
# owner: redis
# group: redis
# mode: 0644
# notify: restart-redis
# tags: redis
## Memcached
- name: template memcached.conf
template:
src=files/memcached.conf.j2
dest=/etc/memcached.conf
backup=yes
notify: restart-memcached
## ETCD
- name: create etcd config folder
file:
path=/etc/etcd
state=directory
owner=etcd
group=etcd
- name: template etcd.conf.yml
template:
src=files/etcd.conf.yml.j2
dest=/etc/etcd/etcd.conf.yml
backup=yes
notify: restart-etcd
## PHPMyAdmin
- name: enable phpmyadmin
file:
src=/etc/phpmyadmin/apache.conf
dest=/etc/apache2/sites-enabled/phpmyadmin.conf
state=link
notify:
- restart-apache2
tags: phpmyadmin
#######################################################################
# db dD d88888b db db .d8888. d888888b .d88b. d8b db d88888b
# 88 ,8P' 88' `8b d8' 88' YP `~~88~~' .8P Y8. 888o 88 88'
# 88,8P 88ooooo `8bd8' `8bo. 88 88 88 88V8o 88 88ooooo
# 88`8b 88~~~~~ 88 `Y8b. 88 88 88 88 V8o88 88~~~~~
# 88 `88. 88. 88 db 8D 88 `8b d8' 88 V888 88.
# YP YD Y88888P YP `8888Y' YP `Y88P' VP V8P Y88888P
#
## Keystone controller
- name: install keystone
apt: pkg=keystone state=present update_cache=yes
register: keystone
tags: keystone
- name: template keystone.conf.yml
template:
src=files/keystone.conf.j2
dest=/etc/keystone/keystone.conf
backup=yes
tags: keystone
- name: chown /var/log/keystone directory
file:
path: /var/log/keystone
state: directory
owner: keystone
group: syslog
mode: 0775
- name: retreive keystone table count
shell: |
mysql -e "SELECT COUNT(*) FROM information_schema.tables \
WHERE table_schema = 'keystone';" -B -N
register: keystonetablecount
tags:
- keystone
- firstrun
- name: Populate the Identity service database
shell: su -s /bin/sh -c "keystone-manage db_sync" keystone
when: keystonetablecount.stdout|int < 10
tags:
- keystone
- firstrun
- name: Initialize Fernet key repositories
shell: |
keystone-manage fernet_setup --keystone-user keystone \
--keystone-group keystone
keystone-manage credential_setup --keystone-user keystone \
--keystone-group keystone
register: fernet
when: keystonetablecount.stdout|int < 10
tags:
- keystone
- firstrun
- name: Bootstrap the Identity service
shell: |
keystone-manage bootstrap --bootstrap-password {{ ADMIN_PASS }} \
--bootstrap-admin-url http://{{ control_node_name }}:5000/v3/ \
--bootstrap-internal-url http://{{ control_node_name }}:5000/v3/ \
--bootstrap-public-url http://{{ control_node_ip_remote }}:5000/v3/ \
--bootstrap-region-id RegionOne
become: yes
become_user: root
register: command_result
failed_when: "'FAILED' in command_result.stderr"
when: keystonetablecount.stdout|int < 10
with_items:
- "{{ groups['control'] }}"
tags:
- keystone
- firstrun
- name: configure keystone domains, roles and users
block:
- name: add domains
os_keystone_domain:
cloud: "{{ooo}}"
state: present
name: "{{item.key}}"
description: "{{item.value}}"
with_dict: "{{keystone_domains}}"
- name: add projects
os_project:
cloud: "{{ooo}}"
name: "{{item.key}}"
description: "{{item.value}}"
domain_id: "{{item.value.domain|default('default')}}"
with_dict: "{{keystone_projects}}"
- name: add roles to keystone
os_keystone_role:
cloud: "{{ooo}}"
name: "{{item}}"
with_items: "{{keystone_roles}}"
- name: add users to keystone
os_user:
cloud: "{{ooo}}"
name: "{{item.key}}"
password: "{{item.value.pass}}"
update_password: on_create
domain: "{{item.value.domain|default('default')}}"
with_dict: "{{keystone_users}}"
- name: assign roles to users in keystone
os_user_role:
cloud: "{{ooo}}"
user: "{{item.key}}"
role: "{{item.value.role}}"
project: "{{item.value.project}}"
with_dict: "{{keystone_users}}"
- name: add domain users to keystone
os_user:
cloud: "{{ooo}}"
name: "{{item.key}}"
password: "{{item.value.pass}}"
update_password: on_create
domain: "{{item.value.domain|default('default')}}"
with_dict: "{{keystone_domain_users}}"
- name: assign roles to domain users in keystone
os_user_role:
cloud: "{{ooo}}"
user: "{{item.key}}"
role: "{{item.value.role}}"
domain: "{{item.value.domain}}"
with_dict: "{{keystone_domain_users}}"
##fails when magnum domain id is not set so ignore errors
ignore_errors: yes
tags:
- keystone
- keystone_users
- name: prep services and endpoints
block:
- name: create services in keystone
os_keystone_service:
cloud: "{{ooo}}"
name: "{{item.key}}"
service_type: "{{item.value.type}}"
description: "{{item.value.description}}"
with_dict: "{{keystone_services}}"
- name: create endpoints in keystone
os_keystone_endpoint:
cloud: "{{ooo}}"
service: "{{item.service}}"
endpoint_interface: "{{item.interface}}"
url: "{{item.url}}"
region: "{{item.region}}"
with_items: "{{keystone_endpoints}}"
tags:
- keystone
- keystone_services
- name: configure Keystone
template:
src=files/apache2/sites-available/keystone.conf.j2
dest=/etc/apache2/sites-available/keystone.conf
backup=yes
notify:
- restart-apache2
#######################################################################
# db db d88888b .d8b. d888888b
# 88 88 88' d8' `8b `~~88~~'
# 88ooo88 88ooooo 88ooo88 88
# 88~~~88 88~~~~~ 88~~~88 88
# 88 88 88. 88 88 88
# YP YP Y88888P YP YP YP
#
## HEAT
- name: install heat
block:
- name: configure heat
template:
src=files/heat/{{item}}.j2
dest=/etc/heat/{{item}}
backup=yes
with_items:
- heat.conf
notify:
- restart-heat-api
- restart-heat-api-cfn
- restart-heat-engine
- name: count heat tables
shell: |
mysql -e "SELECT COUNT(*) FROM information_schema.tables \
WHERE table_schema = 'heat';" -B -N
register: heattablecount
- name: Populate heat database
shell: su -s /bin/sh -c "heat-manage db_sync" heat
when: heattablecount.stdout|int < 10
notify:
- restart-heat-api
- restart-heat-api-cfn
- restart-heat-engine
tags:
- heat
#######################################################################
# .88b d88. .d8b. d888b d8b db db db .88b d88.
# 88'YbdP`88 d8' `8b 88' Y8b 888o 88 88 88 88'YbdP`88
# 88 88 88 88ooo88 88 88V8o 88 88 88 88 88 88
# 88 88 88 88~~~88 88 ooo 88 V8o88 88 88 88 88 88
# 88 88 88 88 88 88. ~8~ 88 V888 88b d88 88 88 88 6
# YP YP YP YP YP Y888P VP V8P ~Y8888P' YP YP YP
#
## MAGNUM
- name: install magnum
block:
- name: configure magnum
template:
src=files/magnum/{{item}}.j2
dest=/etc/magnum/{{item}}
backup=yes
with_items:
- magnum.conf
notify:
- restart-magnum-api
- restart-magnum-conductor
- name: count magnum tables
shell: |
mysql -e "SELECT COUNT(*) FROM information_schema.tables \
WHERE table_schema = 'magnum';" -B -N
register: magnumtablecount
- name: Populate magnum database
shell: su -s /bin/sh -c "magnum-db-manage upgrade" magnum
when: magnumtablecount.stdout|int < 5
notify:
- restart-magnum-api
- restart-magnum-conductor
tags:
- magnum
#######################################################################
# d888b db .d8b. d8b db .o88b. d88888b
# 88' Y8b 88 d8' `8b 888o 88 d8P Y8 88'
# 88 88 88ooo88 88V8o 88 8P 88ooooo
# 88 ooo 88 88~~~88 88 V8o88 8b 88~~~~~
# 88. ~8~ 88booo. 88 88 88 V888 Y8b d8 88.
# Y888P Y88888P YP YP VP V8P `Y88P' Y88888P
#
## Glance
- name: install glance
block:
- name: configure glance
template:
src=files/{{item}}.j2
dest=/etc/glance/{{item}}
backup=yes
with_items:
- glance-api.conf
- glance-registry.conf
notify:
- restart-glance-api
- restart-glance-registry
- name: count glance tables
shell: |
mysql -e "SELECT COUNT(*) FROM information_schema.tables \
WHERE table_schema = 'glance';" -B -N
register: glancetablecount
- name: Populate glance database
shell: su -s /bin/sh -c "glance-manage db_sync" glance
when: glancetablecount.stdout|int < 10
notify:
- restart-glance-api
- restart-glance-registry
tags:
- glance
#######################################################################
# d8b db .d88b. db db .d8b.
# 888o 88 .8P Y8. 88 88 d8' `8b