Use a single configuration file for specifying docker containers.
[apex-tripleo-heat-templates.git] / docker / services / octavia-api.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack Octavia service configured with Puppet
5
6 parameters:
7   DockerOctaviaApiImage:
8     description: image
9     type: string
10   DockerOctaviaConfigImage:
11     description: The container image to use for the octavia 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   EnableInternalTLS:
36     type: boolean
37     default: false
38
39 conditions:
40
41   internal_tls_enabled: {equals: [{get_param: EnableInternalTLS}, true]}
42
43
44 resources:
45
46   ContainersCommon:
47     type: ./containers-common.yaml
48
49   OctaviaApiPuppetBase:
50     type: ../../puppet/services/octavia-api.yaml
51     properties:
52       EndpointMap: {get_param: EndpointMap}
53       ServiceNetMap: {get_param: ServiceNetMap}
54       DefaultPasswords: {get_param: DefaultPasswords}
55       RoleName: {get_param: RoleName}
56       RoleParameters: {get_param: RoleParameters}
57
58 outputs:
59   role_data:
60     description: Role data for the Octavia API role.
61     value:
62       service_name: {get_attr: [OctaviaApiPuppetBase, role_data, service_name]}
63       config_settings: {get_attr: [OctaviaApiPuppetBase, role_data, config_settings]}
64       step_config: &step_config
65         get_attr: [OctaviaApiPuppetBase, role_data, step_config]
66       service_config_settings: {get_attr: [OctaviaApiPuppetBase, role_data, service_config_settings]}
67       # BEGIN DOCKER SETTINGS #
68       puppet_config:
69         config_volume: octavia
70         puppet_tags: octavia_config
71         step_config: *step_config
72         config_image: {get_param: DockerOctaviaConfigImage}
73       kolla_config:
74         /var/lib/kolla/config_files/octavia_api.json:
75           command: /usr/bin/octavia-api --config-file /usr/share/octavia/octavia-dist.conf --config-file /etc/octavia/octavia.conf --log-file /var/log/octavia/api.log --config-dir /etc/octavia/conf.d/common --config-dir /etc/octavia/conf.d/octavia-api
76           config_files:
77             - source: "/var/lib/kolla/config_files/src/*"
78               dest: "/"
79               merge: true
80               preserve_properties: true
81         /var/lib/kolla/config_files/octavia_api_tls_proxy.json:
82           command: /usr/sbin/httpd -DFOREGROUND
83           config_files:
84             - source: "/var/lib/kolla/config_files/src/*"
85               dest: "/"
86               merge: true
87               preserve_properties: true
88       docker_config:
89         # Kolla_bootstrap/db_sync runs before permissions set by kolla_config
90         step_2:
91           octavia_api_init_dirs:
92             start_order: 0
93             image: &octavia_api_image {get_param: DockerOctaviaApiImage}
94             user: root
95             volumes:
96               # NOTE(mandre) we need extra dir for the service in /etc/octavia/conf.d
97               # It is normally created as part of the RPM install, but it is
98               # missing here because we use the same config_volume for all
99               # octavia services, hence the same container image to generate
100               # configuration.
101               - /var/lib/config-data/puppet-generated/octavia/etc/octavia:/etc/octavia/
102               - /var/log/containers/octavia:/var/log/octavia
103             command: ['/bin/bash', '-c', 'mkdir -p /etc/octavia/conf.d/octavia-api; chown -R octavia:octavia /etc/octavia/conf.d/octavia-api; chown -R octavia:octavia /var/log/octavia']
104         step_3:
105           octavia_db_sync:
106             start_order: 0
107             image: *octavia_api_image
108             net: host
109             privileged: false
110             detach: false
111             user: root
112             volumes:
113               list_concat:
114                 - {get_attr: [ContainersCommon, volumes]}
115                 -
116                   - /var/lib/config-data/octavia/etc/octavia/:/etc/octavia/:ro
117                   - /var/log/containers/octavia:/var/log/octavia
118             command: "/usr/bin/bootstrap_host_exec octavia_api su octavia -s /bin/bash -c '/usr/bin/octavia-db-manage upgrade head'"
119         step_4:
120           map_merge:
121             - octavia_api:
122                 start_order: 2
123                 image: *octavia_api_image
124                 net: host
125                 privileged: false
126                 restart: always
127                 volumes:
128                   list_concat:
129                     - {get_attr: [ContainersCommon, volumes]}
130                     -
131                       - /var/lib/kolla/config_files/octavia_api.json:/var/lib/kolla/config_files/config.json:ro
132                       - /var/lib/config-data/puppet-generated/octavia/:/var/lib/kolla/config_files/src:ro
133                       - /var/log/containers/octavia:/var/log/octavia
134                 environment:
135                   - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
136             - if:
137                 - internal_tls_enabled
138                 - octavia_api_tls_proxy:
139                     start_order: 2
140                     image: *octavia_api_image
141                     net: host
142                     user: root
143                     restart: always
144                     volumes:
145                       list_concat:
146                         - {get_attr: [ContainersCommon, volumes]}
147                         -
148                           - /var/lib/kolla/config_files/octavia_api_tls_proxy.json:/var/lib/kolla/config_files/config.json:ro
149                           - /var/lib/config-data/puppet-generated/octavia/:/var/lib/kolla/config_files/src:ro
150                           - /etc/pki/tls/certs/httpd:/etc/pki/tls/certs/httpd:ro
151                           - /etc/pki/tls/private/httpd:/etc/pki/tls/private/httpd:ro
152                     environment:
153                       - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
154                 - {}
155       host_prep_tasks:
156         - name: create persistent logs directory
157           file:
158             path: /var/log/containers/octavia
159             state: directory
160       upgrade_tasks:
161         - name: Stop and disable octavia_api service
162           tags: step2
163           service: name=openstack-octavia-api state=stopped enabled=no