# how to pass a file into AnsibleModule as argument

**URL:** <https://forum.ansible.com/t/how-to-pass-a-file-into-ansiblemodule-as-argument/24504>\
**Category:** Ansible Project\
**Created:** [May 17, 2017, 9:07am UTC](https://forum.ansible.com/t/how-to-pass-a-file-into-ansiblemodule-as-argument/24504 "2017-05-17T09:07:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruce\_Lok](https://avatars.discourse-cdn.com/v4/letter/b/6f9a4e/32.png) [@Bruce\_Lok](https://forum.ansible.com/u/Bruce_Lok)\
**Post date:** [May 17, 2017, 9:07am UTC](https://forum.ansible.com/t/how-to-pass-a-file-into-ansiblemodule-as-argument/24504/1 "2017-05-17T09:07:46Z")

</div>

I know the basic to pass a some string to an Ansible Module as argument, but curious how to pass a file

for example:  
I have a file containing some variable in yaml format (eg: /var/www/project/var.yaml)

def main():  
module = AnsibleModule(  
argument\_spec = dict(user = dict(default=‘me’),  
pass = dict(required=True),  
ip = dict(required=True),  
var1 = dict(required=True),  
filename = dict(required=True),  
))

the argument ‘filename’ is expected to be a file, I want to pass the var.yaml into the ansible module which will read it  
Thank you so much
