Skip to content
This repository was archived by the owner on Jan 30, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions library/ssh_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,43 +687,52 @@ def change_host(options, **kwargs):
del options[k]
changed = True
elif options.get(k) != v:
options[k] = v
options[k] = 'yes' if v == 'True' else v
changed = True

return changed, options


def main():
module = AnsibleModule(
argument_spec=dict(
state=dict(default='present', choices=['present', 'absent']),
host=dict(required=True, type='str'),
hostname=dict(type='str'),
port=dict(type='str'),
remote_user=dict(type='str'),
identity_file=dict(type='str'),
user=dict(default=None, type='str'),
user_known_hosts_file=dict(default=None, type='str'),
proxycommand=dict(default=None, type='str'),
strict_host_key_checking=dict(
default=None,
choices=['yes', 'no', 'ask']
),
argument_spec = {}
for key in SSH_KEYWORDS:
argument_spec[key.lower()] = dict(required=False, type='str')
argument_spec.update(dict(
state=dict(default='present', choices=['present', 'absent']),
host=dict(required=True, type='str'),
hostname=dict(type='str'),
port=dict(type='str'),
remote_user=dict(type='str'),
identity_file=dict(type='str'),
user=dict(default=None, type='str'),
user_known_hosts_file=dict(default=None, type='str'),
proxycommand=dict(default=None, type='str'),
strict_host_key_checking=dict(
default=None,
choices=['yes', 'no', 'ask']
),
))
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True
)

user = module.params.get('user')
host = module.params.get('host')
args = dict(
args = {}
for key in SSH_KEYWORDS:
key_lower = key.lower()
if key_lower in module.params:
args[key_lower] = module.params.get(key_lower)
args.update(dict(
hostname=module.params.get('hostname'),
port=module.params.get('port'),
identity_file=module.params.get('identity_file'),
user=module.params.get('remote_user'),
strict_host_key_checking=module.params.get('strict_host_key_checking'),
user_known_hosts_file=module.params.get('user_known_hosts_file'),
proxycommand=module.params.get('proxycommand'),
)
))
state = module.params.get('state')
config_changed = False
hosts_changed = []
Expand Down