Merge "Containerize Cinder-volume for HA"
[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_2:
90           nova_init_logs:
91             image: &nova_api_image
92               list_join:
93                 - '/'
94                 - [ {get_param: DockerNamespace}, {get_param: DockerNovaApiImage} ]
95             privileged: false
96             user: root
97             volumes:
98               - /var/log/containers/nova:/var/log/nova
99             command: ['/bin/bash', '-c', 'chown -R nova:nova /var/log/nova']
100         step_3:
101           nova_api_db_sync:
102             start_order: 0
103             image: *nova_api_image
104             net: host
105             detach: false
106             user: root
107             volumes: &nova_api_volumes
108               list_concat:
109                 - {get_attr: [ContainersCommon, volumes]}
110                 -
111                   - /var/lib/kolla/config_files/nova_api.json:/var/lib/kolla/config_files/config.json:ro
112                   - /var/lib/config-data/nova/etc/nova/:/etc/nova/:ro
113                   - /var/log/containers/nova:/var/log/nova
114             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage api_db sync'"
115           # FIXME: we probably want to wait on the 'cell_v2 update' in order for this
116           # to be capable of upgrading a baremetal setup. This is to ensure the name
117           # of the cell is 'default'
118           nova_api_map_cell0:
119             start_order: 1
120             image: *nova_api_image
121             net: host
122             detach: false
123             user: root
124             volumes: *nova_api_volumes
125             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 map_cell0'"
126           nova_api_create_default_cell:
127             start_order: 2
128             image: *nova_api_image
129             net: host
130             detach: false
131             volumes: *nova_api_volumes
132             # NOTE: allowing the exit code 2 is a dirty way of making
133             # this idempotent (if the resource already exists a conflict
134             # is raised)
135             exit_codes: [0,2]
136             user: root
137             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 create_cell --name=default'"
138           nova_db_sync:
139             start_order: 3
140             image: *nova_api_image
141             net: host
142             detach: false
143             volumes: *nova_api_volumes
144             user: root
145             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage db sync'"
146         step_4:
147           nova_api:
148             start_order: 2
149             image: *nova_api_image
150             net: host
151             user: nova
152             privileged: true
153             restart: always
154             volumes: *nova_api_volumes
155             environment:
156               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
157         step_5:
158           nova_api_discover_hosts:
159             start_order: 1
160             image: *nova_api_image
161             net: host
162             detach: false
163             volumes: *nova_api_volumes
164             user: root
165             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 discover_hosts'"
166       host_prep_tasks:
167         - name: create persistent logs directory
168           file:
169             path: /var/log/containers/nova
170             state: directory
171       upgrade_tasks:
172         - name: Stop and disable nova_api service
173           tags: step2
174           service: name=openstack-nova-api state=stopped enabled=no