diff --git a/playbook.py b/playbook.py index b3d8f1b..73dc620 100755 --- a/playbook.py +++ b/playbook.py @@ -17,6 +17,12 @@ def parse_arguments(): default="inventory.yml", help="The path to the inventory file.", ) + parser.add_argument( + "-k", + "--ask-pass", + action="store_true", + help="Use become password as SSH password", + ) return parser.parse_args() @@ -61,7 +67,12 @@ def main(): become_pass = getpass(f"Enter become password for {host}: ") # Use JSON to safely pass the become password as an extra var - extra_vars = json.dumps({"ansible_become_pass": become_pass}) + raw_vars = {"ansible_become_pass": become_pass} + + if args.ask_pass: + raw_vars["ansible_ssh_pass"] = become_pass + + extra_vars = json.dumps(raw_vars) # Execute Ansible playbook for each host subprocess.run(