私はプレイブックを持っていて、ホストファイルに文字列のリストを定義したいと思います。ここで可能、ホストインベントリのリストを定義する方法はありますか?
は、私のホストファイルです:
[dashboard]
1.2.3.4 dashboard_domain=test site_domain=['one','two','foo', 'bar']
ここで私はlist documentationを使用して書き込もうと私の脚本だ:しかしansible-playbook -i hosts ping.yml
原因このエラーで、この脚本を実行している
---
- hosts: dashboard
gather_facts: False
remote_user: ubuntu
become: yes
tasks:
- name: ping
ping:
- debug:
msg: "Domain: {{dashboard_domain}}"
- debug:
msg: "Site: {{ item }}"
with_items: "{{site_domain}}"
:
TASK: [debug ] ****************************************************************
fatal: [1.2.3.4] => with_items expects a list or a set
これは転送の問題であるようです脚本にホストファイルから定義されたリスト脚本に直接リストを定義するために動作します:
---
- hosts: dashboard
gather_facts: False
remote_user: ubuntu
become: yes
vars:
site_domain: ['one','two','foo', 'bar']
tasks:
#### APPLY HTTP-AUTH ####
- name: ping
ping:
- debug:
msg: "Domain: {{dashboard_domain}}"
- debug:
msg: "Site: {{ item }}"
with_items: "{{site_domain}}"