|
1 | 1 | ---
|
2 |
| -- name: Ensuring config directory exists |
3 |
| - file: |
4 |
| - path: "{{ node_config_directory }}/{{ item }}" |
5 |
| - state: "directory" |
6 |
| - mode: "0770" |
7 |
| - become: true |
8 |
| - with_items: |
9 |
| - - "nova-libvirt/secrets" |
10 |
| - when: inventory_hostname in groups[nova_cell_compute_group] |
11 |
| - |
12 | 2 | - name: Check nova keyring file
|
13 | 3 | stat:
|
14 | 4 | path: "{{ node_custom_config }}/nova/{{ ceph_nova_keyring }}"
|
|
31 | 21 | - cinder_backend_ceph | bool
|
32 | 22 | - external_ceph_cephx_enabled | bool
|
33 | 23 |
|
| 24 | +- name: Extract nova key from file |
| 25 | + set_fact: |
| 26 | + nova_cephx_raw_key: |
| 27 | + "{{ lookup('template', nova_cephx_keyring_file.stat.path) | regex_search('key\\s*=.*$', multiline=True) | regex_replace('key\\s*=\\s*(.*)\\s*', '\\1') }}" |
| 28 | + changed_when: false |
| 29 | + run_once: True |
| 30 | + when: |
| 31 | + - nova_backend == "rbd" |
| 32 | + - external_ceph_cephx_enabled | bool |
| 33 | + |
| 34 | +- name: Extract cinder key from file |
| 35 | + set_fact: |
| 36 | + cinder_cephx_raw_key: |
| 37 | + "{{ lookup('file', cinder_cephx_keyring_file.stat.path) | regex_search('key\\s*=.*$', multiline=True) | regex_replace('key\\s*=\\s*(.*)\\s*', '\\1') }}" |
| 38 | + changed_when: false |
| 39 | + run_once: True |
| 40 | + when: |
| 41 | + - cinder_backend_ceph | bool |
| 42 | + - external_ceph_cephx_enabled | bool |
| 43 | + |
34 | 44 | - name: Copy over ceph nova keyring file
|
35 | 45 | template:
|
36 | 46 | src: "{{ nova_cephx_keyring_file.stat.path }}"
|
37 | 47 | dest: "{{ node_config_directory }}/{{ item }}/"
|
| 48 | + owner: "{{ config_owner_user }}" |
| 49 | + group: "{{ config_owner_group }}" |
38 | 50 | mode: "0660"
|
39 | 51 | become: true
|
40 | 52 | with_items:
|
|
50 | 62 | template:
|
51 | 63 | src: "{{ cinder_cephx_keyring_file.stat.path }}"
|
52 | 64 | dest: "{{ node_config_directory }}/{{ item }}/"
|
| 65 | + owner: "{{ config_owner_user }}" |
| 66 | + group: "{{ config_owner_group }}" |
53 | 67 | mode: "0660"
|
54 | 68 | become: true
|
55 | 69 | with_items: # NOTE: nova-libvirt does not need it
|
|
62 | 76 | - Restart {{ item }} container
|
63 | 77 |
|
64 | 78 | - name: Copy over ceph.conf
|
| 79 | + vars: |
| 80 | + service: "{{ nova_cell_services[item] }}" |
65 | 81 | template:
|
66 | 82 | src: "{{ node_custom_config }}/nova/ceph.conf"
|
67 | 83 | dest: "{{ node_config_directory }}/{{ item }}/"
|
| 84 | + owner: "{{ config_owner_user }}" |
| 85 | + group: "{{ config_owner_group }}" |
68 | 86 | mode: "0660"
|
69 | 87 | become: true
|
70 | 88 | with_items:
|
71 | 89 | - nova-compute
|
72 | 90 | - nova-libvirt
|
73 | 91 | when:
|
74 |
| - - inventory_hostname in groups[nova_cell_compute_group] |
| 92 | + - inventory_hostname in groups[service.group] |
| 93 | + - service.enabled | bool |
75 | 94 | - nova_backend == "rbd"
|
76 | 95 | notify:
|
77 | 96 | - Restart {{ item }} container
|
78 | 97 |
|
79 |
| -- name: Pushing nova secret xml for libvirt |
80 |
| - template: |
81 |
| - src: "secret.xml.j2" |
82 |
| - dest: "{{ node_config_directory }}/nova-libvirt/secrets/{{ item.uuid }}.xml" |
83 |
| - mode: "0600" |
84 |
| - become: true |
85 |
| - when: |
86 |
| - - inventory_hostname in groups[nova_cell_compute_group] |
87 |
| - - item.enabled | bool |
88 |
| - with_items: |
89 |
| - - uuid: "{{ rbd_secret_uuid }}" |
90 |
| - name: "client.nova secret" |
91 |
| - enabled: "{{ nova_backend == 'rbd' }}" |
92 |
| - - uuid: "{{ cinder_rbd_secret_uuid }}" |
93 |
| - name: "client.cinder secret" |
94 |
| - enabled: "{{ cinder_backend_ceph }}" |
95 |
| - notify: |
96 |
| - - Restart nova-libvirt container |
| 98 | +- block: |
| 99 | + - name: Ensure /etc/ceph directory exists (host libvirt) |
| 100 | + file: |
| 101 | + path: "/etc/ceph/" |
| 102 | + state: "directory" |
| 103 | + owner: "root" |
| 104 | + group: "root" |
| 105 | + mode: "0755" |
| 106 | + become: true |
97 | 107 |
|
98 |
| -- name: Extract nova key from file |
99 |
| - set_fact: |
100 |
| - nova_cephx_raw_key: |
101 |
| - "{{ lookup('template', nova_cephx_keyring_file.stat.path) | regex_search('key\\s*=.*$', multiline=True) | regex_replace('key\\s*=\\s*(.*)\\s*', '\\1') }}" |
102 |
| - changed_when: false |
103 |
| - run_once: True |
| 108 | + - name: Copy over ceph.conf (host libvirt) |
| 109 | + template: |
| 110 | + src: "{{ node_custom_config }}/nova/ceph.conf" |
| 111 | + dest: "/etc/ceph/ceph.conf" |
| 112 | + owner: "root" |
| 113 | + group: "root" |
| 114 | + mode: "0644" |
| 115 | + become: true |
104 | 116 | when:
|
| 117 | + - not enable_nova_libvirt_container | bool |
| 118 | + - inventory_hostname in groups[nova_cell_compute_group] |
105 | 119 | - nova_backend == "rbd"
|
106 |
| - - external_ceph_cephx_enabled | bool |
107 | 120 |
|
108 |
| -- name: Extract cinder key from file |
109 |
| - set_fact: |
110 |
| - cinder_cephx_raw_key: |
111 |
| - "{{ lookup('template', cinder_cephx_keyring_file.stat.path) | regex_search('key\\s*=.*$', multiline=True) | regex_replace('key\\s*=\\s*(.*)\\s*', '\\1') }}" |
112 |
| - changed_when: false |
113 |
| - run_once: True |
114 |
| - when: |
115 |
| - - cinder_backend_ceph | bool |
116 |
| - - external_ceph_cephx_enabled | bool |
| 121 | +- block: |
| 122 | + - name: Ensuring libvirt secrets directory exists |
| 123 | + vars: |
| 124 | + service: "{{ nova_cell_services['nova-libvirt'] }}" |
| 125 | + file: |
| 126 | + path: "{{ libvirt_secrets_dir }}" |
| 127 | + state: "directory" |
| 128 | + owner: "{{ config_owner_user }}" |
| 129 | + group: "{{ config_owner_group }}" |
| 130 | + mode: "0770" |
| 131 | + become: true |
| 132 | + when: |
| 133 | + - inventory_hostname in groups[service.group] |
117 | 134 |
|
118 |
| -- name: Pushing secrets key for libvirt |
119 |
| - copy: |
120 |
| - content: "{{ item.result }}" |
121 |
| - dest: "{{ node_config_directory }}/nova-libvirt/secrets/{{ item.uuid }}.base64" |
122 |
| - mode: "0600" |
123 |
| - become: true |
124 |
| - when: |
125 |
| - - inventory_hostname in groups[nova_cell_compute_group] |
126 |
| - - item.enabled | bool |
127 |
| - - external_ceph_cephx_enabled | bool |
128 |
| - with_items: |
129 |
| - # NOTE(yoctozepto): 'default' filter required due to eager evaluation of item content |
130 |
| - # which will be undefined if the applicable condition is False |
131 |
| - - uuid: "{{ rbd_secret_uuid }}" |
132 |
| - result: "{{ nova_cephx_raw_key | default }}" |
133 |
| - enabled: "{{ nova_backend == 'rbd' }}" |
134 |
| - - uuid: "{{ cinder_rbd_secret_uuid }}" |
135 |
| - result: "{{ cinder_cephx_raw_key | default }}" |
136 |
| - enabled: "{{ cinder_backend_ceph }}" |
137 |
| - notify: |
138 |
| - - Restart nova-libvirt container |
139 |
| - no_log: True |
| 135 | + - name: Pushing nova secret xml for libvirt |
| 136 | + vars: |
| 137 | + service: "{{ nova_cell_services['nova-libvirt'] }}" |
| 138 | + template: |
| 139 | + src: "secret.xml.j2" |
| 140 | + dest: "{{ libvirt_secrets_dir }}/{{ item.uuid }}.xml" |
| 141 | + owner: "{{ config_owner_user }}" |
| 142 | + group: "{{ config_owner_group }}" |
| 143 | + mode: "0600" |
| 144 | + become: true |
| 145 | + when: |
| 146 | + - inventory_hostname in groups[service.group] |
| 147 | + - item.enabled | bool |
| 148 | + with_items: |
| 149 | + - uuid: "{{ rbd_secret_uuid }}" |
| 150 | + name: "client.nova secret" |
| 151 | + enabled: "{{ nova_backend == 'rbd' }}" |
| 152 | + - uuid: "{{ cinder_rbd_secret_uuid }}" |
| 153 | + name: "client.cinder secret" |
| 154 | + enabled: "{{ cinder_backend_ceph }}" |
| 155 | + notify: "{{ libvirt_restart_handlers }}" |
140 | 156 |
|
141 |
| -- name: Ensuring config directory has correct owner and permission |
142 |
| - become: true |
143 |
| - file: |
144 |
| - path: "{{ node_config_directory }}/{{ item }}" |
145 |
| - recurse: yes |
146 |
| - owner: "{{ config_owner_user }}" |
147 |
| - group: "{{ config_owner_group }}" |
148 |
| - with_items: |
149 |
| - - "nova-compute" |
150 |
| - - "nova-libvirt/secrets" |
151 |
| - when: inventory_hostname in groups[nova_cell_compute_group] |
| 157 | + - name: Pushing secrets key for libvirt |
| 158 | + vars: |
| 159 | + service: "{{ nova_cell_services['nova-libvirt'] }}" |
| 160 | + copy: |
| 161 | + content: "{{ item.result }}" |
| 162 | + dest: "{{ libvirt_secrets_dir }}/{{ item.uuid }}.base64" |
| 163 | + owner: "{{ config_owner_user }}" |
| 164 | + group: "{{ config_owner_group }}" |
| 165 | + mode: "0600" |
| 166 | + become: true |
| 167 | + when: |
| 168 | + - inventory_hostname in groups[service.group] |
| 169 | + - item.enabled | bool |
| 170 | + - external_ceph_cephx_enabled | bool |
| 171 | + with_items: |
| 172 | + # NOTE(yoctozepto): 'default' filter required due to eager evaluation of item content |
| 173 | + # which will be undefined if the applicable condition is False |
| 174 | + - uuid: "{{ rbd_secret_uuid }}" |
| 175 | + result: "{{ nova_cephx_raw_key | default }}" |
| 176 | + enabled: "{{ nova_backend == 'rbd' }}" |
| 177 | + - uuid: "{{ cinder_rbd_secret_uuid }}" |
| 178 | + result: "{{ cinder_cephx_raw_key | default }}" |
| 179 | + enabled: "{{ cinder_backend_ceph }}" |
| 180 | + notify: "{{ libvirt_restart_handlers }}" |
| 181 | + no_log: True |
| 182 | + vars: |
| 183 | + libvirt_secrets_dir: >- |
| 184 | + {{ (node_config_directory ~ '/nova-libvirt/secrets') |
| 185 | + if enable_nova_libvirt_container | bool |
| 186 | + else '/etc/libvirt/secrets' }} |
| 187 | + # NOTE(mgoddard): When running libvirt as a host daemon, on CentOS it |
| 188 | + # appears to pick up secrets automatically, while on Ubuntu it requires a |
| 189 | + # reload. This may be due to differences in tested versions of libvirt |
| 190 | + # (8.0.0 vs 6.0.0). Reload should be low overhead, so do it always. |
| 191 | + libvirt_restart_handlers: >- |
| 192 | + {{ ['Restart nova-libvirt container'] |
| 193 | + if enable_nova_libvirt_container | bool else |
| 194 | + ['Reload libvirtd'] }} |
0 commit comments