Merge "Copy scheduler configuration from service/ironic to services-docker/ironic"
[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   EnablePackageInstall:
16     default: 'false'
17     description: Set to true to enable package installation at deploy time
18     type: boolean
19   ServiceData:
20     default: {}
21     description: Dictionary packing service data
22     type: json
23   ServiceNetMap:
24     default: {}
25     description: Mapping of service_name -> network name. Typically set
26                  via parameter_defaults in the resource registry.  This
27                  mapping overrides those in ServiceNetMapDefaults.
28     type: json
29   DefaultPasswords:
30     default: {}
31     type: json
32   RoleName:
33     default: ''
34     description: Role name on which the service is applied
35     type: string
36   RoleParameters:
37     default: {}
38     description: Parameters specific to the role
39     type: json
40   EndpointMap:
41     default: {}
42     description: Mapping of service endpoint -> protocol. Typically set
43                  via parameter_defaults in the resource registry.
44     type: json
45   EnableInternalTLS:
46     type: boolean
47     default: false
48   UseTLSTransportForLiveMigration:
49     type: boolean
50     default: true
51     description: If set to true and if EnableInternalTLS is enabled, it will
52                  set the libvirt URI's transport to tls and configure the
53                  relevant keys for libvirt.
54   DockerNovaMigrationSshdPort:
55     default: 2022
56     description: Port that dockerized nova migration target sshd service
57                  binds to.
58     type: number
59
60
61 conditions:
62
63   use_tls_for_live_migration:
64     and:
65     - equals:
66       - {get_param: EnableInternalTLS}
67       - true
68     - equals:
69       - {get_param: UseTLSTransportForLiveMigration}
70       - true
71
72 resources:
73
74   ContainersCommon:
75     type: ./containers-common.yaml
76
77   MySQLClient:
78     type: ../../puppet/services/database/mysql-client.yaml
79
80   NovaLibvirtBase:
81     type: ../../puppet/services/nova-libvirt.yaml
82     properties:
83       EndpointMap: {get_param: EndpointMap}
84       ServiceData: {get_param: ServiceData}
85       ServiceNetMap: {get_param: ServiceNetMap}
86       DefaultPasswords: {get_param: DefaultPasswords}
87       RoleName: {get_param: RoleName}
88       RoleParameters: {get_param: RoleParameters}
89       MigrationSshPort: {get_param: DockerNovaMigrationSshdPort}
90
91 outputs:
92   role_data:
93     description: Role data for the Libvirt service.
94     value:
95       service_name: {get_attr: [NovaLibvirtBase, role_data, service_name]}
96       config_settings:
97         get_attr: [NovaLibvirtBase, role_data, config_settings]
98       step_config: &step_config
99         list_join:
100           - "\n"
101           - - {get_attr: [NovaLibvirtBase, role_data, step_config]}
102             - {get_attr: [MySQLClient, role_data, step_config]}
103       puppet_config:
104         config_volume: nova_libvirt
105         puppet_tags: libvirtd_config,nova_config,file,exec
106         step_config: *step_config
107         config_image: {get_param: DockerNovaLibvirtConfigImage}
108       kolla_config:
109         /var/lib/kolla/config_files/nova_libvirt.json:
110           command:
111             if:
112               - use_tls_for_live_migration
113               - /usr/sbin/libvirtd --listen --config /etc/libvirt/libvirtd.conf
114               - /usr/sbin/libvirtd --config /etc/libvirt/libvirtd.conf
115           config_files:
116             - source: "/var/lib/kolla/config_files/src/*"
117               dest: "/"
118               merge: true
119               preserve_properties: true
120             - source: "/var/lib/kolla/config_files/src-ceph/"
121               dest: "/etc/ceph/"
122               merge: true
123               preserve_properties: true
124           permissions:
125             - path: /var/log/nova
126               owner: nova:nova
127               recurse: true
128       docker_config:
129         step_3:
130           nova_libvirt:
131             image: {get_param: DockerNovaLibvirtImage}
132             net: host
133             pid: host
134             privileged: true
135             restart: always
136             volumes:
137               list_concat:
138                 - {get_attr: [ContainersCommon, volumes]}
139                 -
140                   - /var/lib/kolla/config_files/nova_libvirt.json:/var/lib/kolla/config_files/config.json:ro
141                   - /var/lib/config-data/puppet-generated/nova_libvirt/:/var/lib/kolla/config_files/src:ro
142                   - /etc/ceph:/var/lib/kolla/config_files/src-ceph:ro
143                   - /lib/modules:/lib/modules:ro
144                   - /dev:/dev
145                   - /run:/run
146                   - /sys/fs/cgroup:/sys/fs/cgroup
147                   - /var/lib/nova:/var/lib/nova
148                   - /etc/libvirt/secrets:/etc/libvirt/secrets
149                   # Needed to use host's virtlogd
150                   - /var/run/libvirt:/var/run/libvirt
151                   - /var/lib/libvirt:/var/lib/libvirt
152                   - /etc/libvirt/qemu:/etc/libvirt/qemu
153                   - /var/log/libvirt/qemu:/var/log/libvirt/qemu:ro
154                   - /var/log/containers/nova:/var/log/nova
155             environment:
156               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
157       host_prep_tasks:
158         - name: create libvirt persistent data directories
159           file:
160             path: "{{ item }}"
161             state: directory
162           with_items:
163             - /etc/libvirt/secrets
164             - /etc/libvirt/qemu
165             - /var/lib/libvirt
166             - /var/log/containers/nova
167         - name: ensure ceph configurations exist
168           file:
169             path: /etc/ceph
170             state: directory
171         - name: set enable_package_install fact
172           set_fact:
173             enable_package_install: {get_param: EnablePackageInstall}
174         # We use virtlogd on host, so when using Deployed Server
175         # feature, we need to ensure libvirt is installed.
176         - name: install libvirt-daemon
177           package:
178             name: libvirt-daemon
179             state: present
180           when: enable_package_install
181         - name: start virtlogd socket
182           service:
183             name: virtlogd.socket
184             state: started
185             enabled: yes
186           when: enable_package_install
187       upgrade_tasks:
188         - name: Stop and disable libvirtd service
189           tags: step2
190           service: name=libvirtd state=stopped enabled=no