Merge "Add DhcpAgentNotification param to neutron base" into stable/pike
[apex-tripleo-heat-templates.git] / docker / services / zaqar.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized Zaqar services
5
6 parameters:
7   DockerZaqarImage:
8     description: image
9     type: string
10   DockerZaqarConfigImage:
11     description: The container image to use for the zaqar config_volume
12     type: string
13   ZaqarManagementStore:
14     type: string
15     description: The management store for Zaqar
16     default: mongodb
17   EndpointMap:
18     default: {}
19     description: Mapping of service endpoint -> protocol. Typically set
20                  via parameter_defaults in the resource registry.
21     type: json
22   ServiceData:
23     default: {}
24     description: Dictionary packing service data
25     type: json
26   ServiceNetMap:
27     default: {}
28     description: Mapping of service_name -> network name. Typically set
29                  via parameter_defaults in the resource registry.  This
30                  mapping overrides those in ServiceNetMapDefaults.
31     type: json
32   DefaultPasswords:
33     default: {}
34     type: json
35   RoleName:
36     default: ''
37     description: Role name on which the service is applied
38     type: string
39   RoleParameters:
40     default: {}
41     description: Parameters specific to the role
42     type: json
43   EnableInternalTLS:
44     type: boolean
45     default: false
46
47 conditions:
48   zaqar_management_store_sqlalchemy: {equals : [{get_param: ZaqarManagementStore}, 'sqlalchemy']}
49   internal_tls_enabled: {get_param: EnableInternalTLS}
50
51 resources:
52
53   ContainersCommon:
54     type: ./containers-common.yaml
55
56   MySQLClient:
57     type: ../../puppet/services/database/mysql-client.yaml
58
59   ZaqarBase:
60     type: ../../puppet/services/zaqar-api.yaml
61     properties:
62       EndpointMap: {get_param: EndpointMap}
63       ServiceData: {get_param: ServiceData}
64       ServiceNetMap: {get_param: ServiceNetMap}
65       DefaultPasswords: {get_param: DefaultPasswords}
66       RoleName: {get_param: RoleName}
67       RoleParameters: {get_param: RoleParameters}
68       EnableInternalTLS: {get_param: EnableInternalTLS}
69
70 outputs:
71   role_data:
72     description: Role data for the Zaqar API role.
73     value:
74       service_name: {get_attr: [ZaqarBase, role_data, service_name]}
75       config_settings: {get_attr: [ZaqarBase, role_data, config_settings]}
76       step_config: &step_config
77         list_join:
78           - "\n"
79           - - {get_attr: [ZaqarBase, role_data, step_config]}
80             - {get_attr: [MySQLClient, role_data, step_config]}
81       service_config_settings: {get_attr: [ZaqarBase, role_data, service_config_settings]}
82       # BEGIN DOCKER SETTINGS
83       puppet_config:
84         config_volume: zaqar
85         puppet_tags: zaqar_config
86         step_config: *step_config
87         config_image: {get_param: DockerZaqarConfigImage}
88       kolla_config:
89         /var/lib/kolla/config_files/zaqar.json:
90           command: /usr/sbin/httpd -DFOREGROUND
91           config_files:
92             - source: "/var/lib/kolla/config_files/src/*"
93               dest: "/"
94               merge: true
95               preserve_properties: true
96         /var/lib/kolla/config_files/zaqar_websocket.json:
97           command: /usr/bin/zaqar-server --config-file /etc/zaqar/zaqar.conf --config-file /etc/zaqar/1.conf
98           config_files:
99             - source: "/var/lib/kolla/config_files/src/*"
100               dest: "/"
101               merge: true
102               preserve_properties: true
103           permissions:
104             - path: /var/log/zaqar
105               owner: zaqar:zaqar
106               recurse: true
107       docker_config:
108         map_merge:
109           -
110             if:
111             - zaqar_management_store_sqlalchemy
112             -
113               step_2:
114                 zaqar_init_log:
115                   image: &zaqar_image {get_param: DockerZaqarImage}
116                   user: root
117                   volumes:
118                     - /var/log/containers/zaqar:/var/log/zaqar
119                     - /var/log/containers/httpd/zaqar:/var/log/httpd
120                   command: ['/bin/bash', '-c', 'chown -R zaqar:zaqar /var/log/zaqar']
121               step_3:
122                 zaqar_db_sync:
123                   image: *zaqar_image
124                   net: host
125                   privileged: false
126                   detach: false
127                   user: root
128                   volumes:
129                     list_concat:
130                       - {get_attr: [ContainersCommon, volumes]}
131                       -
132                         - /var/lib/config-data/zaqar/etc/zaqar/:/etc/zaqar/:ro
133                         - /var/log/containers/zaqar:/var/log/zaqar
134                         - /var/log/containers/httpd/zaqar:/var/log/httpd
135                   command: "/usr/bin/bootstrap_host_exec zaqar_api su zaqar -s /bin/bash -c 'zaqar-sql-db-manage upgrade head'"
136             - {}
137           - step_4:
138               zaqar:
139                 image: *zaqar_image
140                 net: host
141                 privileged: false
142                 restart: always
143                 # NOTE(mandre) kolla image changes the user to 'zaqar', we need it
144                 # to be root to run httpd
145                 user: root
146                 volumes:
147                   list_concat:
148                     - {get_attr: [ContainersCommon, volumes]}
149                     -
150                       - /var/lib/kolla/config_files/zaqar.json:/var/lib/kolla/config_files/config.json:ro
151                       - /var/lib/config-data/puppet-generated/zaqar/:/var/lib/kolla/config_files/src:ro
152                       - /var/log/containers/zaqar:/var/log/zaqar
153                       - /var/log/containers/httpd/zaqar:/var/log/httpd
154                       -
155                         if:
156                           - internal_tls_enabled
157                           - /etc/pki/tls/certs/httpd:/etc/pki/tls/certs/httpd:ro
158                           - ''
159                       -
160                         if:
161                           - internal_tls_enabled
162                           - /etc/pki/tls/private/httpd:/etc/pki/tls/private/httpd:ro
163                           - ''
164                 environment:
165                   - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
166               zaqar_websocket:
167                 image: *zaqar_image
168                 net: host
169                 privileged: false
170                 restart: always
171                 volumes:
172                   list_concat:
173                     - {get_attr: [ContainersCommon, volumes]}
174                     -
175                       - /var/lib/kolla/config_files/zaqar_websocket.json:/var/lib/kolla/config_files/config.json:ro
176                       - /var/lib/config-data/puppet-generated/zaqar/:/var/lib/kolla/config_files/src:ro
177                       - /var/log/containers/zaqar:/var/log/zaqar
178                       - /var/log/containers/httpd/zaqar:/var/log/httpd
179                 environment:
180                   - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
181       host_prep_tasks:
182         - name: create persistent logs directory
183           file:
184             path: "{{ item }}"
185             state: directory
186           with_items:
187             - /var/log/containers/zaqar
188             - /var/log/containers/httpd/zaqar
189       upgrade_tasks:
190         - name: Stop and disable zaqar service
191           tags: step2
192           service: name=httpd state=stopped enabled=no
193       metadata_settings:
194         get_attr: [ZaqarBase, role_data, metadata_settings]