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