Skip to content

motd.j2 fails at alias interfaces #486

@ThiloSolbrig

Description

@ThiloSolbrig

If alias interfaces are active at the host (e.g. virtual IP and SCAN IP interfaces), adding motd fails because alias interfaces are not handled correctly:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'dict object' has no attribute 'ipv4'. 'dict object' has no attribute 'ipv4'
fatal: [c-tso-autoupgrade-01.test.aspicon.lan]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'ipv4'. 'dict object' has no attribute 'ipv4'"}

Reason is, motd.j2 loops over all ansible_interfaces, including the alias interfaces. But alias interfaces seem not to know the ipv4 attribute in ansible_facts:

test.aspicon.lan | SUCCESS => {
    "ansible_facts": {
        ...
        "ansible_ens192": {
            "active": true,
            "device": "ens192",
            "features": {
                ...
            "ipv4": {
                "address": "***",
                "broadcast": "***",
                "netmask": "255.255.255.0",
                "network": "***",
                "prefix": "24"
            },
            ...
        },
        "ansible_ens192_1": {
            "ipv4_secondaries": [
                {
                    "address": "***",
                    "broadcast": "***",
                    "netmask": "255.255.255.0",
                    "network": "***",
                    "prefix": "24"
                }
            ]
        },
        ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions