e02a146918576aa20e1567f7cc0a02c3fde883d5
[apex-tripleo-heat-templates.git] / docker / services / ec2-api.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized EC2 API service
5
6 parameters:
7   DockerNamespace:
8     description: namespace
9     default: 'tripleoupstream'
10     type: string
11   DockerEc2ApiImage:
12     description: image
13     default: 'centos-binary-ec2-api:latest'
14     type: string
15   DockerEc2ApiConfigImage:
16     description: The container image to use for the ec2_api config_volume
17     default: 'centos-binary-ec2-api: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   Ec2ApiPuppetBase:
48       type: ../../puppet/services/ec2-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 EC2 API role.
59     value:
60       service_name: {get_attr: [Ec2ApiPuppetBase, role_data, service_name]}
61       config_settings: {get_attr: [Ec2ApiPuppetBase, role_data, config_settings]}
62       step_config: &step_config
63         get_attr: [Ec2ApiPuppetBase, role_data, step_config]
64       service_config_settings: {get_attr: [Ec2ApiPuppetBase, role_data, service_config_settings]}
65       # BEGIN DOCKER SETTINGS
66       puppet_config:
67         config_volume: ec2_api
68         puppet_tags: ec2api_api_paste_ini,ec2api_config
69         step_config: *step_config
70         config_image:
71           list_join:
72             - '/'
73             - [ {get_param: DockerNamespace}, {get_param: DockerEc2ApiConfigImage} ]
74       kolla_config:
75         /var/lib/kolla/config_files/ec2_api.json:
76           command: /usr/bin/ec2-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/ec2api
84               owner: ec2api:ec2api
85               recurse: true
86         /var/lib/kolla/config_files/ec2_api_metadata.json:
87           command: /usr/bin/ec2-api-metadata
88           config_files:
89             - source: "/var/lib/kolla/config_files/src/*"
90               dest: "/"
91               merge: true
92               preserve_properties: true
93           permissions:
94             - path: /var/log/ec2api # default log dir for metadata service as well
95               owner: ec2api:ec2api
96               recurse: true
97       docker_config:
98         # db sync runs before permissions set by kolla_config
99         step_2:
100           ec2_api_init_logs:
101             image: &ec2_api_image
102               list_join:
103                 - '/'
104                 - [ {get_param: DockerNamespace}, {get_param: DockerEc2ApiImage} ]
105             privileged: false
106             user: root
107             volumes:
108               - /var/log/containers/ec2_api:/var/log/ec2api
109               # mount ec2_api_metadata to "ec2api-metadata" only here to fix
110               # permissions of both directories in one go
111               - /var/log/containers/ec2_api_metadata:/var/log/ec2api-metadata
112             command: ['/bin/bash', '-c', 'chown -R ec2api:ec2api /var/log/ec2api /var/log/ec2api-metadata']
113         step_3:
114           ec2_api_db_sync:
115             image: *ec2_api_image
116             net: host
117             detach: false
118             privileged: false
119             user: root
120             volumes:
121               list_concat:
122                 - {get_attr: [ContainersCommon, volumes]}
123                 -
124                   - /var/lib/config-data/ec2_api/etc/ec2api/:/etc/ec2api/:ro
125                   - /var/log/containers/ec2_api:/var/log/ec2api
126             command: "/usr/bin/bootstrap_host_exec ec2_api su ec2api -s /bin/bash -c '/usr/bin/ec2-api-manage db_sync'"
127         step_4:
128           ec2_api:
129             image: *ec2_api_image
130             net: host
131             privileged: false
132             restart: always
133             volumes:
134               list_concat:
135                 - {get_attr: [ContainersCommon, volumes]}
136                 -
137                   - /var/lib/kolla/config_files/ec2_api.json:/var/lib/kolla/config_files/config.json:ro
138                   - /var/lib/config-data/puppet-generated/ec2_api/:/var/lib/kolla/config_files/src:ro
139                   - /var/log/containers/ec2_api:/var/log/ec2api
140             environment:
141               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
142           ec2_api_metadata:
143             image: *ec2_api_image
144             net: host
145             privileged: false
146             restart: always
147             volumes:
148               list_concat:
149                 - {get_attr: [ContainersCommon, volumes]}
150                 -
151                   - /var/lib/kolla/config_files/ec2_api_metadata.json:/var/lib/kolla/config_files/config.json:ro
152                   - /var/lib/config-data/puppet-generated/ec2_api/:/var/lib/kolla/config_files/src:ro
153                   - /var/log/containers/ec2_api_metadata:/var/log/ec2api
154             environment:
155               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
156       host_prep_tasks:
157         - name: create persistent log directories
158           file:
159             path: /var/log/containers/{{ item }}
160             state: directory
161           with_items:
162             - ec2_api
163             - ec2_api_metadata
164       upgrade_tasks:
165         - name: Stop and disable EC2-API services
166           tags: step2
167           service: name={{ item }} state=stopped enabled=no
168           with_items:
169             - openstack-ec2-api
170             - openstack-ec2-api-metadata