团队:我已经在defaults/main中定义了var device_pattern。我引用它或使用它比较与ansible_facts,但我得到错误,它没有定义?有什么隐情?
device_pattern: "nvme"
'nvme' is undefinedn
fatal: [xxxxxxx]: FAILED! => {
14:14:44 "msg": "The conditional check '{{ device_pattern }} in ansible_devices[item]' failed. The error was: error while evaluating conditional ({{ device_pattern }} in ansible_devices[item]): 'nvme' is undefinednnThe error appears to be in '/ansible-managed/jenkins-slave/slave1/workspace/run_ansible_playbook/k8s/baremetal/roles/local_volume_mount/tasks/main.yml': line 45, column 3, but maynbe elsewhere in the file depending on the exact syntax problem.nnThe offending line appears to be:nn#MDM RAID0 All available free unmounted devicesn- name: "Perform MDM Raid0 on all qualifying available devices on any cpu node"n ^ heren"
14:14:44 }
任务#MDM RAID0 All available free unmounted devices
- name: "Perform MDM Raid0 on all qualifying available devices on any cpu node"
include_tasks:
file: pfm_all_available_devices_mdm.yml
apply:
tags: pfm_all_available_devices_mdm
when:
- '{{ device_pattern }} in ansible_devices[item]'
当不需要引号时
#MDM RAID0 All available free unmounted devices
- name: "Perform MDM Raid0 on all qualifying available devices on any cpu node"
include_tasks:
file: pfm_all_available_devices_mdm.yml
apply:
tags: pfm_all_available_devices_mdm
when:
- device_pattern in ansible_devices[item]