From 82b4209c02c27ab0e9a6d9c016ff06d12f42a9c1 Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Thu, 5 Nov 2015 08:41:51 -0500 Subject: Bug 1274201 - Fixing sudo non-interactive test https://bugzilla.redhat.com/show_bug.cgi?id=1274201#c13 --- utils/src/ooinstall/openshift_ansible.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index e33330102..bdb9859a2 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -46,7 +46,7 @@ def generate_inventory(hosts): if any(host.hostname == installer_host or host.public_hostname == installer_host for host in hosts): - no_pwd_sudo = subprocess.call(['sudo', '-v', '--non-interactive']) + no_pwd_sudo = subprocess.call(['sudo', '-v', '-n']) if no_pwd_sudo == 1: print 'The atomic-openshift-installer requires sudo access without a password.' sys.exit(1) -- cgit v1.2.3 From cfca7b9f7894e2b427ae0753477cd13cc537e348 Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Thu, 5 Nov 2015 09:14:33 -0500 Subject: Bug 1274201 - Fixing non-root installations if using a local connection Previously we were writing out a inventory like this: ~~~ [OSEv3:children] masters nodes [OSEv3:vars] ansible_ssh_user=root deployment_type=openshift-enterprise ansible_connection=local [masters] ose3-master.example.com openshift_hostname=ose3-master.example.com [nodes] ose3-master.example.com openshift_hostname=ose3-master.example.com ose3-node1.example.com openshift_hostname=ose3-node1.example.com ose3-node2.example.com openshift_hostname=ose3-node2.example.com ~~~ The problem with that is now all the hosts are consider local connections. In addition our sudo check wasn't working as expected. We would check that we have sudo, but the playbooks were not running with root privileges. When gathering facts you'd hit: ~~~ __main__.OpenShiftFactsFileWriteError: Could not create fact file: /etc/ansible/facts.d/openshift.fact, error: [Errno 13] Permission denied: '/etc/ansible/facts.d/openshift.fact' ~~~ Instead the test for locale connections needs to be per host. Anytime we're not running as root we need `ansible_become` set: ~~~ ose3-master.example.com openshift_hostname=ose3-master.example.com ansible_connection=local ansible_become=true ~~~ --- utils/src/ooinstall/openshift_ansible.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'utils') diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index bdb9859a2..4b37be278 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -18,7 +18,6 @@ def set_config(cfg): def generate_inventory(hosts): global CFG - installer_host = socket.gethostname() base_inventory_path = CFG.settings['ansible_inventory_path'] base_inventory = open(base_inventory_path, 'w') base_inventory.write('\n[OSEv3:children]\nmasters\nnodes\n') @@ -44,14 +43,6 @@ def generate_inventory(hosts): if 'OO_INSTALL_STAGE_REGISTRY' in os.environ: base_inventory.write('oreg_url=registry.access.stage.redhat.com/openshift3/ose-${component}:${version}\n') - if any(host.hostname == installer_host or host.public_hostname == installer_host - for host in hosts): - no_pwd_sudo = subprocess.call(['sudo', '-v', '-n']) - if no_pwd_sudo == 1: - print 'The atomic-openshift-installer requires sudo access without a password.' - sys.exit(1) - base_inventory.write("ansible_connection=local\n") - base_inventory.write('\n[masters]\n') masters = (host for host in hosts if host.master) for master in masters: @@ -72,6 +63,7 @@ def generate_inventory(hosts): def write_host(host, inventory, scheduleable=True): global CFG + facts = '' if host.ip: facts += ' openshift_ip={}'.format(host.ip) @@ -85,6 +77,16 @@ def write_host(host, inventory, scheduleable=True): # Technically only nodes will ever need this. if not scheduleable: facts += ' openshift_scheduleable=False' + installer_host = socket.gethostname() + if host.hostname == installer_host or host.public_hostname == installer_host: + facts += ' ansible_connection=local' + if os.geteuid() != 0: + no_pwd_sudo = subprocess.call(['sudo', '-v', '-n']) + if no_pwd_sudo == 1: + print 'The atomic-openshift-installer requires sudo access without a password.' + sys.exit(1) + facts += ' ansible_become=true' + inventory.write('{} {}\n'.format(host, facts)) -- cgit v1.2.3 From dcd2fb0558c58fb79f9e3dd9ecd5f6687d8bed5d Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Thu, 5 Nov 2015 09:47:50 -0500 Subject: Making it easier to use pre-release content --- utils/src/ooinstall/openshift_ansible.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'utils') diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index 4b37be278..0648df0fa 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -31,17 +31,18 @@ def generate_inventory(hosts): version=CFG.settings.get('variant_version', None))[1] base_inventory.write('deployment_type={}\n'.format(ver.ansible_key)) - if 'OO_INSTALL_DEVEL_REGISTRY' in os.environ: - base_inventory.write('oreg_url=rcm-img-docker01.build.eng.bos.redhat.com:' - '5001/openshift3/ose-${component}:${version}\n') - if 'OO_INSTALL_PUDDLE_REPO_ENABLE' in os.environ: - base_inventory.write("openshift_additional_repos=[{'id': 'ose-devel', " + if 'OO_INSTALL_ADDITIONAL_REGISTRIES' in os.environ: + base_inventory.write('cli_docker_additional_registries={}\n' + .format(os.environ['OO_INSTALL_ADDITIONAL_REGISTRIES'])) + if 'OO_INSTALL_INSECURE_REGISTRIES' in os.environ: + base_inventory.write('cli_docker_insecure_registries={}\n' + .format(os.environ['OO_INSTALL_INSECURE_REGISTRIES'])) + if 'OO_INSTALL_PUDDLE_REPO' in os.environ: + # We have to double the '{' here for literals + base_inventory.write("openshift_additional_repos=[{{'id': 'ose-devel', " "'name': 'ose-devel', " - "'baseurl': 'http://buildvm-devops.usersys.redhat.com" - "/puddle/build/AtomicOpenShift/3.1/latest/RH7-RHAOS-3.1/$basearch/os', " - "'enabled': 1, 'gpgcheck': 0}]\n") - if 'OO_INSTALL_STAGE_REGISTRY' in os.environ: - base_inventory.write('oreg_url=registry.access.stage.redhat.com/openshift3/ose-${component}:${version}\n') + "'baseurl': '{}', " + "'enabled': 1, 'gpgcheck': 0}}]\n".format(os.environ['OO_INSTALL_PUDDLE_REPO'])) base_inventory.write('\n[masters]\n') masters = (host for host in hosts if host.master) -- cgit v1.2.3 From ae7757195a4230b561b14353a7024d964b5d9664 Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Thu, 5 Nov 2015 12:49:42 -0500 Subject: atomic-openshift-installer's unattended mode wasn't work with --force for all cases --- utils/src/ooinstall/cli_installer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index e4fda2813..f675efead 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -339,7 +339,10 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force): # new nodes. elif host.node: click.echo("{} is already an OpenShift Node".format(host)) - hosts_to_run_on.remove(host) + # force is only used for reinstalls so we don't want to remove + # anything. + if not force: + hosts_to_run_on.remove(host) # for unattended either continue if they force install or exit if they didn't if unattended: if not force: -- cgit v1.2.3 From a552645b05d4af2180596fb01837d0f1062b3ac5 Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Thu, 5 Nov 2015 13:11:42 -0500 Subject: Bug 1278244 - Incorrect node information gathered by atomic-openshift-installer Previously the output was a little confusing. We didn't display anything about the uninstalled hosts. --- utils/src/ooinstall/cli_installer.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'utils') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index f675efead..ff740e426 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -343,6 +343,8 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force): # anything. if not force: hosts_to_run_on.remove(host) + for new_host in set(hosts_to_run_on) - set(installed_hosts): + click.echo("{} is currently uninstalled".format(new_host)) # for unattended either continue if they force install or exit if they didn't if unattended: if not force: -- cgit v1.2.3 From 837ea49bba342aa1fa87736947979ee5235da727 Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Thu, 5 Nov 2015 13:37:51 -0500 Subject: Bug 1278244 - Previously there was no way to add a node in unattended mode TODO: We desparately need tests cases for: - interactive with no config file - interactive with config file and all installed hosts - interactive with config file and no installed hosts - interactive with config file and some installed some uninstalled hosts - unattended with config file and all installed hosts (with and without --force) - unattended with config file and no installed hosts (with and without --force) - unattended with config file and some installed some uninstalled hosts (with and without --force) --- utils/src/ooinstall/cli_installer.py | 69 +++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 25 deletions(-) (limited to 'utils') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index ff740e426..9bf3bc714 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -331,7 +331,22 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force): # Check if master or nodes already have something installed installed_hosts = get_installed_hosts(oo_cfg.hosts, callback_facts) if len(installed_hosts) > 0: - # present a message listing already installed hosts + click.echo('Installed environment detected.') + # This check has to happen before we start removing hosts later in this method + if not force: + if not unattended: + click.echo('By default the installer only adds new nodes to an installed environment.') + response = click.prompt('Do you want to (1) only add additional nodes or ' \ + '(2) perform a clean install?', type=int) + # TODO: this should be reworked with error handling. + # Click can certainly do this for us. + # This should be refactored as soon as we add a 3rd option. + if response == 1: + force = False + if response == 2: + force = True + + # present a message listing already installed hosts and remove hosts if needed for host in installed_hosts: if host.master: click.echo("{} is already an OpenShift Master".format(host)) @@ -343,33 +358,37 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force): # anything. if not force: hosts_to_run_on.remove(host) - for new_host in set(hosts_to_run_on) - set(installed_hosts): - click.echo("{} is currently uninstalled".format(new_host)) - # for unattended either continue if they force install or exit if they didn't - if unattended: - if not force: - click.echo('Installed environment detected and no additional nodes specified: ' \ - 'aborting. If you want a fresh install, use --force') - sys.exit(1) - # for attended ask the user what to do + + # Handle the cases where we know about uninstalled systems + new_hosts = set(hosts_to_run_on) - set(installed_hosts) + if len(new_hosts) > 0: + for new_host in new_hosts: + click.echo("{} is currently uninstalled".format(new_host)) + + # Fall through + click.echo('Adding additional nodes...') else: - click.echo('Installed environment detected and no additional nodes specified. ') - response = click.prompt('Do you want to (1) add more nodes or ' \ - '(2) perform a clean install?', type=int) - if response == 1: # add more nodes - new_nodes = collect_new_nodes() - - hosts_to_run_on.extend(new_nodes) - oo_cfg.hosts.extend(new_nodes) - - openshift_ansible.set_config(oo_cfg) - callback_facts, error = openshift_ansible.default_facts(oo_cfg.hosts) - if error: - click.echo("There was a problem fetching the required information. " \ - "See {} for details.".format(oo_cfg.settings['ansible_log_path'])) + if unattended: + if not force: + click.echo('Installed environment detected and no additional nodes specified: ' \ + 'aborting. If you want a fresh install, use --force') sys.exit(1) else: - pass # proceeding as normal should do a clean install + if not force: + new_nodes = collect_new_nodes() + + hosts_to_run_on.extend(new_nodes) + oo_cfg.hosts.extend(new_nodes) + + openshift_ansible.set_config(oo_cfg) + click.echo('Gathering information from hosts...') + callback_facts, error = openshift_ansible.default_facts(oo_cfg.hosts) + if error: + click.echo("There was a problem fetching the required information. " \ + "See {} for details.".format(oo_cfg.settings['ansible_log_path'])) + sys.exit(1) + else: + pass # proceeding as normal should do a clean install return hosts_to_run_on, callback_facts -- cgit v1.2.3 From a2d19f85a1e501cf7be64236b851eda898f3f51b Mon Sep 17 00:00:00 2001 From: Brenton Leanhardt Date: Thu, 5 Nov 2015 15:33:33 -0500 Subject: Bug 1278243 - Confusing prompt from atomic-openshift-installer --- utils/src/ooinstall/cli_installer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index 9bf3bc714..8bee99f90 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -371,7 +371,8 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force): if unattended: if not force: click.echo('Installed environment detected and no additional nodes specified: ' \ - 'aborting. If you want a fresh install, use --force') + 'aborting. If you want a fresh install, use ' \ + '`atomic-openshift-installer install --force`') sys.exit(1) else: if not force: -- cgit v1.2.3