utils/ansible-ipa-[server,replica,client]-install: New --become-method option

This option is the same as the --become-method option with ansible-playbook.
If this option is set, become_method will be set in the generated playbook.
This commit is contained in:
Thomas Woerner
2019-08-06 12:42:21 +02:00
parent d43b4429e6
commit 1d5b5d38b7
3 changed files with 50 additions and 29 deletions

View File

@@ -208,6 +208,12 @@ def parse_options():
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.")
parser.add_argument("--become-method",
dest="become_method",
default="sudo",
help="privilege escalation method to use "
"(default=sudo), use `ansible-doc -t become -l` to "
"list valid choices.")
options, args = parser.parse_known_args()
@@ -356,15 +362,16 @@ def main(options, args):
state = "present"
with open(playbook, 'w') as f:
f.write("""---
- name: Playbook to configure IPA clients
hosts: ipaclients
become: true
roles:
- role: ipaclient
state: %s
""" % state)
f.write("---\n")
f.write("- name: Playbook to configure IPA clients\n")
f.write(" hosts: ipaclients\n")
f.write(" become: true\n")
if options.become_method:
f.write(" become_method: %s\n" % options.become_method)
f.write("\n")
f.write(" roles:\n")
f.write(" - role: ipaclient\n")
f.write(" state: %s\n" % state)
try:
returncode = run_cmd(['ansible-playbook', '-i', inventory, playbook])