# How to syntax check list of tasks

**URL:** <https://forum.ansible.com/t/how-to-syntax-check-list-of-tasks/28608>\
**Category:** Ansible Project\
**Created:** [September 20, 2018, 6:15am UTC](https://forum.ansible.com/t/how-to-syntax-check-list-of-tasks/28608 "2018-09-20T06:15:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![furstenheim](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@furstenheim](https://forum.ansible.com/u/furstenheim)\
**Post date:** [September 20, 2018, 6:15am UTC](https://forum.ansible.com/t/how-to-syntax-check-list-of-tasks/28608/1 "2018-09-20T06:15:02Z")

</div>

This might be in the docs, but I cannot find it. I have the following files:

first-playbook.yml  
second-playbook.yml  
common-tasks.yml

common-tasks.yml is a list of tasks that is used in first-playbook.yml and second-playbook.yml through `include_tasks common-tasks.yml`

I’d like to syntax check everything before deploying. For playbooks I can do:

```auto
ansible-playbook --syntax-check first-playbook.yml

```

However, it is not possible for common tasks because it is a list of tasks

[https://github.com/ansible/ansible/issues/16778](https://github.com/ansible/ansible/issues/16778)

Another option would be that tasks got validated when including them, but that is not the case:

[https://github.com/ansible/ansible/issues/15709](https://github.com/ansible/ansible/issues/15709)

Is there a flag/ansible command that I can use to syntax check a list of tasks?

Ansible version

```auto
ansible 2.6.4

```

---

<div class="post-metadata">

**Author:** ![Andrew\_Latham](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Andrew\_Latham](https://forum.ansible.com/u/Andrew_Latham)\
**Post date:** [September 20, 2018, 5:23pm UTC](https://forum.ansible.com/t/how-to-syntax-check-list-of-tasks/28608/2 "2018-09-20T17:23:16Z")

</div>

Maybe something like this: python -c ‘import yaml,sys;yaml.safe\_load(sys.stdin)’ \< common-tasks.yml

---

<div class="post-metadata">

**Author:** ![furstenheim](https://avatars.discourse-cdn.com/v4/letter/f/50afbb/32.png) [@furstenheim](https://forum.ansible.com/u/furstenheim)\
**Post date:** [September 21, 2018, 6:02am UTC](https://forum.ansible.com/t/how-to-syntax-check-list-of-tasks/28608/3 "2018-09-21T06:02:28Z")

</div>

At the moment what I’m doing is a nasty hack like:

touch FAKE\_PLAYBOOK.yml  
echo “host: foo” \> FAKE\_PLAYBOOK.yml  
echo " tasks"\>\> FAKE\_PLAYBOOK.yml  
cat common\_tasks.yml | awk ‘{print " " $0 }’  
ansible-playbook --syntax-check FAKE\_PLAYBOOK.yml

Obviously that only scores as hack

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [September 21, 2018, 6:25am UTC](https://forum.ansible.com/t/how-to-syntax-check-list-of-tasks/28608/4 "2018-09-21T06:25:04Z")

</div>

Not an answer to you question but some other way to do it.

Instead of include\_tasks create a role common and put the task(s) there and add the role to both palybook, then they will get syntax checked.
