Hi Mona,
please first import the below line in your module:
from ansible.module_utils.basic import *
After importing it use below step to get value of variable:
module = AnsibleModule(argument_spec = dict( logstash_path =
dict(required=True, aliases=['logstash_path ']))
logstash_path = module.params.get('logstash_path')
regards
Prakul
On Wednesday, April 27, 2016 at 11:42:56 AM UTC+5:30, Mona Gopal wrote:
>
> Hi,
>
> I have written custom modules in python.
> I am calling the modules from my task file like below:
>
> - name: Collect logstash details
> action: get_logstash_details *path*={{ logstash_path }}
> register: result
> - name: Display the logstash details
> debug: var=result
>
>
> get_logstash_details is my custom module.
> path is the parameter i want to pass to the custom module.
>
> This paramter is accessed in custom module as mentioned below
> path=sys.argv[1]
>
>
> Queries:
> 1) Is that the right way to send parameters to custom module?
>
> I am getting the below error:
> fatal: [172.19.10.31]: FAILED! => {"changed": false, "failed": true,
> "invocation": {"module_args": {"path":
> "/opt/logstash_standalone/logstash-2.1.1/bin/logstash"}, "module_name":
> "get_logstash_details"}, "msg": "unsupported parameter for module: path"}
>
>
> Thanks in advance,
> Mona G
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/987b37d6-613c-41d5-b92b-0e7dc668e2cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.