Use a single configuration file for specifying docker containers.
[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   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
36 resources:
37
38   ContainersCommon:
39     type: ./containers-common.yaml
40
41   IronicConductorBase:
42     type: ../../puppet/services/ironic-conductor.yaml
43     properties:
44       EndpointMap: {get_param: EndpointMap}
45       ServiceNetMap: {get_param: ServiceNetMap}
46       DefaultPasswords: {get_param: DefaultPasswords}
47       RoleName: {get_param: RoleName}
48       RoleParameters: {get_param: RoleParameters}
49
50 outputs:
51   role_data:
52     description: Role data for the Ironic Conductor role.
53     value:
54       service_name: {get_attr: [IronicConductorBase, role_data, service_name]}
55       config_settings:
56         map_merge:
57           - get_attr: [IronicConductorBase, role_data, config_settings]
58           # to avoid hard linking errors we store these on the same
59           # volume/device as the ironic master_path
60           # https://github.com/docker/docker/issues/7457
61           - ironic::drivers::pxe::tftp_root: /var/lib/ironic/tftpboot
62           - ironic::drivers::pxe::tftp_master_path: /var/lib/ironic/tftpboot/master_images
63           - ironic::pxe::tftp_root: /var/lib/ironic/tftpboot
64           - ironic::pxe::http_root: /var/lib/ironic/httpboot
65           - ironic::conductor::http_root: /var/lib/ironic/httpboot
66       step_config: &step_config
67         get_attr: [IronicConductorBase, role_data, step_config]
68       service_config_settings: {get_attr: [IronicConductorBase, role_data, service_config_settings]}
69       # BEGIN DOCKER SETTINGS
70       puppet_config:
71         config_volume: ironic
72         puppet_tags: ironic_config
73         step_config: *step_config
74         config_image: {get_param: DockerIronicConfigImage}
75       kolla_config:
76         /var/lib/kolla/config_files/ironic_conductor.json:
77           command: /usr/bin/ironic-conductor
78           config_files:
79             - source: "/var/lib/kolla/config_files/src/*"
80               dest: "/"
81               merge: true
82               preserve_properties: true
83           permissions:
84             - path: /var/lib/ironic
85               owner: ironic:ironic
86               recurse: true
87             - path: /var/log/ironic
88               owner: ironic:ironic
89               recurse: true
90       docker_config:
91         step_4:
92           ironic_conductor:
93             start_order: 80
94             image: {get_param: DockerIronicConductorImage}
95             net: host
96             privileged: true
97             restart: always
98             volumes:
99               list_concat:
100                 - {get_attr: [ContainersCommon, volumes]}
101                 -
102                   - /var/lib/kolla/config_files/ironic_conductor.json:/var/lib/kolla/config_files/config.json:ro
103                   - /var/lib/config-data/puppet-generated/ironic/:/var/lib/kolla/config_files/src:ro
104                   - /lib/modules:/lib/modules:ro
105                   - /sys:/sys
106                   - /dev:/dev
107                   - /run:/run #shared?
108                   - /var/lib/ironic:/var/lib/ironic
109                   - /var/log/containers/ironic:/var/log/ironic
110             environment:
111               - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
112       host_prep_tasks:
113         - name: create persistent directories
114           file:
115             path: "{{ item }}"
116             state: directory
117           with_items:
118             - /var/log/containers/ironic
119             - /var/lib/ironic
120         - name: stat /httpboot
121           stat: path=/httpboot
122           register: stat_httpboot
123         - name: stat /tftpboot
124           stat: path=/tftpboot
125           register: stat_tftpboot
126         - name: stat /var/lib/ironic/httpboot
127           stat: path=/var/lib/ironic/httpboot
128           register: stat_ironic_httpboot
129         - name: stat /var/lib/ironic/tftpboot
130           stat: path=/var/lib/ironic/tftpboot
131           register: stat_ironic_tftpboot
132         # cannot use 'copy' module as with 'remote_src' it doesn't support recursion
133         - name: migrate /httpboot to containerized (if applicable)
134           command: /bin/cp -R /httpboot /var/lib/ironic/httpboot
135           when: stat_httpboot.stat.exists and not stat_ironic_httpboot.stat.exists
136         - name: migrate /tftpboot to containerized (if applicable)
137           command: /bin/cp -R /tftpboot /var/lib/ironic/tftpboot
138           when: stat_tftpboot.stat.exists and not stat_ironic_tftpboot.stat.exists
139         # Even if there was nothing to copy from original locations,
140         # we need to create the dirs before starting the containers
141         - name: ensure ironic pxe directories exist
142           file:
143             path: /var/lib/ironic/{{ item }}
144             state: directory
145           with_items:
146             - httpboot
147             - tftpboot
148       upgrade_tasks:
149         - name: Stop and disable ironic_conductor service
150           tags: step2
151           service: name=openstack-ironic-conductor state=stopped enabled=no