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