On 20. feb. 2017 17:46, Acrobis Nubian wrote:
Hi all,

If someone could help me on the following:

I am trying to automate as maximum as possible the addition of authorized
keys to my new remote servers by doing the below playbook, but I am getting
the following error:
===============================================================
fatal: [web]: FAILED! => {"failed": true, "msg": "'list object' has no
attribute 'name'"}
fatal: [db]: FAILED! => {"failed": true, "msg": "'list object' has no
attribute 'name'"}
===============================================================

I've tried playing with the list of variables, tried also new loop
with_item after the with_file, still no good luck, could someone please
tell me how can I achieve my goal by having authorized_key module going to
each file without specifying each time the full address like
public_keys/web/authorized_key

- hosts: all
  vars:
    pcs:
      - name: web
      - name: db
  tasks:
  - name: Set up authorized_keys for the deploy user
    authorized_key: user=root key="{{ item }}"
    with_file:
      - public_keys/{{ pcs.name }}/authorized_key


Something like this should work:

- name: Set up authorized_keys for the deploy user
authorized_key: user=root key="{{ lookup('file', 'public_keys/{{ item.name }}/authorized_key') }}"
  with_items: pcs

--
Kai Stian Olstad

--
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/0462dfef-3ddf-e584-4e11-3616c25e72f2%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to