blob: a9eb81af670a6ae66ebc39a5cdd68f2722df4f66 (
plain)
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
|
##############################################################################
# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
---
- name: gen ceph uuid
shell: uuidgen
register: ceph_uuid_out
run_once: true
tags:
- ceph_copy_secret
- name: set ceph uuid var
set_fact:
ceph_uuid: "{{ ceph_uuid_out.stdout_lines[0] }}"
when: not compute_expansion
tags:
- ceph_copy_secret
- name: save ceph uuid for expansion
copy: content="{{ ceph_uuid }}" dest=/etc/ceph/ceph.uuid.libvirt
when: not compute_expansion and inventory_hostname in groups['controller']
tags:
- ceph_copy_secret
- name: fetch ceph uuid from controller node for expansion
shell: cat /etc/ceph/ceph.uuid.libvirt
register: ceph_uuid_out
delegate_to: "{{ public_vip.ip }}"
when: compute_expansion and inventory_hostname in groups['compute']
tags:
- ceph_copy_secret
- name: set ceph uuid var for expansion
set_fact:
ceph_uuid: "{{ ceph_uuid_out.stdout_lines[0] }}"
when: compute_expansion and inventory_hostname in groups['compute']
tags:
- ceph_copy_secret
- name: gen template secret.xml
local_action:
module: "template"
src: "secret.j2"
dest: "/tmp/secret.xml"
mode: "0777"
when: inventory_hostname in groups['ceph_adm']
tags:
- ceph_copy_secret
- name: create pool
shell: ceph osd pool create {{ item }} 50
with_items:
- volumes
- images
- backups
- vms
when: inventory_hostname in groups['ceph_adm']
# yamllint disable rule:line-length
- name: create ceph users for openstack
shell: |
ceph auth get-or-create client.cinder mon 'allow r' osd \
'allow class-read object_prefix rbd_children, allow rwx pool=volumes, allow rwx pool=vms, allow rx pool=images';
ceph auth get-or-create client.glance mon 'allow r' osd \
'allow class-read object_prefix rbd_children, allow rwx pool=images';
when: inventory_hostname in groups['ceph_adm']
# yamllint enable rule:line-length
- name: send glance key to controller nodes
shell: |
ceph auth get-or-create client.glance | \
tee /etc/ceph/ceph.client.glance.keyring;
chown glance:glance /etc/ceph/ceph.client.glance.keyring;
when: inventory_hostname in groups['controller']
- name: send cinder key to compute nodes
shell: |
ceph auth get-or-create client.cinder | \
tee /etc/ceph/ceph.client.cinder.keyring;
chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring;
when: inventory_hostname in groups['compute']
tags:
- ceph_send_key
- name: copy cinder key to compute node
shell: ceph auth get-key client.cinder | tee client.cinder.key
when: inventory_hostname in groups['compute']
tags:
- ceph_copy_secret
- name: copy secret.xml to compute nodes
copy: src="/tmp/secret.xml" dest="~/secret.xml"
when: inventory_hostname in groups['compute']
tags:
- ceph_copy_secret
- name: undefine libvirt secret in case of repeatedly execute ceph_deploy
shell: |
virsh secret-list | awk '$1 ~ /[0-9]+/ {print $1}' | \
xargs virsh secret-undefine
when: inventory_hostname in groups['compute']
tags:
- ceph_copy_secret
ignore_errors: "True"
- name: create key for libvirt on compute nodes
shell: |
virsh secret-define --file ~/secret.xml;
virsh secret-set-value --secret {{ ceph_uuid }} \
--base64 $(cat client.cinder.key);
when: inventory_hostname in groups['compute']
tags:
- ceph_copy_secret
ignore_errors: "True"
|