That's what I was missing.  Thanks for that.

On Monday, September 22, 2014 6:17:40 PM UTC-7, Matt Martz wrote:
>
> I may be missing something here, but in your example you did not seem to 
> be passing anything to your module in your playbook.  You mention that the 
> vars are in vars/main.yml, however you still need to pass those vars to 
> your module.  I imagine something like the following based on your output 
> of vars/main.yml:
>
> ---
>
> - name: Run the Command on the switch
>
>   ans_check_dis.py: user="{{item.user}}" password="{{item.password}}" 
> host="{{item.host}}"
>
>   with_items: routers
>
>
>
> On Mon, Sep 22, 2014 at 8:04 PM, Joseph Jenkins <[email protected] 
> <javascript:>> wrote:
>
>> Here is the output from ansible-playbook command:
>>
>> jjenkins@CAARPWATCH:~/ANSIBLE/TEST$ ansible-playbook site.yml -k
>>>
>>> SSH password: 
>>> PLAY [Lookup information on the Switch] 
>>> *************************************** 
>>> GATHERING FACTS 
>>> *************************************************************** 
>>> ok: [localhost]
>>> TASK: [router | Run the Command on the switch] 
>>> ******************************** 
>>> fatal: [localhost] => failed to parse: Traceback (most recent call last):
>>>   File 
>>> "/home/jjenkins/.ansible/tmp/ansible-tmp-1411433982.14-168150244858379/ans_check_dis.py",
>>>  
>>> line 38, in <module>
>>>     remote_conn_pre.connect(dest, username=userid, password=passw, 
>>> allow_agent=False,look_for_keys=False)
>>> NameError: name 'dest' is not defined
>>> FATAL: all hosts have already failed -- aborting
>>> PLAY RECAP 
>>> ******************************************************************** 
>>>            to retry, use: --limit @/home/jjenkins/site.retry
>>> localhost                  : ok=1    changed=0    unreachable=1    
>>> failed=0   
>>>
>>> When I the arguments file under: 
>> /home/jjenkins/.ansible/tmp/ansible-tmp-1411433982.14-168150244858379/arguments
>> it's empty, its like it didn't grab the vars out of the vars/main.yml
>>  
>> ---
>>
>> routers:
>>
>>  - { user: somepass, host: somehost, password: somepass }
>> Is this the correct place to be putting these variables to get passed as 
>> arguments?  That is my first problem is that I am not sure I have the 
>> values in the right place to get treated as arguments to be passed to the 
>> module.
>>
>>  
>>
>>> On Monday, September 22, 2014 5:47:47 PM UTC-7, Michael DeHaan wrote:
>>>
>>> "however nothing was working and it's complaining about the variables 
>>> being empty"
>>>
>>> Can you paste the specific output and the rest of your ansible playbook 
>>> you are using to test this?
>>>
>>> Also, the /usr/share/ansible directory *may* expect your module to be in 
>>> a category subdirectory, it's been so long that we've had categories, I 
>>> don't know if that's true without spelunking through the source.  The 
>>> subdirectory name would not be important.
>>>
>>>
>>>
>>>
>>>
>>> On Mon, Sep 22, 2014 at 8:43 PM, Joseph Jenkins <[email protected]> 
>>> wrote:
>>>
>>>> The module is sitting in /usr/share/ansible in the root and it does 
>>>> have a .py.  The module is ans_check_dis.py.   
>>>>
>>>> The playbook calls the module just fine, however nothing was working 
>>>> and it's complaining about the variables being empty.  So I put a 30 
>>>> second 
>>>> wait into the module so that I could check the arguments file and I found 
>>>> that it's empty.  
>>>>
>>>> Here is the main.yml from my tasks folder:
>>>>
>>>> ---
>>>>
>>>> - name: Run the Command on the switch
>>>>
>>>>   ans_check_dis.py: 
>>>>
>>>> On Monday, September 22, 2014 4:43:43 PM UTC-7, Michael DeHaan wrote:
>>>>>
>>>>> Hi Joseph,
>>>>>
>>>>> It won't matter, but typical convention is to not have modules end in 
>>>>> ".py", but it seems like your problem may be that it's not in the module 
>>>>> path.
>>>>>
>>>>> This is configured in Ansible.cfg, or you can just drop the module 
>>>>> into a "./library" directory alongside your playbook.
>>>>>
>>>>> I'd have to see the line from the playbook to see if you were having a 
>>>>> specific problem with the invocation, but my guess is that's the problem.
>>>>>
>>>>> If that's not it, I'd need more information about what "doesn't work" 
>>>>> means in your case.
>>>>>
>>>>> Thanks!
>>>>>
>>>>> On Mon, Sep 22, 2014 at 5:15 PM, Joseph Jenkins <[email protected]> 
>>>>> wrote:
>>>>>
>>>>>> I created an Ansible module in python that works correctly when I 
>>>>>> call it from the command line with:
>>>>>>
>>>>>> ansible routers -m ans_check_dis.py -a 'user=someuser host=somehost 
>>>>>> password=somepassword' -k
>>>>>>
>>>>>> Now I am trying to build this into a playbook to be called and have 
>>>>>> the variables used as the arguments for the module.  I have tried a 
>>>>>> bunch 
>>>>>> of different iterations and tried searching for it and can't seem to 
>>>>>> find 
>>>>>> how to make this work.  Any recommendations or guidance would be greatly 
>>>>>> appreciated.
>>>>>>
>>>>>> -- 
>>>>>> 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/60e7e71f-705a-44e3-af22-498259cb7ef8%
>>>>>> 40googlegroups.com 
>>>>>> <https://groups.google.com/d/msgid/ansible-project/60e7e71f-705a-44e3-af22-498259cb7ef8%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>  -- 
>>>> 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/94c64e96-9054-419e-bf8e-
>>>> 5852402b65ea%40googlegroups.com 
>>>> <https://groups.google.com/d/msgid/ansible-project/94c64e96-9054-419e-bf8e-5852402b65ea%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  -- 
>> 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] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/ae2f28c8-f2e9-4d94-a952-ac80b4e5a101%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/ae2f28c8-f2e9-4d94-a952-ac80b4e5a101%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Matt Martz
> @sivel
> sivel.net
>  

-- 
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/aba16a09-8a55-41cc-98c1-037d4590686e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to