From b41bca63682e11e2522540567c2bcf1d146e5d03 Mon Sep 17 00:00:00 2001 From: Samuel Munilla Date: Fri, 30 Oct 2015 09:50:11 -0400 Subject: oo-install: Support running on the host to be deployed This adds a check to see if the host the installer is running on is one of the hosts to be installed and sets i ansible_connection=local ansible_sudo=no in the inventory file. --- utils/src/ooinstall/openshift_ansible.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'utils') diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index 3306271c8..bb1003ad6 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -2,6 +2,7 @@ # repo. We will work on these over time. # pylint: disable=bad-continuation,missing-docstring,no-self-use,invalid-name,global-statement,global-variable-not-assigned +import socket import subprocess import os import yaml @@ -16,6 +17,8 @@ def set_config(cfg): def generate_inventory(hosts): print 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') @@ -41,6 +44,10 @@ 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 for host in hosts): + base_inventory.write("ansible_connection=local\n") + base_inventory.write("ansible_sudo=no\n") + base_inventory.write('\n[masters]\n') masters = (host for host in hosts if host.master) for master in masters: -- cgit v1.2.3 From ef6df7220673de40d1c9854e105d7f134232e733 Mon Sep 17 00:00:00 2001 From: Samuel Munilla Date: Fri, 30 Oct 2015 13:01:09 -0400 Subject: ooinstall: Update local install check Update to check both hostname and public_hostname. Remove ansible_sudo=no as I failed to notice we were already checking if ansible_ssh_user == 'root' and setting it there. --- utils/src/ooinstall/openshift_ansible.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index bb1003ad6..4c9d30718 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -44,9 +44,9 @@ 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 for host in hosts): + if any(host.hostname == installer_host or host.public_hostname == installer_host + for host in hosts): base_inventory.write("ansible_connection=local\n") - base_inventory.write("ansible_sudo=no\n") base_inventory.write('\n[masters]\n') masters = (host for host in hosts if host.master) -- cgit v1.2.3 From 3574beed2b43d5fafbf0b833c1f39bb09cdf947f Mon Sep 17 00:00:00 2001 From: Samuel Munilla Date: Mon, 2 Nov 2015 08:32:17 -0500 Subject: ooinstall: Add check for nopwd sudo --- utils/src/ooinstall/openshift_ansible.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'utils') diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py index 4c9d30718..0def72cfd 100644 --- a/utils/src/ooinstall/openshift_ansible.py +++ b/utils/src/ooinstall/openshift_ansible.py @@ -4,6 +4,7 @@ import socket import subprocess +import sys import os import yaml from ooinstall.variants import find_variant @@ -25,7 +26,7 @@ def generate_inventory(hosts): base_inventory.write('\n[OSEv3:vars]\n') base_inventory.write('ansible_ssh_user={}\n'.format(CFG.settings['ansible_ssh_user'])) if CFG.settings['ansible_ssh_user'] != 'root': - base_inventory.write('ansible_sudo=true\n') + base_inventory.write('ansible_become=true\n') # Find the correct deployment type for ansible: ver = find_variant(CFG.settings['variant'], @@ -46,6 +47,10 @@ 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']) + 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') -- cgit v1.2.3