8902f0dfc7ebb9eafc3fb12e048a5757e9055fdc
[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
44 conditions:
45   zaqar_management_store_sqlalchemy: {equals : [{get_param: ZaqarManagementStore}, 'sqlalchemy']}
46
47 resources:
48
49   ContainersCommon:
50     type: ./containers-common.yaml
51
52   MySQLClient:
53     type: ../../puppet/services/database/mysql-client.yaml
54
55   ZaqarBase:
56     type: ../../puppet/services/zaqar.yaml
57     properties:
58       EndpointMap: {get_param: EndpointMap}
59       ServiceData: {get_param: ServiceData}
60       ServiceNetMap: {get_param: ServiceNetMap}
61       DefaultPasswords: {get_param: DefaultPasswords}
62       RoleName: {get_param: RoleName}
63       RoleParameters: {get_param: RoleParameters}
64
65 outputs:
66   role_data:
67     description: Role data for the Zaqar API role.
68     value:
69       service_name: {get_attr: [ZaqarBase, role_data, service_name]}
70       config_settings: {get_attr: [ZaqarBase, role_data, config_settings]}
71       step_config: &step_config
72         list_join:
73           - "\n"
74           - - {get_attr: [ZaqarBase, role_data, step_config]}
75             - {get_attr: [MySQLClient, role_data, step_config]}
76       service_config_settings: {get_attr: [ZaqarBase, role_data, service_config_settings]}
77       # BEGIN DOCKER SETTINGS
78       puppet_config:
79         config_volume: zaqar
80         puppet_tags: zaqar_config
81         step_config: *step_config
82         config_image: {get_param: DockerZaqarConfigImage}
83       kolla_config:
84         /var/lib/kolla/config_files/zaqar.json:
85           command: /usr/sbin/httpd -DFOREGROUND
86           config_files:
87             - source: "/var/lib/kolla/config_files/src/*"
88               dest: "/"
89               merge: true
90               preserve_properties: true
91         /var/lib/kolla/config_files/zaqar_websocket.json:
92           command: /usr/bin/zaqar-server --config-file /etc/zaqar/zaqar.conf --config-file /etc/zaqar/1.conf
93           config_files:
94             - source: "/var/lib/kolla/config_files/src/*"
95               dest: "/"
96               merge: true
97               preserve_properties: true
98           permissions:
99             - path: /var/log/zaqar
100               owner: zaqar:zaqar
101               recurse: true
102       docker_config:
103         map_merge:
104           -
105             if:
106             - zaqar_management_store_sqlalchemy
107             -
108               step_2:
109                 zaqar_init_log:
110                   image: &zaqar_image {get_param: DockerZaqarImage}
111                   user: root
112                   volumes:
113                     - /var/log/containers/zaqar:/var/log/zaqar
114                   command: ['/bin/bash', '-c', 'chown -R zaqar:zaqar /var/log/zaqar']
115               step_3:
116                 zaqar_db_sync:
117                   image: *zaqar_image
118                   net: host
119                   privileged: false
120                   detach: false
121                   user: root
122                   volumes:
123                     list_concat:
124                       - {get_attr: [ContainersCommon, volumes]}
125                       -
126                         - /var/lib/config-data/zaqar/etc/zaqar/:/etc/zaqar/:ro
127                         - /var/log/containers/zaqar:/var/log/zaqar
128                   command: "/usr/bin/bootstrap_host_exec zaqar su zaqar -s /bin/bash -c 'zaqar-sql-db-manage upgrade head'"
129             - {}
130           - step_4:
131               zaqar:
132                 image: *zaqar_image
133                 net: host
134                 privileged: false
135                 restart: always
136                 # NOTE(mandre) kolla image changes the user to 'zaqar', we need it
137                 # to be root to run httpd
138                 user: root
139                 volumes:
140                   list_concat:
141                     - {get_attr: [ContainersCommon, volumes]}
142                     -
143                       - /var/lib/kolla/config_files/zaqar.json:/var/lib/kolla/config_files/config.json:ro
144                       - /var/lib/config-data/puppet-generated/zaqar/:/var/lib/kolla/config_files/src:ro
145                       - /var/log/containers/zaqar:/var/log/zaqar
146                 environment:
147                   - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
148               zaqar_websocket:
149                 image: *zaqar_image
150                 net: host
151                 privileged: false
152                 restart: always
153                 volumes:
154                   list_concat:
155                     - {get_attr: [ContainersCommon, volumes]}
156                     -
157                       - /var/lib/kolla/config_files/zaqar_websocket.json:/var/lib/kolla/config_files/config.json:ro
158                       - /var/lib/config-data/puppet-generated/zaqar/:/var/lib/kolla/config_files/src:ro
159                       - /var/log/containers/zaqar:/var/log/zaqar
160                 environment:
161                   - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
162       host_prep_tasks:
163         - name: create persistent logs directory
164           file:
165             path: /var/log/containers/zaqar
166             state: directory
167       upgrade_tasks:
168         - name: Stop and disable zaqar service
169           tags: step2
170           service: name=httpd state=stopped enabled=no