Merge "Filter null/None service names"
[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       name: CollectMacDeploymentsController
44       servers:  {get_param: controller_servers}
45       config: {get_resource: CollectMacConfig}
46       actions: ['CREATE'] # Only do this on CREATE
47
48   CollectMacDeploymentsCompute:
49     type: OS::Heat::SoftwareDeployments
50     properties:
51       name: CollectMacDeploymentsCompute
52       servers:  {get_param: compute_servers}
53       config: {get_resource: CollectMacConfig}
54       actions: ['CREATE'] # Only do this on CREATE
55
56   CollectMacDeploymentsBlockStorage:
57     type: OS::Heat::SoftwareDeployments
58     properties:
59       name: CollectMacDeploymentsBlockStorage
60       servers:  {get_param: blockstorage_servers}
61       config: {get_resource: CollectMacConfig}
62       actions: ['CREATE'] # Only do this on CREATE
63
64   CollectMacDeploymentsObjectStorage:
65     type: OS::Heat::SoftwareDeployments
66     properties:
67       name: CollectMacDeploymentsObjectStorage
68       servers:  {get_param: objectstorage_servers}
69       config: {get_resource: CollectMacConfig}
70       actions: ['CREATE'] # Only do this on CREATE
71
72   CollectMacDeploymentsCephStorage:
73     type: OS::Heat::SoftwareDeployments
74     properties:
75       name: CollectMacDeploymentsCephStorage
76       servers:  {get_param: cephstorage_servers}
77       config: {get_resource: CollectMacConfig}
78       actions: ['CREATE'] # Only do this on CREATE
79
80   # Now we distribute all-the-macs to all nodes
81   DistributeMacConfig:
82     type: OS::Heat::SoftwareConfig
83     properties:
84       group: script
85       inputs:
86       - name: controller_mappings
87       - name: compute_mappings
88       - name: blockstorage_mappings
89       - name: objectstorage_mappings
90       - name: cephstorage_mappings
91       config: |
92         #!/bin/sh
93         echo $controller_mappings > /root/controller_mappings
94         echo $compute_mappings > /root/compute_mappings
95         echo $blockstorage_mappings > /root/blockstorage_mappings
96         echo $objectstorage_mappings > /root/objectstorage_mappings
97         echo $cephstorage_mappings > /root/cephstorage_mappings
98         echo "mappings = $(cat /root/*_mappings)"
99
100   DistributeMacDeploymentsController:
101     type: OS::Heat::SoftwareDeployments
102     properties:
103       name: DistributeMacDeploymentsController
104       servers:  {get_param: controller_servers}
105       config: {get_resource: DistributeMacConfig}
106       input_values:
107         # FIXME(shardy): It'd be more convenient if we could join these
108         # items together but because the returned format is a map (not a list)
109         # we can't use list_join or str_replace.  Possible Heat TODO.
110         controller_mappings: {get_attr: [CollectMacDeploymentsController, deploy_stdouts]}
111         compute_mappings: {get_attr: [CollectMacDeploymentsCompute, deploy_stdouts]}
112         blockstorage_mappings: {get_attr: [CollectMacDeploymentsBlockStorage, deploy_stdouts]}
113         objectstorage_mappings: {get_attr: [CollectMacDeploymentsObjectStorage, deploy_stdouts]}
114         cephstorage_mappings: {get_attr: [CollectMacDeploymentsCephStorage, deploy_stdouts]}
115       actions: ['CREATE'] # Only do this on CREATE