Skip to content

cluster.yml templating fails when {{ cephadm_admin_interface }} contains hyphens? #172

@PC-Admin

Description

@PC-Admin

So I am trying to set this 'data_t_str' interface as my {{ cephadm_admin_interface }}:

mcollins1@ceph-data-t-mon-01:~$ ip addr show data-t-str
9: data-t-str: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc noqueue state UP group default qlen 1000
    link/ether 52:54:00:c0:d0:54 brd ff:ff:ff:ff:ff:ff
    inet 10.221.0.11/16 brd 10.221.255.255 scope global data-t-str
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fec0:d054/64 scope link
       valid_lft forever preferred_lft forever

But with this task (I've added a debug infront):

- name: Debug template variables
  debug:
    msg:
      - "Template variable: {{ hostvars[inventory_hostname]['ansible_facts'][cephadm_admin_interface | replace('-', '_')]['ipv4']['address'] }}"
  ignore_errors: true
  run_once: false

- name: Template out cluster.yml
  vars:
    fsid: "{{ cephadm_fsid if cephadm_fsid | length > 0 else cephadm_fsid_current.stdout }}"
  template:
    src: "templates/cluster.yml.j2"
    dest: "/var/run/ceph/{{ fsid }}/cephadm_cluster.yml"
    owner: root
    group: root
    mode: "0644"
  become: true
  run_once: true

Whether I set {{ cephadm_admin_interface }} as data-t-str or data_t_str, the task fails in the same way with:

TASK [stackhpc.cephadm.cephadm : Debug template variables] **************************************************************************************************************************************************************************************
ok: [ceph-data-t-mon-01] => {
    "msg": [
        "Template variable: 10.221.0.11"
    ]
}

TASK [stackhpc.cephadm.cephadm : Template out cluster.yml] **************************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'dict object' has no attribute 'data_t_str'
fatal: [ceph-data-t-mon-01]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'data_t_str'"}

That's definitely the IP I wanted, but the template fails to recognize that same variable...

If I set cephadm_admin_interface to an interface without hyphens in it, like 'admin', it works. But what if I need to use a interface name that does have hyphens?

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