Merge "Enable mistral to run under mod_wsgi"
[apex-tripleo-heat-templates.git] / docker / services / nova-api.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized Nova API service
5
6 parameters:
7   DockerNamespace:
8     description: namespace
9     default: 'tripleoupstream'
10     type: string
11   DockerNovaApiImage:
12     description: image
13     default: 'centos-binary-nova-api:latest'
14     type: string
15   DockerNovaConfigImage:
16     description: image
17     default: 'centos-binary-nova-base:latest'
18     type: string
19   EndpointMap:
20     default: {}
21     description: Mapping of service endpoint -> protocol. Typically set
22                  via parameter_defaults in the resource registry.
23     type: json
24   ServiceNetMap:
25     default: {}
26     description: Mapping of service_name -> network name. Typically set
27                  via parameter_defaults in the resource registry.  This
28                  mapping overrides those in ServiceNetMapDefaults.
29     type: json
30   DefaultPasswords:
31     default: {}
32     type: json
33   RoleName:
34     default: ''
35     description: Role name on which the service is applied
36     type: string
37   RoleParameters:
38     default: {}
39     description: Parameters specific to the role
40     type: json
41
42 resources:
43
44   ContainersCommon:
45     type: ./containers-common.yaml
46
47   NovaApiBase:
48     type: ../../puppet/services/nova-api.yaml
49     properties:
50       EndpointMap: {get_param: EndpointMap}
51       ServiceNetMap: {get_param: ServiceNetMap}
52       DefaultPasswords: {get_param: DefaultPasswords}
53       RoleName: {get_param: RoleName}
54       RoleParameters: {get_param: RoleParameters}
55
56 outputs:
57   role_data:
58     description: Role data for the Nova API role.
59     value:
60       service_name: {get_attr: [NovaApiBase, role_data, service_name]}
61       config_settings:
62         map_merge:
63           - get_attr: [NovaApiBase, role_data, config_settings]
64           - apache::default_vhost: false
65       step_config: &step_config
66         list_join:
67           - "\n"
68           - - "['Nova_cell_v2'].each |String $val| { noop_resource($val) }"
69             - {get_attr: [NovaApiBase, role_data, step_config]}
70       service_config_settings: {get_attr: [NovaApiBase, role_data, service_config_settings]}
71       # BEGIN DOCKER SETTINGS
72       puppet_config:
73         config_volume: nova
74         puppet_tags: nova_config
75         step_config: *step_config
76         config_image:
77           list_join:
78           - '/'
79           - [ {get_param: DockerNamespace}, {get_param: DockerNovaConfigImage} ]
80       kolla_config:
81         /var/lib/kolla/config_files/nova_api.json:
82           command: /usr/bin/nova-api
83           permissions:
84             - path: /var/log/nova
85               owner: nova:nova
86               recurse: true
87       docker_config:
88         # db sync runs before permissions set by kolla_config
89         step_3:
90           nova_init_logs:
91             start_order: 0
92             image: &nova_api_image
93               list_join:
94                 - '/'
95                 - [ {get_param: DockerNamespace}, {get_param: DockerNovaApiImage} ]
96             privileged: false
97             user: root
98             volumes:
99               - /var/log/containers/nova:/var/log/nova
100             command: ['/bin/bash', '-c', 'chown -R nova:nova /var/log/nova']
101           nova_api_db_sync:
102             start_order: 1
103             image: *nova_api_image
104             net: host
105             detach: false
106             volumes: &nova_api_volumes
107               list_concat:
108                 - {get_attr: [ContainersCommon, volumes]}
109                 -
110                   - /var/lib/kolla/config_files/nova_api.json:/var/lib/kolla/config_files/config.json:ro
111                   - /var/lib/config-data/nova/etc/nova/:/etc/nova/:ro
112                   - /var/log/containers/nova:/var/log/nova
113             command: ['/usr/bin/nova-manage', 'api_db', 'sync']
114           # FIXME: we probably want to wait on the 'cell_v2 update' in order for this
115           # to be capable of upgrading a baremetal setup. This is to ensure the name
116           # of the cell is 'default'
117           nova_api_map_cell0:
118             start_order: 2
119             image: *nova_api_image
120             net: host
121             detach: false
122             volumes: *nova_api_volumes
123             command:
124               - '/usr/bin/nova-manage'
125               - 'cell_v2'
126               - 'map_cell0'
127           nova_api_create_default_cell:
128             start_order: 3
129             image: *nova_api_image
130             net: host
131             detach: false
132             volumes: *nova_api_volumes
133             # NOTE: allowing the exit code 2 is a dirty way of making
134             # this idempotent (if the resource already exists a conflict
135             # is raised)
136             exit_codes: [0,2]
137             command:
138               - '/usr/bin/nova-manage'
139               - 'cell_v2'
140               - 'create_cell'
141               - '--name="default"'
142           nova_db_sync:
143             start_order: 4
144             image: *nova_api_image
145             net: host
146             detach: false
147             volumes: *nova_api_volumes
148             command: ['/usr/bin/nova-manage', 'db', 'sync']
149         step_4:
150           nova_api:
151             start_order: 2
152             image: *nova_api_image
153             net: host
154             user: nova
155             privileged: true
156             restart: always
157             volumes: *nova_api_volumes
158             environment:
159               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
160         step_5:
161           nova_api_discover_hosts:
162             start_order: 1
163             image: *nova_api_image
164             net: host
165             detach: false
166             volumes: *nova_api_volumes
167             command:
168               - '/usr/bin/nova-manage'
169               - 'cell_v2'
170               - 'discover_hosts'
171       host_prep_tasks:
172         - name: create persistent logs directory
173           file:
174             path: /var/log/containers/nova
175             state: directory
176       upgrade_tasks:
177         - name: Stop and disable nova_api service
178           tags: step2
179           service: name=openstack-nova-api state=stopped enabled=no