1 heat_template_version: ocata
4 Configure os-net-config mappings for specific nodes
5 Your environment file needs to look like:
9 nic1: "00:c8:7c:e6:f0:2e"
11 nic1: "00:18:7d:99:0c:b6"
12 This will result in the first nodeN entry where a mac matches a
13 local device being written as a mapping file for os-net-config in
14 /etc/os-net-config/mapping.yaml
17 # Note this requires a liberty heat or newer in the undercloud due to
18 # the 2015-10-15 (which is required to enable str_replace serializing
19 # the json parameter to json, another approch with a string parameter
20 # will be required for older heat versions)
24 description: per-node configuration map
28 type: OS::Heat::MultipartMime
31 - config: {get_resource: OsNetConfigMappings}
34 type: OS::Heat::SoftwareConfig
41 eth_addr=$(cat /sys/class/net/*/address | tr '\n' ',')
42 mkdir -p /etc/os-net-config
44 # Create an os-net-config mapping file, note this defaults to
45 # /etc/os-net-config/mapping.yaml, so we use that name despite
46 # rendering the result as json
47 echo '$node_lookup' | python -c "
51 input = sys.stdin.readline() or '{}'
52 data = json.loads(input)
54 if any(x in '$eth_addr'.split(',') for x in data[node].values()):
55 interface_mapping = {'interface_mapping': data[node]}
56 with open('/etc/os-net-config/mapping.yaml', 'w') as f:
57 yaml.safe_dump(interface_mapping, f, default_flow_style=False)
61 $node_lookup: {get_param: NetConfigDataLookup}
65 value: {get_resource: userdata}