PLAY [Ansible Pinging Host which validates SSH passwordless login] *******************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************ok: [thor]
TASK [hci_cluster : Copy a version of hosts file common for nodes to ignite cluster] *************************************************************************************ok: [thor]
TASK [hci_cluster : debug] ***********************************************************************************************************************************************ok: [thor] =>
msg: ‘’‘thors’’ this should be hostname with s added such as thors’
TASK [hci_cluster : debug] ***********************************************************************************************************************************************ok: [thor] =>
msg: thor this should be hostname response of thor
TASK [hci_cluster : debug] ***********************************************************************************************************************************************fatal: [thor]: FAILED! =>
msg: |-
The task includes an option with an undefined variable. The error was: ‘ansible.parsing.yaml.objects.AnsibleUnicode object’ has no attribute ‘storage_nic’
The error appears to be in ‘/mnt/c/GitHub/penguinpages_cluster_devops/cluster_devops/roles/task_network_hosts.yml’: line 63, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
msg: “{{ inventory_hostname }} this should be hostname response of thor”
- debug: # this works to set variable for storage interface https://docs.ansible.com/ansible/latest/collections/community/general/nmcli_module.html
msg: "'{{ inventory_hostname }}s' this should be hostname with s added such as thors"
- debug:
msg: "{{ inventory_hostname }} this should be hostname response of thor"
- debug:
msg: "{{ inventory_hostname.storage_nic }} this should be response of ens15f0"
- debug:
msg: "{{ ansible_facts.storage_nic }} I guess if ansible_fact is a special ansible variable...this should be hostname response of ens15f0"
You don't show the task which uses nmlci_module and provides storage_nic information.
inventory_hostname.storage_nic is totally bogus as a string can't be a nested variable.
Well. I was trying to keep it simple and just validate the variable call was valid before trying to use it in a task.
But task would be something along lines of:
- name: Get server storage IP address from /etc/hosts
command: "grep '{{ inventory_hostname }}s' /etc/hosts | awk '{ print $1 }'"
register: storage_ip
So the result of the command is stored in the variable storage_ip and the output of the command
is stored in storage_ip.stdout (as string) and storage_ip.stdout_lines (list of output lines).
To show the result:
debug:
var: storage_ip
- task: # Set Storage IP for host
nmci:
ipaddress: {{storage_ip}}
interface: {{ inventory_hostname.storage_nic }}
mask: 24
mtu: 9000
PLAY [Ansible Pinging Host which validates SSH passwordless login] *******************************************************************************************************
TASK [Gathering Facts] ***************************************************************************************************************************************************ok: [thor]
TASK [hci_cluster : debug] ***********************************************************************************************************************************************fatal: [thor]: FAILED! =>
msg: |-
The task includes an option with an undefined variable. The error was: ‘storage_nic’ is undefined
The error appears to be in ‘/mnt/c/GitHub/penguinpages_cluster_devops/cluster_devops/roles/task_network_hosts.yml’: line 78, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
msg: “{{ inventory_hostname[storage_nic] }} this should be NIC of thor for storage”