Fix bug in apex inventory 59/38959/3
authorYujun Zhang <zhang.yujunz@zte.com.cn>
Wed, 9 Aug 2017 07:20:24 +0000 (15:20 +0800)
committerYujun Zhang <zhang.yujunz@zte.com.cn>
Wed, 9 Aug 2017 07:39:39 +0000 (15:39 +0800)
The default user for overcloud should be heat-admin

JIRA: QTIP-267
Change-Id: Ie868b1a925ca0eaa0292bdfb99d0e328e820f8aa
Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
qtip/ansible_library/modules/apex_generate_inventory.py
qtip/ansible_library/modules/fuel.py
resources/ansible_roles/qtip-generator/files/compute/templates/ssh.cfg
tests/unit/ansible_library/modules/apex_generate_inventory_test.py
tests/unit/ansible_library/modules/fuel_test.py

index b1cc976..0c9500f 100644 (file)
@@ -79,7 +79,8 @@ def generate_inventory(baremetal_info, server_info):
                     node_ip = re.findall('.+=(\d+.\d+.\d+.\d+)$', server['Networks'])[0]
                     hosts[role].append(node_ip)
                     # To match ssh.cfg.j2 template
-                    hosts_meta[node_ip] = {'ansible_ssh_host': node_ip}
+                    hosts_meta[node_ip] = {'ansible_ssh_host': node_ip,
+                                           'ansible_user': 'heat-admin'}
 
     for host in hosts:
         hosts[host].sort()
index 5ec45dd..04154e3 100644 (file)
@@ -98,7 +98,8 @@ def generate_inventory(nodes):
             'ip': node['ip'],
             'mac': node['mac'],
             'cluster': cluster_id,
-            'ansible_ssh_host': node['ip']
+            'ansible_ssh_host': node['ip'],
+            'ansible_user': 'root'
         }
         hosts_meta[hostname] = node_meta
 
index f0e33fd..1b7c018 100644 (file)
@@ -9,7 +9,7 @@
 {% for (name, host) in hosts_meta.items() %}
 Host {{ name }}
   HostName {{ host.ansible_ssh_host }}
-  User root
+      User {{ host.ansible_user }}
   ProxyCommand ssh -o 'ForwardAgent yes' {{ installer_host }} 'ssh-add && nc %h %p'
 
 {% endfor %}
index 7df9d35..668a015 100644 (file)
@@ -23,8 +23,8 @@ def test_generate_inventory(data_root):
         u'compute': [u'192.0.2.5', u'192.0.2.6'],
         u'control': [u'192.0.2.7', u'192.0.2.8', u'192.0.2.9']}
     assert dict(inventory['hosts_meta']) == {
-        u'192.0.2.5': {'ansible_ssh_host': u'192.0.2.5'},
-        u'192.0.2.6': {'ansible_ssh_host': u'192.0.2.6'},
-        u'192.0.2.7': {'ansible_ssh_host': u'192.0.2.7'},
-        u'192.0.2.8': {'ansible_ssh_host': u'192.0.2.8'},
-        u'192.0.2.9': {'ansible_ssh_host': u'192.0.2.9'}}
+        u'192.0.2.5': {'ansible_ssh_host': u'192.0.2.5', 'ansible_user': 'heat-admin'},
+        u'192.0.2.6': {'ansible_ssh_host': u'192.0.2.6', 'ansible_user': 'heat-admin'},
+        u'192.0.2.7': {'ansible_ssh_host': u'192.0.2.7', 'ansible_user': 'heat-admin'},
+        u'192.0.2.8': {'ansible_ssh_host': u'192.0.2.8', 'ansible_user': 'heat-admin'},
+        u'192.0.2.9': {'ansible_ssh_host': u'192.0.2.9', 'ansible_user': 'heat-admin'}}
index e004fc1..9ec1806 100644 (file)
@@ -34,21 +34,21 @@ def test_generate_inventory(data_root):
                            u'node-27'],
         u'mongo': [u'node-24']}
     assert dict(inventory['hosts_meta']) == {
-        u'node-23': {'ansible_ssh_host': u'10.20.11.10', 'cluster': 4, 'ip': u'10.20.11.10',
+        u'node-23': {'ansible_ssh_host': u'10.20.11.10', 'ansible_user': 'root', 'cluster': 4, 'ip': u'10.20.11.10',
                      'mac': u'74:4a:a4:01:71:61', 'name': u'Untitled (71:61)', 'online': True, 'os_platform': u'ubuntu',
                      'status': u'ready'},
-        u'node-24': {'ansible_ssh_host': u'10.20.11.11', 'cluster': 4, 'ip': u'10.20.11.11',
+        u'node-24': {'ansible_ssh_host': u'10.20.11.11', 'ansible_user': 'root', 'cluster': 4, 'ip': u'10.20.11.11',
                      'mac': u'74:4a:a4:01:73:50', 'name': u'Untitled (73:50)', 'online': True, 'os_platform': u'ubuntu',
                      'status': u'ready'},
-        u'node-25': {'ansible_ssh_host': u'10.20.11.12', 'cluster': 4, 'ip': u'10.20.11.12',
+        u'node-25': {'ansible_ssh_host': u'10.20.11.12', 'ansible_user': 'root', 'cluster': 4, 'ip': u'10.20.11.12',
                      'mac': u'74:4a:a4:00:d8:76', 'name': u'Untitled (d8:76)', 'online': True, 'os_platform': u'ubuntu',
                      'status': u'ready'},
-        u'node-26': {'ansible_ssh_host': u'10.20.11.15', 'cluster': 4, 'ip': u'10.20.11.15',
+        u'node-26': {'ansible_ssh_host': u'10.20.11.15', 'ansible_user': 'root', 'cluster': 4, 'ip': u'10.20.11.15',
                      'mac': u'74:4a:a4:01:61:ae', 'name': u'Untitled (61:ae)', 'online': True, 'os_platform': u'ubuntu',
                      'status': u'ready'},
-        u'node-27': {'ansible_ssh_host': u'10.20.11.13', 'cluster': 4, 'ip': u'10.20.11.13',
+        u'node-27': {'ansible_ssh_host': u'10.20.11.13', 'ansible_user': 'root', 'cluster': 4, 'ip': u'10.20.11.13',
                      'mac': u'74:4a:a4:01:82:c0', 'name': u'Untitled (82:c0)', 'online': True, 'os_platform': u'ubuntu',
                      'status': u'ready'},
-        u'node-28': {'ansible_ssh_host': u'10.20.11.14', 'cluster': 4, 'ip': u'10.20.11.14',
+        u'node-28': {'ansible_ssh_host': u'10.20.11.14', 'ansible_user': 'root', 'cluster': 4, 'ip': u'10.20.11.14',
                      'mac': u'74:4a:a4:01:74:63', 'name': u'Untitled (74:63)', 'online': True, 'os_platform': u'ubuntu',
                      'status': u'ready'}}