Prechádzať zdrojové kódy

Merge pull request #2278 from smunilla/BZ1353162

a-o-i: Move ansible_ssh_user to deployment
Scott Dodson 8 rokov pred
rodič
commit
b2c6abedc5

+ 3 - 2
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', ''):

+ 1 - 3
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:

+ 6 - 6
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

+ 1 - 1
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

+ 4 - 3
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'])