'dict object' has no attribute 'packages' error log is found when run playbook 5_setup_bastion.yaml.
liudalibj opened this issue · comments
'dict object' has no attribute 'packages' error reported in log.
file: 5_setup_bastion.yaml
- block:
- name: Check if 'expect' is installed on jumphost, for use in ssh-copy-id role for NAT.
package_facts:
failed_when: '"expect" not in ansible_facts.packages'
when: (env.network_mode | upper == "NAT") and ( env.jumphost.ip is not none )
env the lpar/jumphost:
ansible --version
ansible [core 2.15.12]
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.9.19 (main, May 16 2024, 08:45:44) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)] (/usr/bin/python3.9)
jinja version = 3.1.3
libyaml = True
cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="8.7 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.7"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.7 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8::baseos"
HOME_URL="https://www.redhat.com/"
DOCUMENTATION_URL="https://access.redhat.com/documentation/red_hat_enterprise_linux/8/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.7
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.7"
The detail logs:
...
TASK [Generate an OpenSSH keypair with the default values (4096 bits, RSA), if using jumphost for NAT.] ***
ok: [jumphost]
TASK [Check if 'expect' is installed on jumphost, for use in ssh-copy-id role for NAT.] ***
fatal: [jumphost]: FAILED! => {"ansible_facts": {"packages": {"NetworkManager": [{"arch": "s390x", "epoch": 1, "name": "NetworkManager", "release": "1.el8", "source": "rpm", "version": "1.40.0"}], "NetworkManager-libnm": [{"arch": "s390x", "epoch": 1, "name": "NetworkManager-libnm", "release": "1.el8", "source": "rpm", "version": "1.40.0"}], "NetworkManager-team": [{"arch": "s390x", "epoch": 1, "name": "NetworkManager-team", "release": "1.el8", "source": "rpm", "version": "1.40.0"}], "NetworkManager-tui": [{"arch": "s390x", "epoch": 1, "name": "NetworkManager-tui", "release": "1.el8", "source": "rpm", "version": "1.40.0"}], "PackageKit": [{"arch": "s390x", "epoch": null, "name": "PackageKit", "release": "6.el8", "source": "rpm", "version": "1.1.12"}], "PackageKit-glib": [{"arch": "s390x", "epoch": null, "name": "PackageKit-glib", "release": "6.el8", "source": "rpm", "version": "1.1.12"}], "aardvark-dns": [{"arch": "s390x", "epoch": 2, "name": "aardvark-dns", "release": "1.module+el8.10.0+21962+8143777b", "source": "rpm", "version": "1.10.0"}], ........., "zlib": [{"arch": "s390x", "epoch": null, "name": "zlib", "release": "25.el8", "source": "rpm", "version": "1.2.11"}], "zlib-devel": [{"arch": "s390x", "epoch": null, "name": "zlib-devel", "release": "25.el8", "source": "rpm", "version": "1.2.11"}], "zstd": [{"arch": "s390x", "epoch": null, "name": "zstd", "release": "1.el8", "source": "rpm", "version": "1.4.4"}]}}, "changed": false, "failed_when_result": "The conditional check ''expect' not in ansible_facts.packages' failed. The error was: error while evaluating conditional ('expect' not in ansible_facts.packages): 'dict object' has no attribute 'packages'. 'dict object' has no attribute 'packages'"}
TASK [Package 'expect' must be installed on the jumphost, attempting to install it.] ***
ok: [jumphost]
...
created a pr to use a new way to check the expect package, more details at here #297 (comment)