Merge "Use a single configuration file for specifying docker containers."
[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   DockerNovaApiImage:
8     description: image
9     type: string
10   DockerNovaConfigImage:
11     description: The container image to use for the nova config_volume
12     type: string
13   EndpointMap:
14     default: {}
15     description: Mapping of service endpoint -> protocol. Typically set
16                  via parameter_defaults in the resource registry.
17     type: json
18   ServiceData:
19     default: {}
20     description: Dictionary packing service data
21     type: json
22   ServiceNetMap:
23     default: {}
24     description: Mapping of service_name -> network name. Typically set
25                  via parameter_defaults in the resource registry.  This
26                  mapping overrides those in ServiceNetMapDefaults.
27     type: json
28   DefaultPasswords:
29     default: {}
30     type: json
31   RoleName:
32     default: ''
33     description: Role name on which the service is applied
34     type: string
35   RoleParameters:
36     default: {}
37     description: Parameters specific to the role
38     type: json
39
40 resources:
41
42   ContainersCommon:
43     type: ./containers-common.yaml
44
45   NovaApiBase:
46     type: ../../puppet/services/nova-api.yaml
47     properties:
48       EndpointMap: {get_param: EndpointMap}
49       ServiceData: {get_param: ServiceData}
50       ServiceNetMap: {get_param: ServiceNetMap}
51       DefaultPasswords: {get_param: DefaultPasswords}
52       RoleName: {get_param: RoleName}
53       RoleParameters: {get_param: RoleParameters}
54
55 outputs:
56   role_data:
57     description: Role data for the Nova API role.
58     value:
59       service_name: {get_attr: [NovaApiBase, role_data, service_name]}
60       config_settings:
61         map_merge:
62           - get_attr: [NovaApiBase, role_data, config_settings]
63           - apache::default_vhost: false
64             nova_wsgi_enabled: false
65             nova::api::service_name: '%{::nova::params::api_service_name}'
66             nova::wsgi::apache_api::ssl: false
67       step_config: &step_config
68         list_join:
69           - "\n"
70           - - "['Nova_cell_v2'].each |String $val| { noop_resource($val) }"
71             - {get_attr: [NovaApiBase, role_data, step_config]}
72       service_config_settings: {get_attr: [NovaApiBase, role_data, service_config_settings]}
73       # BEGIN DOCKER SETTINGS
74       puppet_config:
75         config_volume: nova
76         puppet_tags: nova_config
77         step_config: *step_config
78         config_image: {get_param: DockerNovaConfigImage}
79       kolla_config:
80         /var/lib/kolla/config_files/nova_api.json:
81           command: /usr/bin/nova-api
82           config_files:
83             - source: "/var/lib/kolla/config_files/src/*"
84               dest: "/"
85               merge: true
86               preserve_properties: true
87           permissions:
88             - path: /var/log/nova
89               owner: nova:nova
90               recurse: true
91       docker_config:
92         # db sync runs before permissions set by kolla_config
93         step_2:
94           nova_init_logs:
95             image: &nova_api_image {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         step_3:
102           nova_api_db_sync:
103             start_order: 0
104             image: *nova_api_image
105             net: host
106             detach: false
107             user: root
108             volumes: &nova_api_bootstrap_volumes
109               list_concat:
110                 - {get_attr: [ContainersCommon, volumes]}
111                 -
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_bootstrap_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_bootstrap_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_bootstrap_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               list_concat:
156                 - {get_attr: [ContainersCommon, volumes]}
157                 -
158                   - /var/lib/kolla/config_files/nova_api.json:/var/lib/kolla/config_files/config.json:ro
159                   - /var/lib/config-data/puppet-generated/nova/:/var/lib/kolla/config_files/src:ro
160                   - /var/log/containers/nova:/var/log/nova
161             environment:
162               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
163           nova_api_cron:
164             image: *nova_api_image
165             net: host
166             user: root
167             privileged: true
168             restart: always
169             volumes: *nova_api_volumes
170             environment:
171               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
172             command: "/usr/sbin/crond -n"
173         step_5:
174           nova_api_discover_hosts:
175             start_order: 1
176             image: *nova_api_image
177             net: host
178             detach: false
179             volumes: *nova_api_bootstrap_volumes
180             user: root
181             command: "/usr/bin/bootstrap_host_exec nova_api su nova -s /bin/bash -c '/usr/bin/nova-manage cell_v2 discover_hosts'"
182       host_prep_tasks:
183         - name: create persistent logs directory
184           file:
185             path: /var/log/containers/nova
186             state: directory
187       upgrade_tasks:
188         - name: Stop and disable nova_api service
189           tags: step2
190           service: name=openstack-nova-api state=stopped enabled=no