Fix cfn-init-data path in ignition
The 'local-data' in path /var/lib/os-collect-config/local-data should be a directory, not a file. However, even if we can fix this, now os-apply-config will merge configs based on the order [ec2, heat and local], but actually there is no deployments collected local. Then unfortunately, the deployments collected from Heat will be overwriten because the merging order in os-apply-config. At this moment, we can't change os-apply-config since it's deliberate. So the only reasonable way we can do now is using /var/lib/heat-cfntools/cfn-init-data and /var/lib/cloud/data/cfn-init-data. Story: 2006566 Task: 36851 Change-Id: I3b1ed30967e9235e9e830c5e4156f739303be618
This commit is contained in:
parent
491e2fb470
commit
ea18c18188
|
@ -448,10 +448,12 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
|
||||||
|
|
||||||
payload = jsonutils.loads(userdata)
|
payload = jsonutils.loads(userdata)
|
||||||
encoded_metadata = urlparse.quote(jsonutils.dumps(metadata))
|
encoded_metadata = urlparse.quote(jsonutils.dumps(metadata))
|
||||||
cfn_init_data = {
|
path_list = ["/var/lib/heat-cfntools/cfn-init-data",
|
||||||
|
"/var/lib/cloud/data/cfn-init-data"]
|
||||||
|
ignition_format_metadata = {
|
||||||
"filesystem": "root",
|
"filesystem": "root",
|
||||||
"group": {"name": "root"},
|
"group": {"name": "root"},
|
||||||
"path": "/var/lib/os-collect-config/local-data",
|
"path": "",
|
||||||
"user": {"name": "root"},
|
"user": {"name": "root"},
|
||||||
"contents": {
|
"contents": {
|
||||||
"source": "data:," + encoded_metadata,
|
"source": "data:," + encoded_metadata,
|
||||||
|
@ -459,16 +461,19 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
|
||||||
"mode": 0o640
|
"mode": 0o640
|
||||||
}
|
}
|
||||||
|
|
||||||
storage = payload.setdefault('storage', {})
|
for path in path_list:
|
||||||
try:
|
storage = payload.setdefault('storage', {})
|
||||||
files = storage.setdefault('files', [])
|
|
||||||
except AttributeError:
|
|
||||||
raise ValueError('Ignition "storage" section must be a map')
|
|
||||||
else:
|
|
||||||
try:
|
try:
|
||||||
files.append(cfn_init_data)
|
files = storage.setdefault('files', [])
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise ValueError('Ignition "files" section must be a list')
|
raise ValueError('Ignition "storage" section must be a map')
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
data = ignition_format_metadata.copy()
|
||||||
|
data["path"] = path
|
||||||
|
files.append(data)
|
||||||
|
except AttributeError:
|
||||||
|
raise ValueError('Ignition "files" section must be a list')
|
||||||
|
|
||||||
return jsonutils.dumps(payload)
|
return jsonutils.dumps(payload)
|
||||||
|
|
||||||
|
|
|
@ -402,8 +402,10 @@ class NovaClientPluginUserdataTest(NovaClientPluginTestCase):
|
||||||
userdata=userdata,
|
userdata=userdata,
|
||||||
user_data_format=ud_format)
|
user_data_format=ud_format)
|
||||||
ig = json.loads(data)
|
ig = json.loads(data)
|
||||||
self.assertEqual("/var/lib/os-collect-config/local-data",
|
self.assertEqual("/var/lib/heat-cfntools/cfn-init-data",
|
||||||
ig["storage"]["files"][0]["path"])
|
ig["storage"]["files"][0]["path"])
|
||||||
|
self.assertEqual("/var/lib/cloud/data/cfn-init-data",
|
||||||
|
ig["storage"]["files"][1]["path"])
|
||||||
self.assertEqual("data:,%7B%22os-collect-config%22%3A%20%7B%22heat"
|
self.assertEqual("data:,%7B%22os-collect-config%22%3A%20%7B%22heat"
|
||||||
"%22%3A%20%7B%22password%22%3A%20%22%2A%2A%2A%22"
|
"%22%3A%20%7B%22password%22%3A%20%22%2A%2A%2A%22"
|
||||||
"%7D%7D%7D",
|
"%7D%7D%7D",
|
||||||
|
|
Loading…
Reference in New Issue