필자는 책임감있는 작서를 쓸 때 새로운입니다. 내가 할 수있는 방법을 찾으려고 노력 중입니다 여분의 매개 변수가 전달되었는지 여부를 확인하십시오. 추가 매개 변수가 null이거나 명령 줄에 전달되지 않은 경우 콘솔에 오류 메시지를 출력하려고합니다.우리는 여분의 매개 변수가 합동 플레이 북에 합격했는지 여부를 어떻게 확인할 수 있습니까?
내가 여기서 시도하고있는 것.
실행 명령 : -
$ ansible-playbook mytasks.yml -e "action=del"
경우 action
가 null 여부를 다음 오류 메시지가 표시되어야 통과시켰다.
$ ansible-playbook mytasks.yml -e "action="
$ ansible-playbook mytasks.yml
내가 어떤 오류 메시지를 받고 있지 않다
---
- hosts: local
connection: local
gather_facts: true
tasks:
- shell: echo "I've got '{{ action }}' and am not afraid to use it!"
when: action is defined
- fail: msg="Bailing out. this play requires 'action'"
when: action is not defined
mytasks.yml 그냥 통과되지 않거나 여분의 인수를 확인할 수있는 방법을
TASK: [fail msg="Bailing out. this play requires {{action | mandatory}}"] *****
skipping: [localhost]
저를 제안 받기?
제안 사항이나 힌트가 있으십니까? –