diff --git a/utils/ansible-ipa-client-install b/utils/ansible-ipa-client-install index 453b75f30d3e3a00260f85f45bbf6e7c44ae145d..273f997fdb2d7cf15479385ea77c45c3054417e3 100755 --- a/utils/ansible-ipa-client-install +++ b/utils/ansible-ipa-client-install @@ -201,9 +201,19 @@ def parse_options(): choices=("yes", "no"), default=None, help="The bool value defines if the needed packages " "are installed on the node. Default: yes") + # playbook + parser.add_argument("--playbook-dir", + dest="playbook_dir", + default=None, + help="If defined will be used as to create inventory " + "file and playbook in. The files will not be removed " + "after the playbook processing ended.") options, args = parser.parse_known_args() + if options.playbook_dir and not os.path.isdir(options.playbook_dir): + parser.error("playbook dir does not exist") + if options.password_prompt: parser.error("password prompt is not possible with ansible") if options.log_file: @@ -240,10 +250,14 @@ def run_cmd(args): def main(options, args): - temp_dir = tempfile.mkdtemp(prefix='ansible-ipa') + if options.playbook_dir: + playbook_dir = options.playbook_dir + else: + temp_dir = tempfile.mkdtemp(prefix='ansible-ipa-client') + playbook_dir = temp_dir - inventory = os.path.join(temp_dir, "client-inventory") - playbook = os.path.join(temp_dir, "client-playbook.yml") + inventory = os.path.join(playbook_dir, "ipaclient-inventory") + playbook = os.path.join(playbook_dir, "ipaclient-playbook.yml") with open(inventory, 'w') as f: if options.servers: @@ -356,7 +370,8 @@ def main(options, args): if returncode != 0: raise RuntimeError() finally: - shutil.rmtree(temp_dir, ignore_errors=True) + if not options.playbook_dir: + shutil.rmtree(temp_dir, ignore_errors=True) options, args = parse_options() diff --git a/utils/ansible-ipa-replica-install b/utils/ansible-ipa-replica-install index 54c85bb49ba3d8541addf3aefc231aef29cf8280..16e700f28dd91bcd0849225dcc09a79ba8cecd8e 100755 --- a/utils/ansible-ipa-replica-install +++ b/utils/ansible-ipa-replica-install @@ -271,9 +271,19 @@ def parse_options(): help="The value defines if the needed services will " "automatically be openen in the firewall managed by " "firewalld. Default: yes") + # playbook + parser.add_argument("--playbook-dir", + dest="playbook_dir", + default=None, + help="If defined will be used as to create inventory " + "file and playbook in. The files will not be removed " + "after the playbook processing ended.") options, args = parser.parse_known_args() + if options.playbook_dir and not os.path.isdir(options.playbook_dir): + parser.error("playbook dir does not exist") + if options.log_file: parser.error("log_file is not supported") @@ -308,10 +318,14 @@ def run_cmd(args): def main(options, args): - temp_dir = tempfile.mkdtemp(prefix='ansible-ipa') + if options.playbook_dir: + playbook_dir = options.playbook_dir + else: + temp_dir = tempfile.mkdtemp(prefix='ansible-ipa-replica') + playbook_dir = temp_dir - inventory = os.path.join(temp_dir, "replica-inventory") - playbook = os.path.join(temp_dir, "replica-playbook.yml") + inventory = os.path.join(playbook_dir, "ipareplica-inventory") + playbook = os.path.join(playbook_dir, "ipareplica-playbook.yml") with open(inventory, 'w') as f: if options.servers: @@ -472,7 +486,8 @@ def main(options, args): if returncode != 0: raise RuntimeError() finally: - shutil.rmtree(temp_dir, ignore_errors=True) + if not options.playbook_dir: + shutil.rmtree(temp_dir, ignore_errors=True) options, args = parse_options() diff --git a/utils/ansible-ipa-server-install b/utils/ansible-ipa-server-install index 9e2ea48675dcbbaa1972c2fd28879f4bd59b00ec..906bca3c99cfff8a0f7919793f2935dc1b411baa 100755 --- a/utils/ansible-ipa-server-install +++ b/utils/ansible-ipa-server-install @@ -307,9 +307,19 @@ def parse_options(): choices=("yes", "no"), default=None, help="Copy the generated CSR from the ipaserver to " "the controller as <hostname>-ipa.csr.") + # playbook + parser.add_argument("--playbook-dir", + dest="playbook_dir", + default=None, + help="If defined will be used as to create inventory " + "file and playbook in. The files will not be removed " + "after the playbook processing ended.") options, args = parser.parse_known_args() + if options.playbook_dir and not os.path.isdir(options.playbook_dir): + parser.error("playbook dir does not exist") + if options.log_file: parser.error("log_file is not supported") @@ -344,10 +354,14 @@ def run_cmd(args): def main(options, args): - temp_dir = tempfile.mkdtemp(prefix='ansible-ipa') + if options.playbook_dir: + playbook_dir = options.playbook_dir + else: + temp_dir = tempfile.mkdtemp(prefix='ansible-ipa-server') + playbook_dir = temp_dir - inventory = os.path.join(temp_dir, "server-inventory") - playbook = os.path.join(temp_dir, "server-playbook.yml") + inventory = os.path.join(playbook_dir, "ipaserver-inventory") + playbook = os.path.join(playbook_dir, "ipaserver-playbook.yml") with open(inventory, 'w') as f: f.write("[ipaserver]\n") @@ -529,7 +543,8 @@ def main(options, args): if returncode != 0: raise RuntimeError() finally: - shutil.rmtree(temp_dir, ignore_errors=True) + if not options.playbook_dir: + shutil.rmtree(temp_dir, ignore_errors=True) options, args = parse_options()