mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add check for known_hosts changing during tests. (#26470)
* Add check for known_hosts changing during tests. * Don't use known hosts file for delegate_to test.
This commit is contained in:
parent
2401fb5b92
commit
c26a556929
2 changed files with 21 additions and 1 deletions
|
@ -2,4 +2,5 @@
|
||||||
|
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
ANSIBLE_HOST_KEY_CHECKING=false ansible-playbook test_delegate_to.yml -i ../../inventory -v "$@"
|
ANSIBLE_SSH_ARGS='-C -o ControlMaster=auto -o ControlPersist=60s -o UserKnownHostsFile=/dev/null' \
|
||||||
|
ANSIBLE_HOST_KEY_CHECKING=false ansible-playbook test_delegate_to.yml -i ../../inventory -v "$@"
|
||||||
|
|
|
@ -14,6 +14,7 @@ import stat
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
import atexit
|
import atexit
|
||||||
|
import hashlib
|
||||||
|
|
||||||
import lib.pytar
|
import lib.pytar
|
||||||
import lib.thread
|
import lib.thread
|
||||||
|
@ -1199,6 +1200,7 @@ class EnvironmentDescription(object):
|
||||||
pip_paths = dict((v, find_executable('pip%s' % v, required=False)) for v in sorted(versions))
|
pip_paths = dict((v, find_executable('pip%s' % v, required=False)) for v in sorted(versions))
|
||||||
pip_versions = dict((v, self.get_version([pip_paths[v], '--version'])) for v in sorted(pip_paths) if pip_paths[v])
|
pip_versions = dict((v, self.get_version([pip_paths[v], '--version'])) for v in sorted(pip_paths) if pip_paths[v])
|
||||||
pip_interpreters = dict((v, self.get_shebang(pip_paths[v])) for v in sorted(pip_paths) if pip_paths[v])
|
pip_interpreters = dict((v, self.get_shebang(pip_paths[v])) for v in sorted(pip_paths) if pip_paths[v])
|
||||||
|
known_hosts_hash = self.get_hash(os.path.expanduser('~/.ssh/known_hosts'))
|
||||||
|
|
||||||
self.data = dict(
|
self.data = dict(
|
||||||
python_paths=python_paths,
|
python_paths=python_paths,
|
||||||
|
@ -1206,6 +1208,7 @@ class EnvironmentDescription(object):
|
||||||
pip_paths=pip_paths,
|
pip_paths=pip_paths,
|
||||||
pip_versions=pip_versions,
|
pip_versions=pip_versions,
|
||||||
pip_interpreters=pip_interpreters,
|
pip_interpreters=pip_interpreters,
|
||||||
|
known_hosts_hash=known_hosts_hash,
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -1260,6 +1263,22 @@ class EnvironmentDescription(object):
|
||||||
with open(path) as script_fd:
|
with open(path) as script_fd:
|
||||||
return script_fd.readline()
|
return script_fd.readline()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_hash(path):
|
||||||
|
"""
|
||||||
|
:type path: str
|
||||||
|
:rtype: str | None
|
||||||
|
"""
|
||||||
|
if not os.path.exists(path):
|
||||||
|
return None
|
||||||
|
|
||||||
|
file_hash = hashlib.md5()
|
||||||
|
|
||||||
|
with open(path, 'rb') as file_fd:
|
||||||
|
file_hash.update(file_fd.read())
|
||||||
|
|
||||||
|
return file_hash.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
class NoChangesDetected(ApplicationWarning):
|
class NoChangesDetected(ApplicationWarning):
|
||||||
"""Exception when change detection was performed, but no changes were found."""
|
"""Exception when change detection was performed, but no changes were found."""
|
||||||
|
|
Loading…
Reference in a new issue