summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorDevan Goodwin <dgoodwin@redhat.com>2015-11-03 14:37:27 -0400
committerDevan Goodwin <dgoodwin@redhat.com>2015-11-03 14:37:27 -0400
commit9d05b8c192a462c9d6a37586fc27cbd93f80ff65 (patch)
tree85696c092269859010348ede6fe80ba4c1124543 /utils
parentab83e16dbed3eb5cf1dff96992509439d2739550 (diff)
parent3d3f2875bb89cdbdeadd7da4868355669ba12122 (diff)
downloadopenshift-9d05b8c192a462c9d6a37586fc27cbd93f80ff65.tar.gz
openshift-9d05b8c192a462c9d6a37586fc27cbd93f80ff65.tar.bz2
openshift-9d05b8c192a462c9d6a37586fc27cbd93f80ff65.tar.xz
openshift-9d05b8c192a462c9d6a37586fc27cbd93f80ff65.zip
Merge remote-tracking branch 'upstream/master' into upgrade
Diffstat (limited to 'utils')
-rw-r--r--utils/src/ooinstall/cli_installer.py34
-rw-r--r--utils/src/ooinstall/openshift_ansible.py (renamed from utils/src/ooinstall/install_transactions.py)14
-rw-r--r--utils/src/ooinstall/variants.py2
-rw-r--r--utils/test/cli_installer_tests.py40
4 files changed, 51 insertions, 39 deletions
diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py
index 2fc7a872f..25705ec7a 100644
--- a/utils/src/ooinstall/cli_installer.py
+++ b/utils/src/ooinstall/cli_installer.py
@@ -6,7 +6,7 @@ import click
import os
import re
import sys
-from ooinstall import install_transactions
+from ooinstall import openshift_ansible
from ooinstall import OOConfig
from ooinstall.oo_config import Host
from ooinstall.variants import find_variant, get_variant_version_combos
@@ -95,7 +95,7 @@ The OpenShift Node provides the runtime environments for containers. It will
host the required services to be managed by the Master.
http://docs.openshift.com/enterprise/latest/architecture/infrastructure_components/kubernetes_infrastructure.html#master
-http://docs.openshift.com/enterprise/3.0/architecture/infrastructure_components/kubernetes_infrastructure.html#node
+http://docs.openshift.com/enterprise/latest/architecture/infrastructure_components/kubernetes_infrastructure.html#node
"""
click.echo(message)
@@ -191,7 +191,7 @@ Notes:
facts_confirmed = click.confirm("Do the above facts look correct?")
if not facts_confirmed:
message = """
-Edit %s with the desired values and re-run with --unattended .
+Edit %s with the desired values and rerun atomic-openshift-installer with --unattended .
""" % oo_cfg.config_path
click.echo(message)
# Make sure we actually write out the config file.
@@ -357,8 +357,8 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force):
hosts_to_run_on.extend(new_nodes)
oo_cfg.hosts.extend(new_nodes)
- install_transactions.set_config(oo_cfg)
- callback_facts, error = install_transactions.default_facts(oo_cfg.hosts)
+ 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']))
@@ -379,14 +379,14 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force):
readable=True),
default=None)
@click.option('--ansible-playbook-directory',
- '-a',
- type=click.Path(exists=True,
- file_okay=False,
- dir_okay=True,
- writable=False,
- readable=True),
- # callback=validate_ansible_dir,
- envvar='OO_ANSIBLE_PLAYBOOK_DIRECTORY')
+ '-a',
+ type=click.Path(exists=True,
+ file_okay=False,
+ dir_okay=True,
+ readable=True),
+ # callback=validate_ansible_dir,
+ default='/usr/share/openshift-ansible/',
+ envvar='OO_ANSIBLE_PLAYBOOK_DIRECTORY')
@click.option('--ansible-config',
type=click.Path(file_okay=True,
dir_okay=False,
@@ -434,7 +434,7 @@ def cli(ctx, unattended, configuration, ansible_playbook_directory, ansible_conf
oo_cfg.settings['ansible_log_path'] = ctx.obj['ansible_log_path']
ctx.obj['oo_cfg'] = oo_cfg
- install_transactions.set_config(oo_cfg)
+ openshift_ansible.set_config(oo_cfg)
@click.command()
@@ -456,7 +456,7 @@ def uninstall(ctx):
click.echo("Uninstall cancelled.")
sys.exit(0)
- install_transactions.run_uninstall_playbook()
+ openshift_ansible.run_uninstall_playbook()
@click.command()
@@ -509,7 +509,7 @@ def install(ctx, force):
oo_cfg = get_missing_info_from_user(oo_cfg)
click.echo('Gathering information from hosts...')
- callback_facts, error = install_transactions.default_facts(oo_cfg.hosts)
+ callback_facts, error = openshift_ansible.default_facts(oo_cfg.hosts)
if error:
click.echo("There was a problem fetching the required information. " \
"Please see {} for details.".format(oo_cfg.settings['ansible_log_path']))
@@ -536,7 +536,7 @@ If changes are needed to the values recorded by the installer please update {}.
if not ctx.obj['unattended']:
confirm_continue(message)
- error = install_transactions.run_main_playbook(oo_cfg.hosts,
+ error = openshift_ansible.run_main_playbook(oo_cfg.hosts,
hosts_to_run_on)
if error:
# The bootstrap script will print out the log location.
diff --git a/utils/src/ooinstall/install_transactions.py b/utils/src/ooinstall/openshift_ansible.py
index 0754b8ab6..9d801cabe 100644
--- a/utils/src/ooinstall/install_transactions.py
+++ b/utils/src/ooinstall/openshift_ansible.py
@@ -2,7 +2,9 @@
# 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 sys
import os
import yaml
from ooinstall.variants import find_variant
@@ -15,13 +17,15 @@ 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')
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'],
@@ -40,6 +44,14 @@ 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', '--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')
masters = (host for host in hosts if host.master)
for master in masters:
diff --git a/utils/src/ooinstall/variants.py b/utils/src/ooinstall/variants.py
index 219af6cd2..3bb61dddb 100644
--- a/utils/src/ooinstall/variants.py
+++ b/utils/src/ooinstall/variants.py
@@ -41,7 +41,7 @@ OSE = Variant('openshift-enterprise', 'OpenShift Enterprise',
]
)
-AEP = Variant('atomic-enterprise', 'Atomic OpenShift Enterprise',
+AEP = Variant('atomic-enterprise', 'Atomic Enterprise Platform',
[
Version('3.1', 'atomic-enterprise')
]
diff --git a/utils/test/cli_installer_tests.py b/utils/test/cli_installer_tests.py
index 1f74b5b15..b183f0acb 100644
--- a/utils/test/cli_installer_tests.py
+++ b/utils/test/cli_installer_tests.py
@@ -102,8 +102,8 @@ class UnattendedCliTests(OOCliFixture):
OOCliFixture.setUp(self)
self.cli_args.append("-u")
- @patch('ooinstall.install_transactions.run_main_playbook')
- @patch('ooinstall.install_transactions.load_system_facts')
+ @patch('ooinstall.openshift_ansible.run_main_playbook')
+ @patch('ooinstall.openshift_ansible.load_system_facts')
def test_cfg_full_run(self, load_facts_mock, run_playbook_mock):
load_facts_mock.return_value = (MOCK_FACTS, 0)
run_playbook_mock.return_value = 0
@@ -133,8 +133,8 @@ class UnattendedCliTests(OOCliFixture):
self.assertEquals(3, len(hosts))
self.assertEquals(3, len(hosts_to_run_on))
- @patch('ooinstall.install_transactions.run_main_playbook')
- @patch('ooinstall.install_transactions.load_system_facts')
+ @patch('ooinstall.openshift_ansible.run_main_playbook')
+ @patch('ooinstall.openshift_ansible.load_system_facts')
def test_inventory_write(self, load_facts_mock, run_playbook_mock):
# Add an ssh user so we can verify it makes it to the inventory file:
@@ -172,8 +172,8 @@ class UnattendedCliTests(OOCliFixture):
self.assertTrue('openshift_hostname' in master_line)
self.assertTrue('openshift_public_hostname' in master_line)
- @patch('ooinstall.install_transactions.run_main_playbook')
- @patch('ooinstall.install_transactions.load_system_facts')
+ @patch('ooinstall.openshift_ansible.run_main_playbook')
+ @patch('ooinstall.openshift_ansible.load_system_facts')
def test_variant_version_latest_assumed(self, load_facts_mock,
run_playbook_mock):
load_facts_mock.return_value = (MOCK_FACTS, 0)
@@ -199,8 +199,8 @@ class UnattendedCliTests(OOCliFixture):
self.assertEquals('openshift-enterprise',
inventory.get('OSEv3:vars', 'deployment_type'))
- @patch('ooinstall.install_transactions.run_main_playbook')
- @patch('ooinstall.install_transactions.load_system_facts')
+ @patch('ooinstall.openshift_ansible.run_main_playbook')
+ @patch('ooinstall.openshift_ansible.load_system_facts')
def test_variant_version_preserved(self, load_facts_mock,
run_playbook_mock):
load_facts_mock.return_value = (MOCK_FACTS, 0)
@@ -227,8 +227,8 @@ class UnattendedCliTests(OOCliFixture):
self.assertEquals('enterprise',
inventory.get('OSEv3:vars', 'deployment_type'))
- @patch('ooinstall.install_transactions.run_ansible')
- @patch('ooinstall.install_transactions.load_system_facts')
+ @patch('ooinstall.openshift_ansible.run_ansible')
+ @patch('ooinstall.openshift_ansible.load_system_facts')
def test_no_ansible_config_specified(self, load_facts_mock, run_ansible_mock):
load_facts_mock.return_value = (MOCK_FACTS, 0)
run_ansible_mock.return_value = 0
@@ -238,8 +238,8 @@ class UnattendedCliTests(OOCliFixture):
self._ansible_config_test(load_facts_mock, run_ansible_mock,
config, None, None)
- @patch('ooinstall.install_transactions.run_ansible')
- @patch('ooinstall.install_transactions.load_system_facts')
+ @patch('ooinstall.openshift_ansible.run_ansible')
+ @patch('ooinstall.openshift_ansible.load_system_facts')
def test_ansible_config_specified_cli(self, load_facts_mock, run_ansible_mock):
load_facts_mock.return_value = (MOCK_FACTS, 0)
run_ansible_mock.return_value = 0
@@ -250,8 +250,8 @@ class UnattendedCliTests(OOCliFixture):
self._ansible_config_test(load_facts_mock, run_ansible_mock,
config, ansible_config, ansible_config)
- @patch('ooinstall.install_transactions.run_ansible')
- @patch('ooinstall.install_transactions.load_system_facts')
+ @patch('ooinstall.openshift_ansible.run_ansible')
+ @patch('ooinstall.openshift_ansible.load_system_facts')
def test_ansible_config_specified_in_installer_config(self,
load_facts_mock, run_ansible_mock):
@@ -389,8 +389,8 @@ class AttendedCliTests(OOCliFixture):
self.assertTrue('public_ip' in h)
self.assertTrue('public_hostname' in h)
- @patch('ooinstall.install_transactions.run_main_playbook')
- @patch('ooinstall.install_transactions.load_system_facts')
+ @patch('ooinstall.openshift_ansible.run_main_playbook')
+ @patch('ooinstall.openshift_ansible.load_system_facts')
def test_full_run(self, load_facts_mock, run_playbook_mock):
load_facts_mock.return_value = (MOCK_FACTS, 0)
run_playbook_mock.return_value = 0
@@ -413,8 +413,8 @@ class AttendedCliTests(OOCliFixture):
written_config = self._read_yaml(self.config_file)
self._verify_config_hosts(written_config, 3)
- @patch('ooinstall.install_transactions.run_main_playbook')
- @patch('ooinstall.install_transactions.load_system_facts')
+ @patch('ooinstall.openshift_ansible.run_main_playbook')
+ @patch('ooinstall.openshift_ansible.load_system_facts')
def test_add_nodes(self, load_facts_mock, run_playbook_mock):
# Modify the mock facts to return a version indicating OpenShift
@@ -446,8 +446,8 @@ class AttendedCliTests(OOCliFixture):
written_config = self._read_yaml(self.config_file)
self._verify_config_hosts(written_config, 3)
- @patch('ooinstall.install_transactions.run_main_playbook')
- @patch('ooinstall.install_transactions.load_system_facts')
+ @patch('ooinstall.openshift_ansible.run_main_playbook')
+ @patch('ooinstall.openshift_ansible.load_system_facts')
def test_fresh_install_with_config(self, load_facts_mock, run_playbook_mock):
load_facts_mock.return_value = (MOCK_FACTS, 0)
run_playbook_mock.return_value = 0