mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Clean up inventory generation in ansible-test. (#20313)
This commit is contained in:
parent
1f1379ea61
commit
e2bd71ac02
1 changed files with 26 additions and 13 deletions
|
@ -238,12 +238,18 @@ def network_inventory(remotes):
|
||||||
groups = dict([(remote.platform, []) for remote in remotes])
|
groups = dict([(remote.platform, []) for remote in remotes])
|
||||||
|
|
||||||
for remote in remotes:
|
for remote in remotes:
|
||||||
|
options = dict(
|
||||||
|
ansible_host=remote.connection.hostname,
|
||||||
|
ansible_user=remote.connection.username,
|
||||||
|
ansible_connection='network_cli',
|
||||||
|
ansible_ssh_private_key_file=remote.ssh_key.key,
|
||||||
|
ansible_network_os=remote.platform,
|
||||||
|
)
|
||||||
|
|
||||||
groups[remote.platform].append(
|
groups[remote.platform].append(
|
||||||
'%s ansible_host=%s ansible_user=%s ansible_connection=network_cli ansible_ssh_private_key_file=%s' % (
|
'%s %s' % (
|
||||||
remote.name.replace('.', '_'),
|
remote.name.replace('.', '_'),
|
||||||
remote.connection.hostname,
|
' '.join('%s="%s"' % (k, options[k]) for k in sorted(options)),
|
||||||
remote.connection.username,
|
|
||||||
remote.ssh_key.key,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -319,15 +325,22 @@ def windows_inventory(remotes):
|
||||||
:type remotes: list[AnsibleCoreCI]
|
:type remotes: list[AnsibleCoreCI]
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
hosts = ['%s ansible_host=%s ansible_user=%s ansible_password="%s" ansible_port=%s' %
|
hosts = []
|
||||||
(
|
|
||||||
remote.name.replace('/', '_'),
|
for remote in remotes:
|
||||||
remote.connection.hostname,
|
options = dict(
|
||||||
remote.connection.username,
|
ansible_host=remote.connection.hostname,
|
||||||
remote.connection.password,
|
ansible_user=remote.connection.username,
|
||||||
remote.connection.port,
|
ansible_password=remote.connection.password,
|
||||||
|
ansible_port=remote.connection.port,
|
||||||
|
)
|
||||||
|
|
||||||
|
hosts.append(
|
||||||
|
'%s %s' % (
|
||||||
|
remote.name.replace('/', '_'),
|
||||||
|
' '.join('%s="%s"' % (k, options[k]) for k in sorted(options)),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
for remote in remotes]
|
|
||||||
|
|
||||||
template = """
|
template = """
|
||||||
[windows]
|
[windows]
|
||||||
|
|
Loading…
Reference in a new issue