Merge "Fix wrong permission on database during mysql_init tasks." into stable/pike
[apex-tripleo-heat-templates.git] / docker / services / ironic-conductor.yaml
1 heat_template_version: pike
2
3 description: >
4   OpenStack containerized Ironic Conductor service
5
6 parameters:
7   DockerIronicConductorImage:
8     description: image
9     type: string
10   DockerIronicConfigImage:
11     description: The container image to use for the ironic 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   MySQLClient:
46     type: ../../puppet/services/database/mysql-client.yaml
47
48   IronicConductorBase:
49     type: ../../puppet/services/ironic-conductor.yaml
50     properties:
51       EndpointMap: {get_param: EndpointMap}
52       ServiceData: {get_param: ServiceData}
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 Ironic Conductor role.
61     value:
62       service_name: {get_attr: [IronicConductorBase, role_data, service_name]}
63       config_settings:
64         map_merge:
65           - get_attr: [IronicConductorBase, role_data, config_settings]
66           # to avoid hard linking errors we store these on the same
67           # volume/device as the ironic master_path
68           # https://github.com/docker/docker/issues/7457
69           - ironic::drivers::pxe::tftp_root: /var/lib/ironic/tftpboot
70           - ironic::drivers::pxe::tftp_master_path: /var/lib/ironic/tftpboot/master_images
71           - ironic::pxe::tftp_root: /var/lib/ironic/tftpboot
72           - ironic::pxe::http_root: /var/lib/ironic/httpboot
73           - ironic::conductor::http_root: /var/lib/ironic/httpboot
74       logging_source: {get_attr: [IronicConductorBase, role_data, logging_source]}
75       logging_groups: {get_attr: [IronicConductorBase, role_data, logging_groups]}
76       step_config: &step_config
77         list_join:
78           - "\n"
79           - - {get_attr: [IronicConductorBase, role_data, step_config]}
80             - {get_attr: [MySQLClient, role_data, step_config]}
81       service_config_settings: {get_attr: [IronicConductorBase, role_data, service_config_settings]}
82       # BEGIN DOCKER SETTINGS
83       puppet_config:
84         config_volume: ironic
85         puppet_tags: ironic_config
86         step_config: *step_config
87         config_image: {get_param: DockerIronicConfigImage}
88       kolla_config:
89         /var/lib/kolla/config_files/ironic_conductor.json:
90           command: /usr/bin/ironic-conductor
91           config_files:
92             - source: "/var/lib/kolla/config_files/src/*"
93               dest: "/"
94               merge: true
95               preserve_properties: true
96           permissions:
97             - path: /var/lib/ironic
98               owner: ironic:ironic
99               recurse: true
100             - path: /var/log/ironic
101               owner: ironic:ironic
102               recurse: true
103       docker_config:
104         step_4:
105           ironic_conductor:
106             start_order: 80
107             image: {get_param: DockerIronicConductorImage}
108             net: host
109             privileged: true
110             restart: always
111             volumes:
112               list_concat:
113                 - {get_attr: [ContainersCommon, volumes]}
114                 -
115                   - /var/lib/kolla/config_files/ironic_conductor.json:/var/lib/kolla/config_files/config.json:ro
116                   - /var/lib/config-data/puppet-generated/ironic/:/var/lib/kolla/config_files/src:ro
117                   - /lib/modules:/lib/modules:ro
118                   - /sys:/sys
119                   - /dev:/dev
120                   - /run:/run #shared?
121                   - /var/lib/ironic:/var/lib/ironic
122                   - /var/log/containers/ironic:/var/log/ironic
123             environment:
124               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
125       host_prep_tasks:
126         - name: create persistent directories
127           file:
128             path: "{{ item }}"
129             state: directory
130           with_items:
131             - /var/log/containers/ironic
132             - /var/lib/ironic
133         - name: stat /httpboot
134           stat: path=/httpboot
135           register: stat_httpboot
136         - name: stat /tftpboot
137           stat: path=/tftpboot
138           register: stat_tftpboot
139         - name: stat /var/lib/ironic/httpboot
140           stat: path=/var/lib/ironic/httpboot
141           register: stat_ironic_httpboot
142         - name: stat /var/lib/ironic/tftpboot
143           stat: path=/var/lib/ironic/tftpboot
144           register: stat_ironic_tftpboot
145         # cannot use 'copy' module as with 'remote_src' it doesn't support recursion
146         - name: migrate /httpboot to containerized (if applicable)
147           command: /bin/cp -R /httpboot /var/lib/ironic/httpboot
148           when: stat_httpboot.stat.exists and not stat_ironic_httpboot.stat.exists
149         - name: migrate /tftpboot to containerized (if applicable)
150           command: /bin/cp -R /tftpboot /var/lib/ironic/tftpboot
151           when: stat_tftpboot.stat.exists and not stat_ironic_tftpboot.stat.exists
152         # Even if there was nothing to copy from original locations,
153         # we need to create the dirs before starting the containers
154         - name: ensure ironic pxe directories exist
155           file:
156             path: /var/lib/ironic/{{ item }}
157             state: directory
158           with_items:
159             - httpboot
160             - tftpboot
161       upgrade_tasks:
162         - name: Stop and disable ironic_conductor service
163           tags: step2
164           service: name=openstack-ironic-conductor state=stopped enabled=no