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