Simulate o-c-c cfn deployments handling
o-c-c has a special mode which explodes deployments into individual files. This will effectively do the same for local copies of server metadata. Change-Id: I505d02a190ac93f243aeaf6d05256e66e832c8bf
This commit is contained in:
parent
d6bc04296c
commit
545ecfa013
27
playbooks/files/explode-deployments.py
Normal file
27
playbooks/files/explode-deployments.py
Normal file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('path', default='/var/lib/os-collect-config/local-data')
|
||||
parser.add_argument('--deployments-key', default='deployments')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
for fname in os.listdir(args.path):
|
||||
f = os.path.join(args.path, fname)
|
||||
with open(f) as infile:
|
||||
x = json.loads(infile.read())
|
||||
dp = args.deployments_key
|
||||
final_list = []
|
||||
if dp in x:
|
||||
if isinstance(x[dp], list):
|
||||
for d in x[dp]:
|
||||
name = d['name']
|
||||
if d.get('group', 'Heat::Ungrouped') in ('os-apply-config', 'Heat::Ungrouped'):
|
||||
final_list.append((name, d['config']))
|
||||
for oname, oconfig in final_list:
|
||||
with open('%s%s' % (f, oname), 'w') as outfile:
|
||||
outfile.write(json.dumps(oconfig))
|
@ -18,8 +18,17 @@
|
||||
- name: "Ensure heat local-data directory exists"
|
||||
sudo: yes
|
||||
file: path=/var/lib/os-collect-config/local-data state=directory
|
||||
- name: "Copy deployments exploder script"
|
||||
sudo: yes
|
||||
copy:
|
||||
src: files/explode-deployments.py
|
||||
dest: /usr/local/bin/explode-deployments
|
||||
mode: 0755
|
||||
- name: "Write out metadata"
|
||||
sudo: yes
|
||||
template:
|
||||
src: templates/host_metadata.json.j2
|
||||
dest: /var/lib/os-collect-config/local-data/host_metadata.json
|
||||
- name: "Explode deployments"
|
||||
sudo: yes
|
||||
command: /usr/local/bin/explode-deployments /var/lib/os-collect-config/local-data
|
||||
|
Loading…
x
Reference in New Issue
Block a user