Add update yaml backward compatibe with PublicVirtualIP on ctlplane
[apex-tripleo-heat-templates.git] / extraconfig / all_nodes / mac_hostname.yaml
1 heat_template_version: 2014-10-16
2
3 description: >
4   Example extra config for cluster config
5   this example collects the hostname and MAC addresses for each node in
6   the deployment, then distributes that info to all Controller nodes.
7
8 # Parameters passed from the parent template - note if you maintain
9 # out-of-tree templates they may require additional parameters if the
10 # in-tree templates add a new role.
11 parameters:
12   controller_servers:
13     type: json
14   compute_servers:
15     type: json
16   blockstorage_servers:
17     type: json
18   objectstorage_servers:
19     type: json
20   cephstorage_servers:
21     type: json
22 # Note extra parameters can be defined, then passed data via the
23 # environment parameter_defaults, without modifying the parent template
24
25 resources:
26
27   CollectMacConfig:
28     type: OS::Heat::SoftwareConfig
29     properties:
30       group: script
31       config: |
32         #!/bin/sh
33         MACS=$(ifconfig  | grep ether | awk '{print $2}' | tr "\n" " ")
34         HOSTNAME=$(hostname -s)
35         echo "$HOSTNAME $MACS"
36
37   # FIXME(shardy): Long term it'd be better if Heat SoftwareDeployments accepted
38   # list instead of a map, then we could join the lists of servers into one
39   # deployment instead of requiring one deployment per-role.
40   CollectMacDeploymentsController:
41     type: OS::Heat::SoftwareDeployments
42     properties:
43       servers:  {get_param: controller_servers}
44       config: {get_resource: CollectMacConfig}
45       actions: ['CREATE'] # Only do this on CREATE
46
47   CollectMacDeploymentsCompute:
48     type: OS::Heat::SoftwareDeployments
49     properties:
50       servers:  {get_param: compute_servers}
51       config: {get_resource: CollectMacConfig}
52       actions: ['CREATE'] # Only do this on CREATE
53
54   CollectMacDeploymentsBlockStorage:
55     type: OS::Heat::SoftwareDeployments
56     properties:
57       servers:  {get_param: blockstorage_servers}
58       config: {get_resource: CollectMacConfig}
59       actions: ['CREATE'] # Only do this on CREATE
60
61   CollectMacDeploymentsObjectStorage:
62     type: OS::Heat::SoftwareDeployments
63     properties:
64       servers:  {get_param: objectstorage_servers}
65       config: {get_resource: CollectMacConfig}
66       actions: ['CREATE'] # Only do this on CREATE
67
68   CollectMacDeploymentsCephStorage:
69     type: OS::Heat::SoftwareDeployments
70     properties:
71       servers:  {get_param: cephstorage_servers}
72       config: {get_resource: CollectMacConfig}
73       actions: ['CREATE'] # Only do this on CREATE
74
75   # Now we distribute all-the-macs to all nodes
76   DistributeMacConfig:
77     type: OS::Heat::SoftwareConfig
78     properties:
79       group: script
80       inputs:
81       - name: controller_mappings
82       - name: compute_mappings
83       - name: blockstorage_mappings
84       - name: objectstorage_mappings
85       - name: cephstorage_mappings
86       config: |
87         #!/bin/sh
88         echo $controller_mappings > /root/controller_mappings
89         echo $compute_mappings > /root/compute_mappings
90         echo $blockstorage_mappings > /root/blockstorage_mappings
91         echo $objectstorage_mappings > /root/objectstorage_mappings
92         echo $cephstorage_mappings > /root/cephstorage_mappings
93         echo "mappings = $(cat /root/*_mappings)"
94
95   DistributeMacDeploymentsController:
96     type: OS::Heat::SoftwareDeployments
97     properties:
98       servers:  {get_param: controller_servers}
99       config: {get_resource: DistributeMacConfig}
100       input_values:
101         # FIXME(shardy): It'd be more convenient if we could join these
102         # items together but because the returned format is a map (not a list)
103         # we can't use list_join or str_replace.  Possible Heat TODO.
104         controller_mappings: {get_attr: [CollectMacDeploymentsController, deploy_stdouts]}
105         compute_mappings: {get_attr: [CollectMacDeploymentsCompute, deploy_stdouts]}
106         blockstorage_mappings: {get_attr: [CollectMacDeploymentsBlockStorage, deploy_stdouts]}
107         objectstorage_mappings: {get_attr: [CollectMacDeploymentsObjectStorage, deploy_stdouts]}
108         cephstorage_mappings: {get_attr: [CollectMacDeploymentsCephStorage, deploy_stdouts]}
109       actions: ['CREATE'] # Only do this on CREATE
110
111 outputs:
112   # This value should change if the configuration data has changed
113   # It is used to e.g re-apply puppet after hieradata values change.
114   config_identifier:
115     value: {get_attr: [DistributeMacDeploymentsController, deploy_stdouts]}
116