1

I have a playbook like : myplaybook.yml

---
- name: call another playbook
  hosts: 127.0.0.1

- include: "{{name}}-playbook.yml"
  when: name is defined

Here I am passing the 'name' variable from cli as --extra-vars

It is working fine. But while trying to check the syntax with below command its giving error saying name is undefined

Ansible-playbook --syntax myplaybook.yml

Any ideas on how to handle it ?

2
  • Why not pass the name for the syntax check also with --extra-vars? Commented Dec 5, 2017 at 11:54
  • Actually I can't do it. The syntax check is doing by other system where I have no control. Any workaround ? Commented Dec 5, 2017 at 11:58

1 Answer 1

3

What syntax do you want to check? If you have many playbooks like name1-playbook.yml and name2-playbook.yml, how is Ansible supposed to guess all the names and test all of them?

If you want to test just one of them, make default value for name, like:

- include: "{{ name | default('name1') }}-playbook.yml"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.