So roles have a "files" directory and for some actions and attributes they 
are evaluated relative to this directory (e.g.: the "src" attribute of the 
"copy" module). So with:

# roles/common/tasks/main.yml
- name: Copy in ssh key files
  copy:
    src="devops.pem"
    dest="/home/{{ ansible_user_id }}/.ssh/id_rsa"
    mode=600
  tags:
    - ssh_key

src="devops.pem" will find my file in roles/common/files/devops.pem

For other actions, this doesn't work -- for example:

- name: Make sure that devops.pem is not group/world readable
  local_action: file path=devops.pem mode=600
  tags:
    - ssh_key
    - ssh_key_local

In this case, it will not find the file in roles/common/files/devops.pem -- 
it seems to look for the file relative to the playbook?

How can I reference a file relative to the role I'm referencing it in? -- 
e.g.: something like:

- name: Make sure that devops.pem is not group/world readable
  local_action: file path={{ current_role_dir }}/files/devops.pem mode=600
  tags:
    - ssh_key
    - ssh_key_local

-- 
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/3eb883b1-8c1d-4d48-8c99-f1a6e48d2944%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to