community.general/lib/ansible/modules/system
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
..
__init__.py
alternatives.py Relocating extras into lib/ansible/modules/ after merge 2016-12-08 11:35:18 -05:00
at.py Relocating extras into lib/ansible/modules/ after merge 2016-12-08 11:35:18 -05:00
authorized_key.py PEP 8 indent cleanup. (#20800) 2017-01-29 07:28:53 +00:00
beadm.py system/beadm: improve examples (#20461) 2017-01-19 17:14:01 +00:00
capabilities.py PEP 8 W291 whitespace cleanup. 2017-01-27 17:08:02 -08:00
cron.py PEP 8 indent cleanup. (#20800) 2017-01-29 07:28:53 +00:00
cronvar.py Update cronvar.py (#19227) 2017-01-11 18:56:34 -05:00
crypttab.py Relocating extras into lib/ansible/modules/ after merge 2016-12-08 11:35:18 -05:00
debconf.py PEP 8 indent cleanup. (#20800) 2017-01-29 07:28:53 +00:00
facter.py PEP 8 W291 whitespace cleanup. 2017-01-27 17:08:02 -08:00
filesystem.py allow device to be list for multidev fs (#20655) 2017-02-01 13:13:12 -05:00
firewalld.py PEP 8 E111 & E114 cleanup. (#20838) 2017-01-30 15:01:47 -08:00
gconftool2.py Update validate-modules (#20932) 2017-02-02 11:45:22 -08:00
getent.py Relocating extras into lib/ansible/modules/ after merge 2016-12-08 11:35:18 -05:00
gluster_volume.py PEP 8 cleanup. (#20789) 2017-01-28 00:12:11 -08:00
group.py PEP 8 whitespace cleanup. (#20783) 2017-01-27 15:45:23 -08:00
hostname.py added formatting 2017-01-23 13:29:14 -05:00
iptables.py iptables: Fixes invalid ip6tables option (#19657) 2016-12-27 08:27:22 +01:00
kernel_blacklist.py Add Check Mode capability to kernel_blacklist module (#21007) 2017-02-06 13:00:31 -05:00
known_hosts.py known_hosts: support --diff (#20349) 2017-02-08 09:56:03 -05:00
locale_gen.py PEP 8 whitespace cleanup. (#20783) 2017-01-27 15:45:23 -08:00
lvg.py PEP 8 E111 & E114 cleanup. (#20838) 2017-01-30 15:01:47 -08:00
lvol.py PEP 8 E111 & E114 cleanup. (#20838) 2017-01-30 15:01:47 -08:00
make.py Relocating extras into lib/ansible/modules/ after merge 2016-12-08 11:35:18 -05:00
modprobe.py PEP 8 W291 whitespace cleanup. 2017-01-27 17:08:02 -08:00
mount.py Consistent path attribute for file-related modules 2017-01-13 15:49:42 -05:00
ohai.py PEP 8 W291 whitespace cleanup. 2017-01-27 17:08:02 -08:00
open_iscsi.py Fix infrequent PEP 8 issues. 2017-01-27 14:06:21 -08:00
openwrt_init.py PEP 8 indent cleanup. (#20800) 2017-01-29 07:28:53 +00:00
osx_defaults.py PEP 8 E111 & E114 cleanup. (#20838) 2017-01-30 15:01:47 -08:00
pam_limits.py Update validate-modules (#20932) 2017-02-02 11:45:22 -08:00
pamd.py Update validate-modules (#20932) 2017-02-02 11:45:22 -08:00
ping.py
puppet.py Update validate-modules (#20932) 2017-02-02 11:45:22 -08:00
runit.py renamed sv to runit, avoid svc confusion 2017-01-30 10:24:43 -05:00
seboolean.py
sefcontext.py PEP 8 indent cleanup. (#20800) 2017-01-29 07:28:53 +00:00
selinux.py
selinux_permissive.py Relocating extras into lib/ansible/modules/ after merge 2016-12-08 11:35:18 -05:00
seport.py PEP 8 indent cleanup. (#20800) 2017-01-29 07:28:53 +00:00
service.py Fix service's exec_command() for python3 (#20826) 2017-01-30 13:08:31 -05:00
setup.py PEP 8 W291 whitespace cleanup. 2017-01-27 17:08:02 -08:00
solaris_zone.py Update validate-modules (#20932) 2017-02-02 11:45:22 -08:00
svc.py minor spelling changes 2016-12-13 13:51:13 -05:00
sysctl.py PEP 8 W291 whitespace cleanup. 2017-01-27 17:08:02 -08:00
systemd.py error out if systemctl isn't present 2017-02-06 14:52:24 -05:00
timezone.py Update validate-modules (#20932) 2017-02-02 11:45:22 -08:00
ufw.py PEP 8 E111 & E114 cleanup. (#20838) 2017-01-30 15:01:47 -08:00
user.py PEP 8 E111 & E114 cleanup. (#20838) 2017-01-30 15:01:47 -08:00