ssh_config: Add 'forwardagent' option (#3495)

* Integration Tests for Options added, includes 'proxycommand'

* New option 'forwardagent' added to integration tests

* Missing double quotes added to 'forwardagent' values to enforce handling as string

* New option 'forwardagent' added

* yamllint error resolved

* 'forwardagent' type changed from str to choices (yes/no)

* Changelog added

* correct typo

Co-authored-by: Felix Fontein <felix@fontein.de>

* version info added to new option

Co-authored-by: Felix Fontein <felix@fontein.de>

* fix(ssh_config): option name to snake_case, type str to bool

* fix(ssh_config): convert bool true/false to str yes/no

* fix(ssh_config): rename option to 'forward_agent' in integration test

* fix(ssh_config): args key 'forwardagent' renamed to 'forward_agent'

* fix(ssh_config): 'else' replaced with 'if' statement to cover case when value is 'None'

* increase version_added to 4.0.0

Co-authored-by: Felix Fontein <felix@fontein.de>

* simplify if statement for True/False to yes/no mapping

Co-authored-by: Felix Fontein <felix@fontein.de>

* update comment to better describe functionality

Co-authored-by: Felix Fontein <felix@fontein.de>

* fix(ssh_config): avoid overwrite of existing option in case of None value

* test(ssh_config): case added to verify no changes on existing option if not given in playbook

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Dominik Wombacher 2021-10-14 21:24:23 +02:00 committed by GitHub
parent 18f8195983
commit 71ea99d10f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 212 additions and 0 deletions

View file

@ -76,6 +76,11 @@ options:
description:
- Sets the C(ProxyCommand) option.
type: str
forward_agent:
description:
- Sets the C(ForwardAgent) option.
type: bool
version_added: 4.0.0
ssh_config_file:
description:
- SSH config file.
@ -203,6 +208,12 @@ class SSHConfig():
proxycommand=self.params.get('proxycommand'),
)
# Convert True / False to 'yes' / 'no' for usage in ssh_config
if self.params['forward_agent'] is True:
args['forward_agent'] = 'yes'
if self.params['forward_agent'] is False:
args['forward_agent'] = 'no'
config_changed = False
hosts_changed = []
hosts_change_diff = []
@ -288,6 +299,7 @@ def main():
identity_file=dict(type='path'),
port=dict(type='str'),
proxycommand=dict(type='str', default=None),
forward_agent=dict(type='bool'),
remote_user=dict(type='str'),
ssh_config_file=dict(default=None, type='path'),
state=dict(type='str', default='present', choices=['present', 'absent']),