# included tasks do not execute when running playbook with ansible api

**URL:** <https://forum.ansible.com/t/included-tasks-do-not-execute-when-running-playbook-with-ansible-api/20261>\
**Category:** Ansible Developer\
**Created:** [January 19, 2016, 4:34am UTC](https://forum.ansible.com/t/included-tasks-do-not-execute-when-running-playbook-with-ansible-api/20261 "2016-01-19T04:34:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shengwu\_Jiang](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@Shengwu\_Jiang](https://forum.ansible.com/u/Shengwu_Jiang)\
**Post date:** [January 19, 2016, 4:34am UTC](https://forum.ansible.com/t/included-tasks-do-not-execute-when-running-playbook-with-ansible-api/20261/1 "2016-01-19T04:34:03Z")

</div>

I have a simple test role located in `/etc/ansible/roles/test/tasks/main.yml` like this:

```auto
---
- roles/common/tasks/facts.yml
- include: test.yml

```

And I use the example code of **Python API 2.0** found in [Documentation](http://docs.ansible.com/ansible/developing_api.html). Then I’ve encountered a strange problem.

On my develop machine which is a Mac, everything works fine, but when I run it on the production machine whose operating system is CentOS 7, the two included tasks can’t be executed. Here is the output:

```auto
PLAY [Test Play] **************************************************************

TASK [setup] *******************************************************************
ok: [10.85.0.20]

TASK [test : include] **********************************************************
included: /etc/ansible/roles/common/tasks/facts.yml for 10.85.0.20

TASK [test : include] **********************************************************
included: /etc/ansible/roles/test/tasks/test.yml for 10.85.0.20

```

You see, it did including operation, but nothing actually executed.

And the correct output would be:

```auto
PLAY [Test Play] **************************************************************

TASK [setup] *******************************************************************
ok: [10.85.0.20]

TASK [test : include] **********************************************************
included: /Users/Jiang/projects/ecs-ansible/roles/common/tasks/facts.yml for 10.85.0.20

TASK [test : facts.d dir] ******************************************************
ok: [10.85.0.20]

TASK [test : facts file] *******************************************************
changed: [10.85.0.20]

TASK [test : get facts from pluto] *********************************************
changed: [10.85.0.20]

TASK [test : setup] ************************************************************
ok: [10.85.0.20]

TASK [test : include] **********************************************************
included: /Users/Jiang/projects/ecs-ansible/roles/test/tasks/test.yml for 10.85.0.20

TASK [test : debug] ************************************************************
ok: [10.85.0.20] => {
    "msg": "15.0"
}

```

Version:

- OSX 10.11.4 beta & ansible 2.1.0 (devel [`36aa89a`](https://github.com/ansible/ansible/commit/36aa89ac7e77dde7fba7a14db21845a456577b46)) last updated 2016/01/18 14:48:31 (GMT +800)
- CentOS 7.1.1503 & ansible 2.1.0 (devel [`36aa89a`](https://github.com/ansible/ansible/commit/36aa89ac7e77dde7fba7a14db21845a456577b46)) last updated 2016/01/18 23:05:26 (GMT +800)

Could someone help me to solve this? Thanks.

---

<div class="post-metadata">

**Author:** ![Dossy\_Shiobara](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@Dossy\_Shiobara](https://forum.ansible.com/u/Dossy_Shiobara)\
**Post date:** [January 19, 2016, 4:05pm UTC](https://forum.ansible.com/t/included-tasks-do-not-execute-when-running-playbook-with-ansible-api/20261/2 "2016-01-19T16:05:37Z")

</div>

Could you provide copies of your roles/common/tasks/facts.yml and roles/test/tasks/test.yml files, so others can try to fully reproduce what you’re experiencing?

---

<div class="post-metadata">

**Author:** ![Shengwu\_Jiang](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@Shengwu\_Jiang](https://forum.ansible.com/u/Shengwu_Jiang)\
**Post date:** [January 19, 2016, 4:13pm UTC](https://forum.ansible.com/t/included-tasks-do-not-execute-when-running-playbook-with-ansible-api/20261/3 "2016-01-19T16:13:26Z")

</div>

Here is the contents of the included tasks:

##### roles/common/tasks/facts.yml:

```auto
---
- name: facts.d dir
  file: path=/etc/ansible/facts.d state=directory

- name: facts file
  copy: src=roles/common/files/facts/preferences.fact dest=/etc/ansible/facts.d/preferences.fact

- name: get facts from pluto
  get_url: url=http://10.209.0.83:7070/api/config/ansible_facts?ip={{ ansible_default_ipv4.address }} force=yes dest=/etc/ansible/facts.d/preferences.fact
  
- setup: filter=*

```

##### roles/test/tasks/test.yml

```auto
---
- debug: msg={{ (ansible_memtotal_mb / 1024) | round }}

```

---

<div class="post-metadata">

**Author:** ![Dossy\_Shiobara](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@Dossy\_Shiobara](https://forum.ansible.com/u/Dossy_Shiobara)\
**Post date:** [January 19, 2016, 4:55pm UTC](https://forum.ansible.com/t/included-tasks-do-not-execute-when-running-playbook-with-ansible-api/20261/4 "2016-01-19T16:55:22Z")

</div>

What versions of Python are you using on OSX vs. CentOS 7?
