community.general/lib/ansible
Marius Gedminas 2efb692cc4 known_hosts: support --diff (#20349)
* known_hosts: support --diff

* known_hosts: support --diff also without --check

* Add unit tests and fix incorrect diff in one corner case

Tests are good!

* Refactor for readability

* Python 3 compat

* More Python 3 compat

* Add an integration test for known_hosts

* Handle ssh-keygen -HF returning non-zero exit code

AFAICT this is a bug in ssh-keygen in some newer OpenSSH versions
(>= 6.4 probably; see commit dd9d5cc670):
when you invoke ssh-keygen with -H and -F <host> options, it always
returns exit code 1.  This is because in ssh-keygen.c there's a function
do_known_hosts() which calls

  exit (find_host && !ctx.found_key);

at the end, and find_host is 1 (because we passed -F on the command line),
but ctx.found_key is always 0.  Why is found_key always 0?  Because the
callback passed to hostkeys_foreach(), which is known_hosts_hash(),
never bothers to set found_key to 1.

* This test does not need root

* Avoid ssh-ed25519 keys in sample known_hosts file

Older versions of OpenSSH do not like them and ssh-keygen -HF
aborts with an error when it sees such keys:

  line 5 invalid key: example.net...
  /root/ansible_testing/known_hosts is not a valid known_hosts file.

* Fix Python 3 errors

Specifically, the default mode of tempfile.NamedTemporaryFile is 'w+b',
which means Python 3 wants us to write bytes objects to it -- but the
keys we have are all unicode strings.
2017-02-08 09:56:03 -05:00
..
cli PEP 8 indent cleanup. (#20800) 2017-01-29 07:28:53 +00:00
compat Fix typo when choosing KqueueSelector 2017-02-06 08:46:58 -08:00
config Making the switch to v2 2015-05-03 21:47:26 -05:00
errors adds feature to all modules to be run locally (#18763) 2016-12-15 15:47:29 -05:00
executor refactoring async 2017-02-06 19:32:00 -05:00
galaxy PEP 8 E111 & E114 cleanup. (#20838) 2017-01-30 15:01:47 -08:00
inventory Convert error to the native text type before writing to stderr 2017-02-07 18:01:58 -05:00
module_utils Avi Networks Ansible modules. (#20415) 2017-02-08 09:47:18 -05:00
modules known_hosts: support --diff (#20349) 2017-02-08 09:56:03 -05:00
parsing improve error message on conflicting actions. Fixes #21057 (#21059) 2017-02-06 22:48:06 +00:00
playbook refactoring async 2017-02-06 19:32:00 -05:00
plugins remove warning/deprecation keys after usage 2017-02-08 09:47:10 -05:00
template PEP 8 E111 & E114 cleanup. (#20838) 2017-01-30 15:01:47 -08:00
utils Avi Networks Ansible modules. (#20415) 2017-02-08 09:47:18 -05:00
vars PEP 8 fix. 2017-01-31 13:38:05 -08:00
__init__.py Fix ziploader for the cornercase of ansible invoking ansible. 2016-04-29 08:47:49 -07:00
constants.py Module utils default path (#20913) 2017-02-02 17:48:53 -08:00
release.py Bumping devel version to 2.3.0 2016-10-03 11:46:31 -05:00
test-requirements.txt Switch tests to pytest and ansible-test. 2017-01-11 12:34:59 -08:00