All stages must be able to handle an input_dir argument, as we now either pass it to all or none for agiven run. Simply set it to 'None' if it is not provided. Signed-off-by: Tom Gundersen <teg@jklm.no>
30 lines
728 B
Python
Executable file
30 lines
728 B
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def main(tree, input_dir, playbook):
|
|
with open("/tmp/inventory", "w") as f:
|
|
f.write(f"osbuild-tree ansible_connection=chroot ansible_host={tree} ansible_python_interpreter=/usr/bin/python3")
|
|
|
|
with open("/tmp/playbook.yml", "w") as f:
|
|
if isinstance(playbook, str):
|
|
f.write(playbook)
|
|
else:
|
|
json.dump(playbook, f)
|
|
|
|
r = subprocess.run([
|
|
"ansible-playbook", "-v",
|
|
"--connection", "chroot",
|
|
"--inventory", "/tmp/inventory",
|
|
"/tmp/playbook.yml"
|
|
])
|
|
|
|
return r.returncode
|
|
|
|
if __name__ == '__main__':
|
|
options = json.load(sys.stdin)
|
|
sys.exit(main(**options))
|