Ansible 验证所需的额外变量
Ansible validate required extra-var
我有一个 Ansible 剧本,我在其中导入其他 Ansible 剧本,并从命令行获取一些额外变量。我希望它们是必需的。
- import_playbook: nginx.yml
test_first="test first"
- import_playbook: nginx1.yml
test_two={"hello":"{{test}}"}
我将 test
作为命令行的额外变量。我希望它是必需的。
我尝试了下面的代码,但它给出了错误:
- import_playbook: nginx.yml
test_first="test first"
tasks:
- fail: msg="Error"
when: not (test is defined)
- import_playbook: nginx1.yml
test_two={"hello":"{{test}}"}
tasks
应该是一个play中的key,所以必须定义一个play,例如:
- import_playbook: nginx.yml
test_first="test first"
- hosts: localhost
gather_facts: false
connection: local
tasks:
- fail: msg="Error"
when: not (test is defined)
- import_playbook: nginx1.yml
test_two={"hello":"{{test}}"}
我有一个 Ansible 剧本,我在其中导入其他 Ansible 剧本,并从命令行获取一些额外变量。我希望它们是必需的。
- import_playbook: nginx.yml
test_first="test first"
- import_playbook: nginx1.yml
test_two={"hello":"{{test}}"}
我将 test
作为命令行的额外变量。我希望它是必需的。
我尝试了下面的代码,但它给出了错误:
- import_playbook: nginx.yml
test_first="test first"
tasks:
- fail: msg="Error"
when: not (test is defined)
- import_playbook: nginx1.yml
test_two={"hello":"{{test}}"}
tasks
应该是一个play中的key,所以必须定义一个play,例如:
- import_playbook: nginx.yml
test_first="test first"
- hosts: localhost
gather_facts: false
connection: local
tasks:
- fail: msg="Error"
when: not (test is defined)
- import_playbook: nginx1.yml
test_two={"hello":"{{test}}"}