Return error when write_files exists in cloud-init (#1644)
* Return error when write_files exists in cloud-init Since the script adds a `write_files` key in cloud-init user-data, it should return error if this key already exist in the input file. Co-authored-by: Ondřej Budai <obudai@redhat.com>
This commit is contained in:
parent
9fab5def90
commit
ba5f49c592
1 changed files with 7 additions and 1 deletions
|
|
@ -29,6 +29,7 @@ import json
|
|||
import os
|
||||
import stat
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
|
||||
def octal_mode_string(mode):
|
||||
|
|
@ -62,7 +63,12 @@ def main():
|
|||
})
|
||||
|
||||
with open(f"{args.configdir}/user-data.yml") as f:
|
||||
sys.stdout.write(f.read())
|
||||
yml = f.read()
|
||||
o = yaml.safe_load(yml)
|
||||
if "write_files" in o:
|
||||
print("Input file should not contain `write_files`", file=sys.stderr)
|
||||
return 1
|
||||
sys.stdout.write(yml)
|
||||
sys.stdout.write("write_files: ")
|
||||
json.dump(write_files, sys.stdout)
|
||||
sys.stdout.write("\n")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue