Merge "Use a single configuration file for specifying docker containers."
[apex-tripleo-heat-templates.git] / docker / services / horizon.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized Horizon service
5
6 parameters:
7   DockerHorizonImage:
8     description: image
9     type: string
10   DockerHorizonConfigImage:
11     description: The container image to use for the horizon 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
40 resources:
41
42   ContainersCommon:
43     type: ./containers-common.yaml
44
45   HorizonBase:
46     type: ../../puppet/services/horizon.yaml
47     properties:
48       EndpointMap: {get_param: EndpointMap}
49       ServiceData: {get_param: ServiceData}
50       ServiceNetMap: {get_param: ServiceNetMap}
51       DefaultPasswords: {get_param: DefaultPasswords}
52       RoleName: {get_param: RoleName}
53       RoleParameters: {get_param: RoleParameters}
54
55 outputs:
56   role_data:
57     description: Role data for the Horizon API role.
58     value:
59       service_name: {get_attr: [HorizonBase, role_data, service_name]}
60       config_settings:
61         map_merge:
62           - get_attr: [HorizonBase, role_data, config_settings]
63           - horizon::vhost_extra_params:
64               add_listen: true
65               priority: 10
66               access_log_format: '%a %l %u %t \"%r\" %>s %b \"%%{}{Referer}i\" \"%%{}{User-Agent}i\"'
67               options: ['FollowSymLinks','MultiViews']
68           - horizon::secure_cookies: false
69       step_config: {get_attr: [HorizonBase, role_data, step_config]}
70       service_config_settings: {get_attr: [HorizonBase, role_data, service_config_settings]}
71       # BEGIN DOCKER SETTINGS
72       puppet_config:
73         config_volume: horizon
74         puppet_tags: horizon_config
75         step_config: {get_attr: [HorizonBase, role_data, step_config]}
76         config_image: {get_param: DockerHorizonConfigImage}
77       kolla_config:
78         /var/lib/kolla/config_files/horizon.json:
79           command: /usr/sbin/httpd -DFOREGROUND
80           config_files:
81             - source: "/var/lib/kolla/config_files/src/*"
82               dest: "/"
83               merge: true
84               preserve_properties: true
85           permissions:
86             - path: /var/log/horizon/
87               owner: apache:apache
88               recurse: true
89             # FIXME Apache tries to write a .lock file there
90             - path: /usr/share/openstack-dashboard/openstack_dashboard/local/
91               owner: apache:apache
92               recurse: false
93       docker_config:
94         step_2:
95           horizon_fix_perms:
96             image: &horizon_image {get_param: DockerHorizonImage}
97             user: root
98             # NOTE Set ownership for /var/log/horizon/horizon.log file here,
99             # otherwise it's created by root when generating django cache.
100             # FIXME Apache needs to read files in /etc/openstack-dashboard
101             # Need to set permissions to match the BM case,
102             # http://paste.openstack.org/show/609819/
103             command: ['/bin/bash', '-c', 'touch /var/log/horizon/horizon.log && chown -R apache:apache /var/log/horizon && chmod -R a+rx /etc/openstack-dashboard']
104             volumes:
105               - /var/log/containers/horizon:/var/log/horizon
106               - /var/lib/config-data/horizon/etc/:/etc/
107         step_3:
108           horizon:
109             image: *horizon_image
110             net: host
111             privileged: false
112             restart: always
113             volumes:
114               list_concat:
115                 - {get_attr: [ContainersCommon, volumes]}
116                 -
117                   - /var/lib/kolla/config_files/horizon.json:/var/lib/kolla/config_files/config.json:ro
118                   - /var/lib/config-data/puppet-generated/horizon/:/var/lib/kolla/config_files/src:ro
119                   - /var/log/containers/horizon:/var/log/horizon
120             environment:
121               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
122       host_prep_tasks:
123         - name: create persistent logs directory
124           file:
125             path: /var/log/containers/horizon
126             state: directory
127       upgrade_tasks:
128         - name: Stop and disable horizon service (running under httpd)
129           tags: step2
130           service: name=httpd state=stopped enabled=no
131       metadata_settings:
132         get_attr: [HorizonBase, role_data, metadata_settings]