9445069beb3e65a673a9963d9e178077884dcd42
[apex-tripleo-heat-templates.git] / docker / services / aodh-api.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized aodh service
5
6 parameters:
7   DockerAodhApiImage:
8     description: image
9     type: string
10   DockerAodhConfigImage:
11     description: The container image to use for the aodh 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   EnableInternalTLS:
40     type: boolean
41     default: false
42   UpgradeRemoveUnusedPackages:
43     default: false
44     description: Remove package if the service is being disabled during upgrade
45     type: boolean
46
47 conditions:
48
49   internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
50
51 resources:
52
53   ContainersCommon:
54     type: ./containers-common.yaml
55
56   MySQLClient:
57     type: ../../puppet/services/database/mysql-client.yaml
58
59   AodhApiPuppetBase:
60       type: ../../puppet/services/aodh-api.yaml
61       properties:
62         EndpointMap: {get_param: EndpointMap}
63         ServiceNetMap: {get_param: ServiceNetMap}
64         DefaultPasswords: {get_param: DefaultPasswords}
65         RoleName: {get_param: RoleName}
66         RoleParameters: {get_param: RoleParameters}
67
68 outputs:
69   role_data:
70     description: Role data for the aodh API role.
71     value:
72       service_name: {get_attr: [AodhApiPuppetBase, role_data, service_name]}
73       config_settings:
74         map_merge:
75           - get_attr: [AodhApiPuppetBase, role_data, config_settings]
76           - apache::default_vhost: false
77       logging_source: {get_attr: [AodhApiPuppetBase, role_data, logging_source]}
78       logging_groups: {get_attr: [AodhApiPuppetBase, role_data, logging_groups]}
79       step_config: &step_config
80         list_join:
81           - "\n"
82           - - {get_attr: [AodhApiPuppetBase, role_data, step_config]}
83             - {get_attr: [MySQLClient, role_data, step_config]}
84       service_config_settings: {get_attr: [AodhApiPuppetBase, role_data, service_config_settings]}
85       # BEGIN DOCKER SETTINGS
86       puppet_config:
87         config_volume: aodh
88         puppet_tags: aodh_api_paste_ini,aodh_config
89         step_config: *step_config
90         config_image: {get_param: DockerAodhConfigImage}
91       kolla_config:
92         /var/lib/kolla/config_files/aodh_api.json:
93           command: /usr/sbin/httpd -DFOREGROUND
94           config_files:
95             - source: "/var/lib/kolla/config_files/src/*"
96               dest: "/"
97               merge: true
98               preserve_properties: true
99           permissions:
100             - path: /var/log/aodh
101               owner: aodh:aodh
102               recurse: true
103       docker_config:
104         # db sync runs before permissions set by kolla_config
105         step_2:
106           aodh_init_log:
107             image: &aodh_api_image {get_param: DockerAodhApiImage}
108             user: root
109             volumes:
110               - /var/log/containers/aodh:/var/log/aodh
111               - /var/log/containers/httpd/aodh-api:/var/log/httpd
112             command: ['/bin/bash', '-c', 'chown -R aodh:aodh /var/log/aodh']
113         step_3:
114           aodh_db_sync:
115             image: *aodh_api_image
116             net: host
117             privileged: false
118             detach: false
119             user: root
120             volumes:
121               list_concat:
122                 - {get_attr: [ContainersCommon, volumes]}
123                 -
124                   - /var/lib/config-data/aodh/etc/my.cnf.d/tripleo.cnf:/etc/my.cnf.d/tripleo.cnf:ro
125                   - /var/lib/config-data/aodh/etc/aodh/:/etc/aodh/:ro
126                   - /var/log/containers/aodh:/var/log/aodh
127                   - /var/log/containers/httpd/aodh-api:/var/log/httpd
128             command: "/usr/bin/bootstrap_host_exec aodh_api su aodh -s /bin/bash -c /usr/bin/aodh-dbsync"
129         step_4:
130           aodh_api:
131             image: *aodh_api_image
132             net: host
133             privileged: false
134             restart: always
135             volumes:
136               list_concat:
137                 - {get_attr: [ContainersCommon, volumes]}
138                 -
139                   - /var/lib/kolla/config_files/aodh_api.json:/var/lib/kolla/config_files/config.json:ro
140                   - /var/lib/config-data/puppet-generated/aodh/:/var/lib/kolla/config_files/src:ro
141                   - /var/log/containers/aodh:/var/log/aodh
142                   - /var/log/containers/httpd/aodh-api:/var/log/httpd
143                   -
144                     if:
145                       - internal_tls_enabled
146                       - /etc/pki/tls/certs/httpd:/etc/pki/tls/certs/httpd:ro
147                       - ''
148                   -
149                     if:
150                       - internal_tls_enabled
151                       - /etc/pki/tls/private/httpd:/etc/pki/tls/private/httpd:ro
152                       - ''
153             environment:
154               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
155       host_prep_tasks:
156       - name: create persistent logs directory
157         file:
158           path: "{{ item }}"
159           state: directory
160         with_items:
161           - /var/log/containers/aodh
162           - /var/log/containers/httpd/aodh-api
163       upgrade_tasks:
164         - name: Stop and disable aodh service (running under httpd)
165           tags: step2
166           service: name=httpd state=stopped enabled=no
167         - name: Remove openstack-aodh-api package if operator requests it
168           yum: name=openstack-aodh-api state=removed
169           tags: step2
170           ignore_errors: True
171           when: {get_param: UpgradeRemoveUnusedPackages}
172       metadata_settings:
173         get_attr: [AodhApiPuppetBase, role_data, metadata_settings]