# Develope Module and include non python files

**URL:** <https://forum.ansible.com/t/develope-module-and-include-non-python-files/39524>\
**Category:** Get Help\
**Created:** [January 9, 2025, 10:39am UTC](https://forum.ansible.com/t/develope-module-and-include-non-python-files/39524 "2025-01-09T10:39:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thom79](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@thom79](https://forum.ansible.com/u/thom79)\
**Post date:** [January 9, 2025, 10:39am UTC](https://forum.ansible.com/t/develope-module-and-include-non-python-files/39524/1 "2025-01-09T10:39:05Z")

</div>

When developing a module, how can i include some non python files (force ansiballz to include it)? Why do i need this? I’ve modeled a large structure of configuration objects and it’s dependencies in yaml format for easier writing. the module needs this structure to work. Furthermore, i also have some default data (jsonschemas, xmlschemas…) as files which the module needs. I dont want to have a dedicated “copy task” in the playbook since these files should be part of the module itself.

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [January 9, 2025, 3:26pm UTC](https://forum.ansible.com/t/develope-module-and-include-non-python-files/39524/2 "2025-01-09T15:26:16Z")

</div>

There is no current way to do this as they were designed ONLY for python code, I would suggest creating an action plugin of the same name that takes care of copying the data files and then executing the module. `unarchive` might be simplest example to follow, it copies archive in this case before running module.

---

<div class="post-metadata">

**Author:** ![flowerysong](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/flowerysong/32/2305_2.png) [@flowerysong](https://forum.ansible.com/u/flowerysong)\
**Post date:** [January 9, 2025, 4:51pm UTC](https://forum.ansible.com/t/develope-module-and-include-non-python-files/39524/3 "2025-01-09T16:51:16Z")

</div>

Another option would be to transform them into valid Python code that the module machinery can ship as a module util:

`plugins/module_utils/yamldata.py`:

```python
FOO = r'''
a: eh
b: bee
c: sea
'''

```

`plugins/modules/testyamldata.py`:

```python
import yaml

from ansible.module_utils.basic import AnsibleModule
from ..module_utils.yamldata import FOO

def main():
    module = AnsibleModule(
        argument_spec={},
    )

    module.exit_json(changed=False, data=yaml.safe_load(FOO))

if __name__ == ' __main__':
    main()

```

Result:

```plaintext
TASK [flowerysong.test.testyamldata] *******************************************
ok: [localhost] => 
    changed: false
    data:
        a: eh
        b: bee
        c: sea

```

---

<div class="post-metadata">

**Author:** ![thom79](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@thom79](https://forum.ansible.com/u/thom79)\
**Post date:** [January 15, 2025, 5:58pm UTC](https://forum.ansible.com/t/develope-module-and-include-non-python-files/39524/4 "2025-01-15T17:58:04Z")

</div>

Many thanks for your hint! Even more easy, since i’m using it only on the control node, i changed the whole stuff to be a action module instead of a normal module… this way it works like a charm and dont get “ansiballed”

cheers, thom

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [February 14, 2025, 5:58pm UTC](https://forum.ansible.com/t/develope-module-and-include-non-python-files/39524/5 "2025-02-14T17:58:15Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
