Merge "Add support for Dell EMC Unity Manila Backend" into stable/pike
[apex-tripleo-heat-templates.git] / docker / services / nova-libvirt.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack Libvirt Service
5
6 parameters:
7   DockerNovaLibvirtImage:
8     description: image
9     type: string
10   # we configure libvirt via the nova-compute container due to coupling
11   # in the puppet modules
12   DockerNovaLibvirtConfigImage:
13     description: The container image to use for the nova_libvirt config_volume
14     type: string
15   ServiceData:
16     default: {}
17     description: Dictionary packing service data
18     type: json
19   ServiceNetMap:
20     default: {}
21     description: Mapping of service_name -> network name. Typically set
22                  via parameter_defaults in the resource registry.  This
23                  mapping overrides those in ServiceNetMapDefaults.
24     type: json
25   DefaultPasswords:
26     default: {}
27     type: json
28   RoleName:
29     default: ''
30     description: Role name on which the service is applied
31     type: string
32   RoleParameters:
33     default: {}
34     description: Parameters specific to the role
35     type: json
36   EndpointMap:
37     default: {}
38     description: Mapping of service endpoint -> protocol. Typically set
39                  via parameter_defaults in the resource registry.
40     type: json
41   EnableInternalTLS:
42     type: boolean
43     default: false
44   UseTLSTransportForLiveMigration:
45     type: boolean
46     default: true
47     description: If set to true and if EnableInternalTLS is enabled, it will
48                  set the libvirt URI's transport to tls and configure the
49                  relevant keys for libvirt.
50   DockerNovaMigrationSshdPort:
51     default: 2022
52     description: Port that dockerized nova migration target sshd service
53                  binds to.
54     type: number
55   NovaEnableRbdBackend:
56     default: false
57     description: Whether to enable or not the Rbd backend for Nova
58     type: boolean
59   CinderEnableRbdBackend:
60     default: false
61     description: Whether to enable or not the Rbd backend for Cinder
62     type: boolean
63   CephClientKey:
64     description: The Ceph client key. Can be created with ceph-authtool --gen-print-key.
65     type: string
66     hidden: true
67   CephClusterFSID:
68     type: string
69     description: The Ceph cluster FSID. Must be a UUID.
70
71 conditions:
72
73   use_tls_for_live_migration:
74     and:
75     - equals:
76       - {get_param: EnableInternalTLS}
77       - true
78     - equals:
79       - {get_param: UseTLSTransportForLiveMigration}
80       - true
81
82   need_libvirt_secret:
83     or:
84     - equals:
85       - {get_param: NovaEnableRbdBackend}
86       - true
87     - equals:
88       - {get_param: CinderEnableRbdBackend}
89       - true
90
91 resources:
92
93   ContainersCommon:
94     type: ./containers-common.yaml
95
96   MySQLClient:
97     type: ../../puppet/services/database/mysql-client.yaml
98
99   NovaLibvirtBase:
100     type: ../../puppet/services/nova-libvirt.yaml
101     properties:
102       EndpointMap: {get_param: EndpointMap}
103       ServiceData: {get_param: ServiceData}
104       ServiceNetMap: {get_param: ServiceNetMap}
105       DefaultPasswords: {get_param: DefaultPasswords}
106       RoleName: {get_param: RoleName}
107       RoleParameters: {get_param: RoleParameters}
108       MigrationSshPort: {get_param: DockerNovaMigrationSshdPort}
109
110 outputs:
111   role_data:
112     description: Role data for the Libvirt service.
113     value:
114       service_name: {get_attr: [NovaLibvirtBase, role_data, service_name]}
115       config_settings:
116         map_merge:
117           - get_attr: [NovaLibvirtBase, role_data, config_settings]
118           - tripleo::profile::base::certmonger_user::libvirt_postsave_cmd: "true" # TODO: restart the libvirt container here
119
120       step_config: &step_config
121         list_join:
122           - "\n"
123           - - {get_attr: [NovaLibvirtBase, role_data, step_config]}
124             - {get_attr: [MySQLClient, role_data, step_config]}
125       puppet_config:
126         config_volume: nova_libvirt
127         puppet_tags: libvirtd_config,nova_config,file
128         step_config: *step_config
129         config_image: {get_param: DockerNovaLibvirtConfigImage}
130       kolla_config:
131         /var/lib/kolla/config_files/nova_libvirt.json:
132           command:
133             if:
134               - use_tls_for_live_migration
135               - /usr/sbin/libvirtd --listen --config /etc/libvirt/libvirtd.conf
136               - /usr/sbin/libvirtd --config /etc/libvirt/libvirtd.conf
137           config_files:
138             - source: "/var/lib/kolla/config_files/src/*"
139               dest: "/"
140               merge: true
141               preserve_properties: true
142             - source: "/var/lib/kolla/config_files/src-ceph/"
143               dest: "/etc/ceph/"
144               merge: true
145               preserve_properties: true
146         /var/lib/kolla/config_files/nova_virtlogd.json:
147           command: /usr/sbin/virtlogd --config /etc/libvirt/virtlogd.conf
148           config_files:
149             - source: "/var/lib/kolla/config_files/src/*"
150               dest: "/"
151               merge: true
152               preserve_properties: true
153           permissions:
154             - path: /var/log/nova
155               owner: nova:nova
156               recurse: true
157       docker_config:
158         step_3:
159           nova_virtlogd:
160             start_order: 0
161             image: {get_param: DockerNovaLibvirtImage}
162             net: host
163             pid: host
164             privileged: true
165             restart: always
166             volumes:
167               list_concat:
168                 - {get_attr: [ContainersCommon, volumes]}
169                 -
170                   - /var/lib/kolla/config_files/nova_virtlogd.json:/var/lib/kolla/config_files/config.json:ro
171                   - /var/lib/config-data/puppet-generated/nova_libvirt/:/var/lib/kolla/config_files/src:ro
172                   - /lib/modules:/lib/modules:ro
173                   - /dev:/dev
174                   - /run:/run
175                   - /sys/fs/cgroup:/sys/fs/cgroup
176                   - /var/lib/nova:/var/lib/nova
177                   - /var/run/libvirt:/var/run/libvirt
178                   - /var/lib/libvirt:/var/lib/libvirt
179                   - /etc/libvirt/qemu:/etc/libvirt/qemu:ro
180                   - /var/log/libvirt/qemu:/var/log/libvirt/qemu
181             environment:
182               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
183           nova_libvirt:
184             start_order: 1
185             image: {get_param: DockerNovaLibvirtImage}
186             net: host
187             pid: host
188             privileged: true
189             restart: always
190             volumes:
191               list_concat:
192                 - {get_attr: [ContainersCommon, volumes]}
193                 -
194                   - /var/lib/kolla/config_files/nova_libvirt.json:/var/lib/kolla/config_files/config.json:ro
195                   - /var/lib/config-data/puppet-generated/nova_libvirt/:/var/lib/kolla/config_files/src:ro
196                   - /etc/ceph:/var/lib/kolla/config_files/src-ceph:ro
197                   - /lib/modules:/lib/modules:ro
198                   - /dev:/dev
199                   - /run:/run
200                   - /sys/fs/cgroup:/sys/fs/cgroup
201                   - /var/lib/nova:/var/lib/nova
202                   - /etc/libvirt:/etc/libvirt
203                   - /var/run/libvirt:/var/run/libvirt
204                   - /var/lib/libvirt:/var/lib/libvirt
205                   - /var/log/libvirt/qemu:/var/log/libvirt/qemu:ro
206                   - /var/log/containers/nova:/var/log/nova
207                 -
208                   if:
209                     - use_tls_for_live_migration
210                     -
211                       - /etc/ipa/ca.crt:/etc/pki/CA/cacert.pem:ro
212                       - /etc/pki/libvirt/servercert.pem:/etc/pki/libvirt/servercert.pem:ro
213                       - /etc/pki/libvirt/private/serverkey.pem:/etc/pki/libvirt/private/serverkey.pem:ro
214                       - /etc/pki/libvirt/clientcert.pem:/etc/pki/libvirt/clientcert.pem:ro
215                       - /etc/pki/libvirt/private/clientkey.pem:/etc/pki/libvirt/private/clientkey.pem:ro
216                     - null
217             environment:
218               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
219         step_4:
220           if:
221             - need_libvirt_secret
222             - nova_libvirt_init_secret:
223                 detach: false
224                 image: {get_param: DockerNovaLibvirtImage}
225                 privileged: false
226                 user: root
227                 volumes:
228                   list_concat:
229                     - {get_attr: [ContainersCommon, volumes]}
230                     -
231                       - /var/lib/config-data/puppet-generated/nova_libvirt/etc/nova:/etc/nova:ro
232                       - /etc/libvirt:/etc/libvirt
233                       - /var/run/libvirt:/var/run/libvirt
234                       - /var/lib/libvirt:/var/lib/libvirt
235                 command:
236                   - /bin/bash
237                   - -c
238                   - str_replace:
239                       template: /usr/bin/virsh secret-define --file /etc/nova/secret.xml && /usr/bin/virsh secret-set-value --secret 'SECRET_UUID' --base64 'SECRET_KEY'
240                       params:
241                         SECRET_UUID: {get_param: CephClusterFSID}
242                         SECRET_KEY: {get_param: CephClientKey}
243             - {}
244       host_prep_tasks:
245         - name: create libvirt persistent data directories
246           file:
247             path: "{{ item }}"
248             state: directory
249           with_items:
250             - /etc/libvirt
251             - /etc/libvirt/secrets
252             - /etc/libvirt/qemu
253             - /var/lib/libvirt
254             - /var/log/containers/nova
255         - name: ensure ceph configurations exist
256           file:
257             path: /etc/ceph
258             state: directory
259         - name: check if libvirt is installed
260           command: /usr/bin/rpm -q libvirt-daemon
261           failed_when: false
262           register: libvirt_installed
263         - name: make sure libvirt services are disabled
264           service:
265             name: "{{ item }}"
266             state: stopped
267             enabled: no
268           with_items:
269             - libvirtd.service
270             - virtlogd.socket
271           when: libvirt_installed.rc == 0
272       metadata_settings:
273         get_attr: [NovaLibvirtBase, role_data, metadata_settings]
274       upgrade_tasks:
275         - name: Stop and disable libvirtd service
276           tags: step2
277           service: name=libvirtd state=stopped enabled=no