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