summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/src/ooinstall/ansible_plugins/facts_callback.py53
-rw-r--r--utils/src/ooinstall/cli_installer.py6
-rw-r--r--utils/src/ooinstall/openshift_ansible.py7
-rw-r--r--utils/test/cli_installer_tests.py12
-rw-r--r--utils/test/fixture.py2
-rw-r--r--utils/test/oo_config_tests.py7
6 files changed, 47 insertions, 40 deletions
diff --git a/utils/src/ooinstall/ansible_plugins/facts_callback.py b/utils/src/ooinstall/ansible_plugins/facts_callback.py
index ea6ed6574..2537a099f 100644
--- a/utils/src/ooinstall/ansible_plugins/facts_callback.py
+++ b/utils/src/ooinstall/ansible_plugins/facts_callback.py
@@ -4,8 +4,10 @@
import os
import yaml
+from ansible.plugins.callback import CallbackBase
-class CallbackModule(object):
+# pylint: disable=super-init-not-called
+class CallbackModule(CallbackBase):
def __init__(self):
######################
@@ -21,68 +23,71 @@ class CallbackModule(object):
self.hosts_yaml = os.open(self.hosts_yaml_name, os.O_CREAT |
os.O_WRONLY)
- def on_any(self, *args, **kwargs):
+ def v2_on_any(self, *args, **kwargs):
pass
- def runner_on_failed(self, host, res, ignore_errors=False):
+ def v2_runner_on_failed(self, res, ignore_errors=False):
pass
- def runner_on_ok(self, host, res):
- if res['invocation']['module_args'] == 'var=result':
- facts = res['var']['result']['ansible_facts']['openshift']
+ # pylint: disable=protected-access
+ def v2_runner_on_ok(self, res):
+ abridged_result = res._result.copy()
+ # Collect facts result from playbooks/byo/openshift_facts.yml
+ if 'result' in abridged_result:
+ facts = abridged_result['result']['ansible_facts']['openshift']
hosts_yaml = {}
- hosts_yaml[host] = facts
+ hosts_yaml[res._host.get_name()] = facts
os.write(self.hosts_yaml, yaml.safe_dump(hosts_yaml))
- def runner_on_skipped(self, host, item=None):
+ def v2_runner_on_skipped(self, res):
pass
- def runner_on_unreachable(self, host, res):
+ def v2_runner_on_unreachable(self, res):
pass
- def runner_on_no_hosts(self):
+ def v2_runner_on_no_hosts(self, task):
pass
- def runner_on_async_poll(self, host, res):
+ def v2_runner_on_async_poll(self, res):
pass
- def runner_on_async_ok(self, host, res):
+ def v2_runner_on_async_ok(self, res):
pass
- def runner_on_async_failed(self, host, res):
+ def v2_runner_on_async_failed(self, res):
pass
- def playbook_on_start(self):
+ def v2_playbook_on_start(self, playbook):
pass
- def playbook_on_notify(self, host, handler):
+ def v2_playbook_on_notify(self, res, handler):
pass
- def playbook_on_no_hosts_matched(self):
+ def v2_playbook_on_no_hosts_matched(self):
pass
- def playbook_on_no_hosts_remaining(self):
+ def v2_playbook_on_no_hosts_remaining(self):
pass
- def playbook_on_task_start(self, name, is_conditional):
+ def v2_playbook_on_task_start(self, name, is_conditional):
pass
#pylint: disable=too-many-arguments
- def playbook_on_vars_prompt(self, varname, private=True, prompt=None,
+ def v2_playbook_on_vars_prompt(self, varname, private=True, prompt=None,
encrypt=None, confirm=False, salt_size=None, salt=None, default=None):
pass
- def playbook_on_setup(self):
+ def v2_playbook_on_setup(self):
pass
- def playbook_on_import_for_host(self, host, imported_file):
+ def v2_playbook_on_import_for_host(self, res, imported_file):
pass
- def playbook_on_not_import_for_host(self, host, missing_file):
+ def v2_playbook_on_not_import_for_host(self, res, missing_file):
pass
- def playbook_on_play_start(self, name):
+ def v2_playbook_on_play_start(self, play):
pass
- def playbook_on_stats(self, stats):
+ def v2_playbook_on_stats(self, stats):
pass
diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py
index 51c4c2def..67eeb97bc 100644
--- a/utils/src/ooinstall/cli_installer.py
+++ b/utils/src/ooinstall/cli_installer.py
@@ -490,7 +490,7 @@ def error_if_missing_info(oo_cfg):
'command line or in the config file: %s' % oo_cfg.config_path)
sys.exit(1)
- if 'ansible_ssh_user' not in oo_cfg.settings:
+ if 'ansible_ssh_user' not in oo_cfg.deployment.variables:
click.echo("Must specify ansible_ssh_user in configuration file.")
sys.exit(1)
@@ -586,7 +586,8 @@ https://docs.openshift.com/enterprise/latest/admin_guide/install/prerequisites.h
click.clear()
if not oo_cfg.settings.get('ansible_ssh_user', ''):
- oo_cfg.settings['ansible_ssh_user'] = get_ansible_ssh_user()
+ oo_cfg.deployment.variables['ansible_ssh_user'] = \
+ get_ansible_ssh_user()
click.clear()
if not oo_cfg.settings.get('variant', ''):
@@ -774,6 +775,7 @@ def get_hosts_to_run_on(oo_cfg, callback_facts, unattended, force, verbose):
default="/tmp/ansible.log")
@click.option('-v', '--verbose',
is_flag=True, default=False)
+@click.help_option('--help', '-h')
#pylint: disable=too-many-arguments
#pylint: disable=line-too-long
# Main CLI entrypoint, not much we can do about too many arguments.
diff --git a/utils/src/ooinstall/openshift_ansible.py b/utils/src/ooinstall/openshift_ansible.py
index f1e03f8f2..a121e2e24 100644
--- a/utils/src/ooinstall/openshift_ansible.py
+++ b/utils/src/ooinstall/openshift_ansible.py
@@ -19,8 +19,6 @@ ROLES_TO_GROUPS_MAP = {
VARIABLES_MAP = {
'ansible_ssh_user': 'ansible_ssh_user',
- 'ansible_config': 'ansible_config',
- 'ansible_log_path': 'ansible_log_path',
'deployment_type': 'deployment_type',
'master_routingconfig_subdomain':'openshift_master_default_subdomain',
'proxy_http':'openshift_http_proxy',
@@ -106,7 +104,7 @@ def write_inventory_vars(base_inventory, multiple_masters, lb):
if value:
base_inventory.write('{}={}\n'.format(inventory_var, value))
- if CFG.settings['ansible_ssh_user'] != 'root':
+ if CFG.deployment.variables['ansible_ssh_user'] != 'root':
base_inventory.write('ansible_become=yes\n')
if multiple_masters and lb is not None:
@@ -190,7 +188,8 @@ def write_host(host, role, inventory, schedulable=None):
for variable, value in host.other_variables.iteritems():
facts += " {}={}".format(variable, value)
if host.node_labels:
- facts += ' openshift_node_labels="{}"'.format(host.node_labels)
+ if role == 'node':
+ facts += ' openshift_node_labels="{}"'.format(host.node_labels)
# Distinguish between three states, no schedulability specified (use default),
diff --git a/utils/test/cli_installer_tests.py b/utils/test/cli_installer_tests.py
index 3044a2449..98e111043 100644
--- a/utils/test/cli_installer_tests.py
+++ b/utils/test/cli_installer_tests.py
@@ -101,8 +101,8 @@ MOCK_FACTS_QUICKHA = {
# Missing connect_to on some hosts:
BAD_CONFIG = """
variant: %s
-ansible_ssh_user: root
deployment:
+ ansible_ssh_user: root
hosts:
- connect_to: 10.0.0.1
ip: 10.0.0.1
@@ -132,8 +132,8 @@ deployment:
QUICKHA_CONFIG = """
variant: %s
-ansible_ssh_user: root
deployment:
+ ansible_ssh_user: root
hosts:
- connect_to: 10.0.0.1
ip: 10.0.0.1
@@ -189,8 +189,8 @@ deployment:
QUICKHA_2_MASTER_CONFIG = """
variant: %s
-ansible_ssh_user: root
deployment:
+ ansible_ssh_user: root
hosts:
- connect_to: 10.0.0.1
ip: 10.0.0.1
@@ -238,8 +238,8 @@ deployment:
QUICKHA_CONFIG_REUSED_LB = """
variant: %s
-ansible_ssh_user: root
deployment:
+ ansible_ssh_user: root
hosts:
- connect_to: 10.0.0.1
ip: 10.0.0.1
@@ -281,8 +281,8 @@ deployment:
QUICKHA_CONFIG_NO_LB = """
variant: %s
-ansible_ssh_user: root
deployment:
+ ansible_ssh_user: root
hosts:
- connect_to: 10.0.0.1
ip: 10.0.0.1
@@ -323,8 +323,8 @@ deployment:
QUICKHA_CONFIG_PRECONFIGURED_LB = """
variant: %s
-ansible_ssh_user: root
deployment:
+ ansible_ssh_user: root
hosts:
- connect_to: 10.0.0.1
ip: 10.0.0.1
diff --git a/utils/test/fixture.py b/utils/test/fixture.py
index 006df739b..152c06da8 100644
--- a/utils/test/fixture.py
+++ b/utils/test/fixture.py
@@ -11,9 +11,9 @@ from click.testing import CliRunner
SAMPLE_CONFIG = """
variant: %s
variant_version: 3.2
-ansible_ssh_user: root
master_routingconfig_subdomain: example.com
deployment:
+ ansible_ssh_user: root
hosts:
- connect_to: 10.0.0.1
ip: 10.0.0.1
diff --git a/utils/test/oo_config_tests.py b/utils/test/oo_config_tests.py
index c19fe9e0d..10439c9ae 100644
--- a/utils/test/oo_config_tests.py
+++ b/utils/test/oo_config_tests.py
@@ -13,8 +13,8 @@ from ooinstall.oo_config import OOConfig, Host, OOConfigInvalidHostError
SAMPLE_CONFIG = """
variant: openshift-enterprise
variant_version: 3.2
-ansible_ssh_user: root
deployment:
+ ansible_ssh_user: root
hosts:
- connect_to: master-private.example.com
ip: 10.0.0.1
@@ -65,6 +65,7 @@ validated_facts:
CONFIG_INCOMPLETE_FACTS = """
deployment:
+ ansible_ssh_user: root
hosts:
- connect_to: 10.0.0.1
ip: 10.0.0.1
@@ -90,8 +91,8 @@ deployment:
CONFIG_BAD = """
variant: openshift-enterprise
-ansible_ssh_user: root
deployment:
+ ansible_ssh_user: root
hosts:
- connect_to: master-private.example.com
ip: 10.0.0.1
@@ -212,7 +213,7 @@ class OOConfigTests(OOInstallFixture):
self.assertTrue('hostname' in h)
self.assertTrue('public_hostname' in h)
- self.assertTrue('ansible_ssh_user' in written_config)
+ self.assertTrue('ansible_ssh_user' in written_config['deployment'])
self.assertTrue('variant' in written_config)
self.assertEquals('v2', written_config['version'])