diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-10-18 16:44:11 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-10-18 17:57:02 +0300 |
commit | 6f1703216b5068db1700e3e72e04aa508e368fdb (patch) | |
tree | 9741031ec6d8f061edb212363a4756b3d4d3a47f /roles/sane_debian_system/subplot.py | |
parent | 6fbc9fc4c06d95a7bbb4cc42847082262a07f2a1 (diff) | |
download | debian-ansible-6f1703216b5068db1700e3e72e04aa508e368fdb.tar.gz |
fix(sane_debian_system): set hostname via Ansible
Diffstat (limited to 'roles/sane_debian_system/subplot.py')
-rw-r--r-- | roles/sane_debian_system/subplot.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/roles/sane_debian_system/subplot.py b/roles/sane_debian_system/subplot.py index 8262479..f45eb2b 100644 --- a/roles/sane_debian_system/subplot.py +++ b/roles/sane_debian_system/subplot.py @@ -1,3 +1,6 @@ +import logging + + def host_has_package_installed(ctx, package=None): assert_eq = globals()["assert_eq"] qemu = ctx["qemu"] @@ -27,3 +30,19 @@ def host_hostname_is(ctx, hostname=None): assert_eq(exit, 0) actual = output.decode("UTF8").splitlines()[-1] assert_eq(actual, hostname) + + +def host_hostname_has_address(ctx, hostname=None, addr=None): + assert_eq = globals()["assert_eq"] + + logging.debug(f"host_hostname_has_address:") + qemu = ctx["qemu"] + output, exit = qemu.ssh(["cat", "/etc/hosts"]) + assert_eq(exit, 0) + logging.debug(f" /etc/hosts: {output!r}") + actual = output.decode("UTF8") + logging.debug(f" /etc/hosts: {actual!r}") + wordlines = [line.split() for line in actual.splitlines()] + matches = [words for words in wordlines if len(words) == 2 and words[1] == hostname] + logging.debug(f" matches: {matches!r}") + assert_eq(matches, [[addr, hostname]]) |