diff --git a/.gitignore b/.gitignore index f7275bb..3487fcc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ venv/ +*.gen \ No newline at end of file diff --git a/README.md b/README.md index 99f69ca..710f160 100644 --- a/README.md +++ b/README.md @@ -24,3 +24,11 @@ optional arguments: --containers-yaml-out CONTAINERS_YAML_OUT --standalone-yaml-out STANDALONE_YAML_OUT ``` + +Use this script to generate the yaml and a deploy script to buyild an AIO + +By default the files will be placed in the home directory of the user running the script (should probable be the stack user) + +When happy with the contents rename them to remove the .gen suffix and run the deploy script. + +The doco for the AIO deply says to run the deploy using sudo - I don't think this is correct. If you use sudo you will get a warning about files ending up /root. \ No newline at end of file diff --git a/main.py b/main.py index ff25069..ad0ffb4 100644 --- a/main.py +++ b/main.py @@ -9,6 +9,9 @@ import yaml def parse_args(): """Parse the command line arguments""" + + home = os.environ.get('HOME') + parser = argparse.ArgumentParser() parser.add_argument("-u", "--username", required=True) parser.add_argument("-p", "--password", required=True) @@ -25,10 +28,14 @@ def parse_args(): parser.add_argument("-g", "--gateway") parser.add_argument( "--containers-yaml-out", - default="./containers-prepare-parameters.yaml.gen", + default=f"{home}/containers-prepare-parameters.yaml.gen", ) parser.add_argument( - "--standalone-yaml-out", default="./standalone_parameters.yaml.gen" + "--standalone-yaml-out", default=f"{home}/standalone_parameters.yaml.gen" + ) + parser.add_argument( + "--deploy-script-out", + default=f"{home}/deploy.sh.gen", dest="deploy" ) args = parser.parse_args() @@ -94,6 +101,30 @@ def build_containers_yaml(args): return data +def deploy_sh(args): + home = os.environ.get("HOME") + + template = ( + "sudo openstack tripleo deploy \\\n" + " --templates \\\n" + f" --local-ip={args.address}/{args.netmask} \\\n" + " -e /usr/share/openstack-tripleo-heat-templates/" + "environments/standalone/standalone-tripleo.yaml \\\n" + " -r /usr/share/openstack-tripleo-heat-templates/" + "roles/Standalone.yaml \\\n" + f" -e {home}/containers-prepare-parameters.yaml \\\n" + f" -e {home}/standalone_parameters.yaml \\\n" + f" --output-dir {home} \\\n" + " --standalone\n" + ) + + return template + + +def set_hostname(args): + pass + + def main(): """main function""" args = parse_args() @@ -112,6 +143,10 @@ def main(): parameters_out.write(yaml.dump(standalone_parameters)) print(f"standalone parameters yaml written to {args.standalone_yaml_out}") + with open(args.deploy, "w", encoding="utf-8") as deploy: + deploy.write(deploy_sh(args)) + print(f"deploy script written to {args.deploy}") + if __name__ == "__main__": main()