Skip to content

Commit cb9b9d1

Browse files
committed
Ansible inventory: Pick transport and devtype from device section of suzieq inventory
Signed-off-by: Dinesh Dutt <[email protected]>
1 parent c782691 commit cb9b9d1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

suzieq/poller/controller/source/ansible.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,17 @@ def _get_inventory(self) -> Dict:
108108
if 'ansible_password' in entry:
109109
password = entry['ansible_password']
110110

111-
# Retrieve password information
112111
devtype = None
113-
if entry.get('ansible_network_os') in ['eos', 'panos']:
114-
devtype = entry.get('ansible_network_os')
112+
if entry.get('ansible_network_os') in ['panos']:
113+
devtype = 'panos'
115114
transport = 'https'
116115
port = 443
117116
else:
118-
transport = 'ssh'
119117
port = entry.get('ansible_port', 22)
118+
if port == 443:
119+
transport = 'https'
120+
else:
121+
transport = 'ssh'
120122

121123
# Get keyfile
122124
keyfile = entry.get('ansible_ssh_private_key_file', None)
@@ -130,12 +132,12 @@ def _get_inventory(self) -> Dict:
130132
host = {
131133
'address': ansible_host,
132134
'username': ansible_user,
133-
'port': port,
134135
'password': password,
135-
'transport': transport,
136-
'devtype': devtype,
137136
'namespace': self._namespace,
138137
'ssh_keyfile': keyfile,
138+
'port': port,
139+
'devtype': devtype,
140+
'transport': transport,
139141
'hostname': None
140142
}
141143
out_inv[f"{self._namespace}.{ansible_host}.{port}"] = host

0 commit comments

Comments
 (0)