Thanks Michael...

.raja

On Sunday, May 18, 2014 10:16:43 PM UTC-5, Michael DeHaan wrote:
>
> There should already be a ticket open about lookup module errors not 
> resulting in errors that traverse down the stack.
>
> This is currently flagged a "P2" so it should be included in the next dot 
> release.
>
>
> On Fri, May 16, 2014 at 6:19 PM, Raja Mukherjee 
> <[email protected]<javascript:>
> > wrote:
>
>> I figured it out...problem is that if lookup function does not find a 
>> file, it seems to not generate any error to upstream...my issue was...this 
>> line
>>
>> key="{{ lookup('file', '/keys/' + item.0.username + '/' + item.1) }}"
>>
>> it should be
>>
>> key="{{ lookup('file', 'keys/' + item.0.username + '/' + item.1) }}" - 
>> relative 
>> to the roles/files
>>
>> I had a similar issue with copy and that's what aided me to figure this 
>> out.
>>
>> Thanks
>>
>> .raja
>>
>> On Friday, May 16, 2014 3:52:22 PM UTC-5, Raja Mukherjee wrote:
>>>
>>> Platform: 
>>>
>>> raja@ansible-control:~/ansible$ cat /etc/lsb-release | grep -i desc | 
>>> cut -d'=' -f2
>>> "Ubuntu 14.04 LTS"
>>>
>>> Ansible is installed through PPA
>>>
>>> raja@ansible-control:~/ansible$ ansible --version
>>> ansible 1.6
>>>
>>> *roles/user/vars/main.yml *
>>>
>>> (for testing, eventually will go to group_vars)
>>>
>>> authorized:
>>>   - username: mimi
>>>     ssh_key_files:
>>>       - id_rsa_mimi.pub
>>>
>>> roles/users/tasks/main.yml (snippet)
>>>
>>> - name: Copy SSH Keys
>>>   authorized_key: user="{{ item.0.username }}" 
>>>                   key="{{ lookup('file', '/keys/' + item.0.username + 
>>> '/' + item.1) }}"
>>>   with_subelements: 
>>>     - authorized
>>>     - ssh_key_files
>>>   tags: 'users'
>>>
>>> Key file exists
>>>
>>> raja@ansible-control:~/ansible$ ll roles/users/files/keys/mimi/
>>> total 16
>>> drwxrwxr-x 2 raja raja 4096 May 16 15:04 ./
>>> drwxrwxr-x 4 raja raja 4096 May 16 15:04 ../
>>> -rw-rw-r-- 1 raja raja  740 May 16 09:10 id_rsa_mimi.pub
>>>
>>> When I run this, it says successful...
>>>
>>> TASK: [users | Copy SSH Keys] ******************************
>>> *******************
>>> <localhost> REMOTE_MODULE authorized_key user="mimi" key="" 
>>> manage_dir=yes
>>> <localhost> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-
>>> tmp-1400271971.73-135477642264398 && chmod a+rx 
>>> $HOME/.ansible/tmp/ansible-tmp-1400271971.73-135477642264398 && echo 
>>> $HOME/.ansible/tmp/ansible-tmp-1400271971.73-135477642264398']
>>> <localhost> PUT /tmp/tmpp3ljsQ TO /home/raja/.ansible/tmp/
>>> ansible-tmp-1400271971.73-135477642264398/authorized_key
>>> <localhost> EXEC /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via 
>>> ansible, key=banwdhwvmsabmqjcjmygxjkmjbmztflf] password: " -u root 
>>> /bin/sh -c '"'"'echo SUDO-SUCCESS-banwdhwvmsabmqjcjmygxjkmjbmztflf; 
>>> LC_CTYPE=C LANG=C /usr/bin/python /home/raja/.ansible/tmp/
>>> ansible-tmp-1400271971.73-135477642264398/authorized_key; rm -rf 
>>> /home/raja/.ansible/tmp/ansible-tmp-1400271971.73-135477642264398/ 
>>> >/dev/null 2>&1'"'"''
>>> ok: [localhost] => (item=({'username': 'mimi'}, 'id_rsa_mimi.pub')) => 
>>> {"changed": false, "item": [{"username": "mimi"}, "id_rsa_mimi.pub"], 
>>> "key": "", "key_options": null, "keyfile": 
>>> "/home/mimi/.ssh/authorized_keys", 
>>> "manage_dir": true, "path": null, "state": "present", "unique": false, 
>>> "user": "mimi"}
>>>
>>> However, it does not create .ssh directory or .ssh/authorized_keys on 
>>> the target machine/userHome...user is created as part of the same 
>>> role/tasks, just prior to this task. 
>>>
>>>
>>> Any idea what's going on?
>>>
>>  -- 
>> 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/a30277c9-800d-47c8-a8e2-8de2b94d3a41%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/a30277c9-800d-47c8-a8e2-8de2b94d3a41%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/9e3e3587-a565-44ab-bbe3-9d893c576e67%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to