1
我的樣品劇本(用於ansible 2.1)是:劇本中的主持人的默認值?
---
# This is sample playbook.
- name: add sample_role
hosts: '{{ target }}'
become: true
become_user: root
roles:
- sample role
當我運行它,一切都很好:
ansible-playbook -i staging test_playbook.yml --extra-vars "target=192.168.15.29"
我怎麼能忽略目標?
我已經試過這樣的事情:
hosts: '{{ target | default(all) }}'
或
hosts: '{{ target | default(hostvars) }}'
然後運行:
ansible-playbook -i staging test_playbook.yml
,但遺憾的是:
錯誤! '所有' 是未定義
或:
錯誤! 「HOSTVARS」未定義
「all」周圍的雙引號對我有用:''''hosts:'{{target |默認(「全部」)}}''''' –