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