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