Skip to content

Combining Hostname / Ip /MAN into dictionary fails #11

@ykhanal123

Description

@ykhanal123

Hi,

I was working on deploying a openshift 4.1 cluster on RHEV utilizing this Ansible playbook. As I was going through the setup and running the playbook I ran into a few issues. 1st on the task to combine mac /hostname/ip into a dictionary it runs into a templating error. Here is the traceback:
fatal: [localhost]: FAILED! => {"msg": "Unexpected templating type error occurre d on ({{\n host_mac_list | default([]) +\n [\n {\n 'name': item.it em,\n 'mac': item.ansible_facts.ovirt_nics[0].mac.address,\n ' ip': hostvars[item.item]['ip']\n }\n ]\n}}): coercing to Unicode: need strin g or buffer, list found"}
Here is the portion of the code in roles/rhv/tasks/main.yaml where it is getting an error:

- name: Combine Hostname/IP/MAC into Dictionary for Easy Lookup
  set_fact:
    host_mac_list: >-
      {{
        host_mac_list | default([]) +
        [
          {
                'name': item.item,
                'mac': item.ansible_facts.ovirt_nics[0].mac.address,
                'ip': hostvars[item.item]['ip']
          }
        ]
      }}
  with_items:
    - "{{ ovirt_nic_facts_results.results }}"

I temporarily created a fix where I messed around with the variables and got the ip and hostname to be saved correctly but the mac address is not so I worked around that and set a static value for now. Here is my current configuration.

  set_fact:
    host_mac_list: >-
      {{
        host_mac_list | default([]) +
        [
          {
            'name': item,
            'mac': item.nics.mac_address | default('56:6f:68:f0:00:06'),
            'ip': hostvars[item]['ip'] | default([])
          }
        ]
      }}
  with_items:
   - "{{ groups[provision_group] }}"

Any help would be appreciated
Thanks,
Yajan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions