You could certainly do this all in one expression:

{{ lookup('file', lookup('pipe', 'hg root') +
'../source/deploy/ansible/id_rsa.pub') }}

Or if you could find the pub key file relative to the location of the
playbook instead, use the playbook_dir magic variable (
http://docs.ansible.com/playbooks_variables.html) to resolve the path.

-Tim

On Sun, Jan 4, 2015 at 9:04 AM, Roy Smith <[email protected]> wrote:

> I need to install my ssh public key on a host.  I've got my public key
> checked into my source tree.  I don't want to hard-wire the location of my
> source tree, so I use lookup('pipe', 'hg root') to find the root of my tree
> and all my file references are relative to that.  So, I've got something
> like
>
>
>   vars:
>     local_base_dir: "{{ lookup('pipe', 'hg root') }}/.."
>     path: "{{ local_base_dir }}/source/deploy/ansible/id_rsa.pub"
>     ssh_key: "{{ lookup('file', path) }}"
>
>   tasks:
>   - name: add authorized ssh keys
>     sudo: yes
>     authorized_key: user=xxx key="{{ ssh_key }}"
>
>
> This works, but it seems needlessly complicated.  Is there some way to
> avoid having to generate the temporary path and ssh_key variables?
>
>
> --
> Roy Smith
> [email protected]
>
>  --
> 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/BA7D579C-CE60-4162-ADD3-F59FA4BFBDA8%40panix.com
> <https://groups.google.com/d/msgid/ansible-project/BA7D579C-CE60-4162-ADD3-F59FA4BFBDA8%40panix.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/CAH4wdVU%2BDo%3DsyzckVL%3DcY7UswgK7KvtuyxBz7Q7p4TCjGS1dBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to