summaryrefslogtreecommitdiffstats
path: root/utils/src
diff options
context:
space:
mode:
authorBrenton Leanhardt <bleanhar@redhat.com>2016-04-05 16:38:03 -0400
committerBrenton Leanhardt <bleanhar@redhat.com>2016-04-05 16:38:03 -0400
commitf13efb21bb48a2202a09d70bf0a0103461b22950 (patch)
tree8286e8f422376c60cef480cc612bed24f031dac9 /utils/src
parentdebe6109ad57c0d722c41a720dba95a1eb1f3d35 (diff)
parent67d4685ef8885ff3ee759f5a36d9c97ba2012c50 (diff)
downloadopenshift-f13efb21bb48a2202a09d70bf0a0103461b22950.tar.gz
openshift-f13efb21bb48a2202a09d70bf0a0103461b22950.tar.bz2
openshift-f13efb21bb48a2202a09d70bf0a0103461b22950.tar.xz
openshift-f13efb21bb48a2202a09d70bf0a0103461b22950.zip
Merge pull request #1654 from dgoodwin/gen-inventory
Add --gen-inventory command to atomic-openshift-installer.
Diffstat (limited to 'utils/src')
-rw-r--r--utils/src/ooinstall/cli_installer.py20
-rw-r--r--utils/src/ooinstall/oo_config.py2
-rw-r--r--utils/src/ooinstall/openshift_ansible.py3
3 files changed, 18 insertions, 7 deletions
diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py
index 50a688eca..dd9d517f1 100644
--- a/utils/src/ooinstall/cli_installer.py
+++ b/utils/src/ooinstall/cli_installer.py
@@ -862,8 +862,10 @@ def upgrade(ctx, latest_minor, next_major):
@click.command()
@click.option('--force', '-f', is_flag=True, default=False)
+@click.option('--gen-inventory', is_flag=True, default=False,
+ help="Generate an ansible inventory file and exit.")
@click.pass_context
-def install(ctx, force):
+def install(ctx, force, gen_inventory):
oo_cfg = ctx.obj['oo_cfg']
verbose = ctx.obj['verbose']
@@ -886,7 +888,6 @@ def install(ctx, force):
hosts_to_run_on, callback_facts = get_hosts_to_run_on(
oo_cfg, callback_facts, ctx.obj['unattended'], force, verbose)
- click.echo('Writing config to: %s' % oo_cfg.config_path)
# We already verified this is not the case for unattended installs, so this can
# only trigger for live CLI users:
@@ -896,7 +897,18 @@ def install(ctx, force):
if len(oo_cfg.calc_missing_facts()) > 0:
confirm_hosts_facts(oo_cfg, callback_facts)
+ # Write quick installer config file to disk:
oo_cfg.save_to_disk()
+ # Write ansible inventory file to disk:
+ inventory_file = openshift_ansible.generate_inventory(hosts_to_run_on)
+
+ click.echo()
+ click.echo('Wrote atomic-openshift-installer config: %s' % oo_cfg.config_path)
+ click.echo("Wrote ansible inventory: %s" % inventory_file)
+ click.echo()
+
+ if gen_inventory:
+ sys.exit(0)
click.echo('Ready to run installation process.')
message = """
@@ -905,8 +917,8 @@ If changes are needed please edit the config file above and re-run.
if not ctx.obj['unattended']:
confirm_continue(message)
- error = openshift_ansible.run_main_playbook(oo_cfg.hosts,
- hosts_to_run_on, verbose)
+ error = openshift_ansible.run_main_playbook(inventory_file, oo_cfg.hosts,
+ hosts_to_run_on, verbose)
if error:
# The bootstrap script will print out the log location.
message = """
diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py
index c9498542f..0f1f5caf7 100644
--- a/utils/src/ooinstall/oo_config.py
+++ b/utils/src/ooinstall/oo_config.py
@@ -198,7 +198,7 @@ class OOConfig(object):
self.settings['ansible_ssh_user'] = ''
self.settings['ansible_inventory_path'] = \
- '{}/hosts'.format(self.settings['ansible_inventory_directory'])
+ '{}/hosts'.format(os.path.dirname(self.config_path))
# clean up any empty sets
for setting in self.settings.keys():
diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py
index 6e43eac9f..28b157e8e 100644
--- a/utils/src/ooinstall/openshift_ansible.py
+++ b/utils/src/ooinstall/openshift_ansible.py
@@ -213,9 +213,8 @@ def default_facts(hosts, verbose=False):
return load_system_facts(inventory_file, os_facts_path, facts_env, verbose)
-def run_main_playbook(hosts, hosts_to_run_on, verbose=False):
+def run_main_playbook(inventory_file, hosts, hosts_to_run_on, verbose=False):
global CFG
- inventory_file = generate_inventory(hosts_to_run_on)
if len(hosts_to_run_on) != len(hosts):
main_playbook_path = os.path.join(CFG.ansible_playbook_directory,
'playbooks/byo/openshift-node/scaleup.yml')