# task file includes

**URL:** <https://forum.ansible.com/t/task-file-includes/12551>\
**Category:** Ansible Project\
**Created:** [March 21, 2013, 2:58pm UTC](https://forum.ansible.com/t/task-file-includes/12551 "2013-03-21T14:58:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![PJ1](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@PJ1](https://forum.ansible.com/u/PJ1)\
**Post date:** [March 21, 2013, 2:58pm UTC](https://forum.ansible.com/t/task-file-includes/12551/1 "2013-03-21T14:58:00Z")

</div>

Hi,

I’m trying to include a subset of OS tasks in another task file, which in turn is included in the main book, ie.

playbook.yml  
 → include: tasks/os\_common.yml  
 → include: sysctl.yml

os\_common.yml contains a bunch of normal tasks in addition to the include:

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [March 21, 2013, 3:15pm UTC](https://forum.ansible.com/t/task-file-includes/12551/2 "2013-03-21T15:15:47Z")

</div>

Can you please post these files on gist.github.com so we can see them  
with formatting?

Please also include the command you are using to run things in the gist.

Thanks!

---

<div class="post-metadata">

**Author:** ![PJ1](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@PJ1](https://forum.ansible.com/u/PJ1)\
**Post date:** [March 21, 2013, 3:35pm UTC](https://forum.ansible.com/t/task-file-includes/12551/3 "2013-03-21T15:35:11Z")

</div>

[https://gist.github.com/pjoakimsson/d06a726ef1e6840d2b44](https://gist.github.com/pjoakimsson/d06a726ef1e6840d2b44)

---

<div class="post-metadata">

**Author:** ![PJ1](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@PJ1](https://forum.ansible.com/u/PJ1)\
**Post date:** [March 21, 2013, 3:40pm UTC](https://forum.ansible.com/t/task-file-includes/12551/4 "2013-03-21T15:40:36Z")

</div>

If I skip os\_common.yml, i.e. specify sysctl.yml as include file in main.yml it works just fine…

---

<div class="post-metadata">

**Author:** ![Lester\_Wade](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@Lester\_Wade](https://forum.ansible.com/u/Lester_Wade)\
**Post date:** [March 21, 2013, 4:46pm UTC](https://forum.ansible.com/t/task-file-includes/12551/5 "2013-03-21T16:46:41Z")

</div>

PJ, I believe your sysctl.yml task include needs the action attribute:

```auto

  lineinfile: dest=/etc/sysctl.conf regexp=^kernel.core_pattern line="kernel.core_pattern = /var/cores/core_%h_%e.%p"

```

becomes …

```auto

  action: lineinfile dest=/etc/sysctl.conf regexp=^kernel.core_pattern line="kernel.core_pattern = /var/cores/core_%h_%e.%p"

```

---

<div class="post-metadata">

**Author:** ![PJ1](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@PJ1](https://forum.ansible.com/u/PJ1)\
**Post date:** [March 21, 2013, 6:14pm UTC](https://forum.ansible.com/t/task-file-includes/12551/6 "2013-03-21T18:14:00Z")

</div>

Indeed, thanks for spotting it.  
That would still imply that shorthands doesn’t work in that structure and that it’s also unable to pick up the task name when producing the error message.

---

<div class="post-metadata">

**Author:** ![PJ1](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@PJ1](https://forum.ansible.com/u/PJ1)\
**Post date:** [March 22, 2013, 9:50am UTC](https://forum.ansible.com/t/task-file-includes/12551/7 "2013-03-22T09:50:49Z")

</div>

Is this something that I should create a ticket on perhaps?

---

<div class="post-metadata">

**Author:** ![Lester\_Wade](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@Lester\_Wade](https://forum.ansible.com/u/Lester_Wade)\
**Post date:** [March 22, 2013, 10:15am UTC](https://forum.ansible.com/t/task-file-includes/12551/8 "2013-03-22T10:15:40Z")

</div>

Might be a good idea, at the least we can spawn a document ticket from it to make sure its very clear in the documentation.

---

<div class="post-metadata">

**Author:** ![PJ1](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@PJ1](https://forum.ansible.com/u/PJ1)\
**Post date:** [March 22, 2013, 10:48am UTC](https://forum.ansible.com/t/task-file-includes/12551/9 "2013-03-22T10:48:45Z")

</div>

I revert that… tried to set it up again and failed to reproduce the successful run (maybe I managed to fiddle with the wrong playbook yesterday).

I still get ‘ERROR: ‘action’ or ‘local\_action’ attribute missing in task “”’

Did some initial debugging it seems it expects action/local\_action in the os\_common.yml and don’t even read sysctl.yml before exiting.

---

<div class="post-metadata">

**Author:** ![PJ1](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@PJ1](https://forum.ansible.com/u/PJ1)\
**Post date:** [March 22, 2013, 11:11am UTC](https://forum.ansible.com/t/task-file-includes/12551/10 "2013-03-22T11:11:06Z")

</div>

Tested on the devel branch and there it works fine… I was running my initial tests on 0.9.

case closed. 🙂
