From 234ba33fb3c2c17ab4d14dab7aaae189b5d13bd1 Mon Sep 17 00:00:00 2001 From: Xavier Barbosa Date: Tue, 1 Mar 2016 12:02:59 -0800 Subject: [PATCH] allow True, False in strict_host_key_checking --- library/ssh_config.py | 6 +++++- test/roles/normal-user/tasks/main.yml | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/library/ssh_config.py b/library/ssh_config.py index 7ff3a3b..d0b9909 100755 --- a/library/ssh_config.py +++ b/library/ssh_config.py @@ -641,6 +641,10 @@ def dump(self): key, value_ ) host_item_content += sub_content + elif value is True: + host_item_content += " {0} yes\n".format(key) + elif value is False: + host_item_content += " {0} no\n".format(key) else: host_item_content += " {0} {1}\n".format( key, value @@ -707,7 +711,7 @@ def main(): proxycommand=dict(default=None, type='str'), strict_host_key_checking=dict( default=None, - choices=['yes', 'no', 'ask'] + choices=['yes', 'no', 'ask', True, False] ), ), supports_check_mode=True diff --git a/test/roles/normal-user/tasks/main.yml b/test/roles/normal-user/tasks/main.yml index 568887d..b15b2c9 100644 --- a/test/roles/normal-user/tasks/main.yml +++ b/test/roles/normal-user/tasks/main.yml @@ -66,3 +66,24 @@ host=example.com strict_host_key_checking=yes - include: _assert.yml option=stricthostkeychecking value=yes + +- name: Test host key checking with lax config + ssh_config: + user: vagrant + host: example.com + strict_host_key_checking: true +- include: _assert.yml option=stricthostkeychecking value=yes + +- name: Test no host key checking with lax config + ssh_config: + user: vagrant + host: example.com + strict_host_key_checking: false +- include: _assert.yml option=stricthostkeychecking value=no + +- name: Test ask host key checking with lax config + ssh_config: + user: vagrant + host: example.com + strict_host_key_checking: ask +- include: _assert.yml option=stricthostkeychecking value=ask