【发布时间】:2020-02-22 23:16:33
【问题描述】:
我有以下剧本,我在其中测试对 group_vars 文件中值的访问。第一个任务运行良好,但第二个任务失败。我认为这是从 vars 文件访问嵌套数据的正确语法。
Failure message:
TASK [call 60 env FEX 141 uplink port from group_vars] ****************************************************************************************************************
fatal: [S70G1MS001]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'float object' has no attribute 'uplink'
我的 group_vars 文件中有以下数据结构:
60:
141:
uplink: Eth1/6
description: "FEX101@AA33"
IZ2:
SW1: S70G1MS001
SW2: S70G2MS002
剧本:
---
- hosts: S70G1MS001
no_log: false
gather_facts: false
tasks:
- name: call IZ2 switch 2 from group_vars
debug:
msg:
- "{{ IZ2.SW2 }}"
- name: call 60 env FEX 141 uplink port from group_vars
debug:
msg:
- "{{ 60.141.uplink }}"
【问题讨论】: