We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我有兩個 dict 內容長這樣 teams.yml
{ "teams": [{"gid": 10125,"location": ["hq"],"name": "aa","users": ["chenhu","chouf"]}, {"gid": 10126,"location": ["hq"],"name": "ac","users": ["guoj","yangc"]}]
}
users.yml { "users": [{"name": "changc","uid": 20000},{"name": "changb","uid": 20001}] }
我想要取出 teams 裡面的users 所以我簡單的先用個for loop 來跑跑看
{% for j in teams %} {{ j.users }} {% endfor %}
然後就會報錯
AnsibleUndefinedVariable: 'dict object' has no attribute 'users'
可是 users 不就在那邊嗎?為什麼抓不到啊? 不只是 users ,只要是值有用 [ ] 包起來的,像是 teams 的location ,我也是抓不到 ,但是 teams.gid 卻可以... ???
The text was updated successfully, but these errors were encountered:
我測試 ok ,以下是我的 playbook
https://gist.github.com/elleryq/b0b62498b3f57a9badbba26830f67344
Sorry, something went wrong.
No branches or pull requests
我有兩個 dict 內容長這樣
teams.yml
{
"teams": [{"gid": 10125,"location": ["hq"],"name": "aa","users": ["chenhu","chouf"]},
{"gid": 10126,"location": ["hq"],"name": "ac","users": ["guoj","yangc"]}]
}
users.yml
{
"users": [{"name": "changc","uid": 20000},{"name": "changb","uid": 20001}]
}
我想要取出 teams 裡面的users
所以我簡單的先用個for loop 來跑跑看
然後就會報錯
可是 users 不就在那邊嗎?為什麼抓不到啊?
不只是 users ,只要是值有用 [ ] 包起來的,像是 teams 的location ,我也是抓不到 ,但是 teams.gid 卻可以... ???
The text was updated successfully, but these errors were encountered: