moustaches don't stack and concatenation (+) does not work outside moustaches:

 authorized_key: user=root key="{{ lookup('file', role_path +
'/files/public_keys/' + item.1) }}"

On Thu, Jan 7, 2016 at 3:16 PM, Colin Byrne <[email protected]> wrote:
> Hey so I have a list of developer names in a dictionary and I am trying to
> do a file lookup on their ssh key,
>
> I want to dynamically build the file path for each key as opposed to
> specifying it the full path for each developer.
>
> Here is my task:
>
> ---
>   - name: Set up authorized_keys for the root user
>     authorized_key: user=root key="{{ lookup('file', {{ role_path }} +
> '/files/public_keys/' + {{ item.1 }} ) }}"
>     with_subelements:
>       - ssh_users
>       - names
>
>
>
> I haven't been able to get those variables to evaluate within the file
> lookup (I have tried many other syntaxes to try to achieve this).  I know I
> am importing them properly as I can get them to evaluate outside of the file
> lookup with something like the following, but then they whole string is not
> evaluated as a file.
>
>
> ---
>
>   - name: Set up authorized_keys for the root user
>
>    authorized_key: user=root key={{ role_path }} + '/files/public_keys/' +
> {{ item.1 }}
>
>    with_subelements:
>
>      - ssh_users
>
>      - names
>
>
>
> Here is my dictionary with the embedded lists:
>
> ---
> ssh_users:
>   - group: admin
>     names:
>        - bob
>        - dave
>   - group: developers
>     names:
>        - tim
>        - susan
>   - group: analysts
>     names:
>        - mike
>        - steve
>
>
>
> I am open to changing the task in an way shape or form to achieve this.
>
> Thanks for any help!
>
>
> --
> 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/605d42f9-0caa-46b1-929b-cd0d662e4ad4%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
Brian Coca

-- 
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/CAJ5XC8%3DMgRKTZT-Zc8-isiKueuHojSMd6KH1j8Et8twGthoS6g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to