Hi,

Just tried out the authorize_key example in the 'Looping over Subelements' section of the docs [1] and wonder if it's incorrect?

When I try the example it only saves the last key instead of all of them. Copy of example and output below.

I'm using Ansible 1.7.1.

Thanks,
Patrick

[1] http://docs.ansible.com/playbooks_loops.html#looping-over-subelements

vars:

users:
  - name: alice
    authorized:
      - roles/builder/files/alice/onekey.pub
      - roles/builder/files/alice/twokey.pub
      - roles/builder/files/bob/id_rsa.pub

tasks:

- name: Add authorized_keys
  authorized_key:
    user: "{{ item.0.name }}"
    key: "{{ lookup('file', item.1) }}"
  with_subelements:
    - users
    - authorized


TASK: [builder | builder | Add authorized_keys] ******************************* changed: [test.local] => (item=({'name': 'alice'}, 'roles/builder/files/alice/onekey.pub')) => {"changed": true, "item": [{"name": "alice"}, "roles/builder/files/alice/onekey.pub"], "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC2LvY73j+274/rqT/KkpxgMX0gjZ0dkY3YGxYtwMmgenCscTcsroPDELRPSrhRjzNHFgbcb9w4otlB/3Ax3XRpwENVsnv0k6B9LWj3whMr319fa1orRZVLet7rmiDf13jpaqp1cXEsKVM/3Ra0DH6e6hgfcG69JV9dr1Kya9hH0HUHGUkfy4mUo1mWQFdqRDe4Oo7sGsJMPoEkPSz+nSo0n+Ldn/0P9j/+4FxlnFHAdAuP7/94N60RmtgiIJsUx/zNpgEJMQzW7S9j8DwW5GoN1U0mU3moAresu1CN+6x3SKdLtO1NRlhI7Oe+err16tHB8gANLo645z99GeymrYzJ alice1 onekey.pub", "key_options": null, "keyfile": "/home/alice/.ssh/authorized_keys", "manage_dir": true, "path": null, "state": "present", "unique": false, "user": "alice"} changed: [test.local] => (item=({'name': 'alice'}, 'roles/builder/files/alice/twokey.pub')) => {"changed": true, "item": [{"name": "alice"}, "roles/builder/files/alice/twokey.pub"], "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC2LvY73j+274/rqT/KkpxgMX0gjZ0dkY3YGxYtwMmgenCscTcsroPDELRPSrhRjzNHFgbcb9w4otlB/3Ax3XRpwENVsnv0k6B9LWj3whMr319fa1orRZVLet7rmiDf13jpaqp1cXEsKVM/3Ra0DH6e6hgfcG69JV9dr1Kya9hH0HUHGUkfy4mUo1mWQFdqRDe4Oo7sGsJMPoEkPSz+nSo0n+Ldn/0P9j/+4FxlnFHAdAuP7/94N60RmtgiIJsUx/zNpgEJMQzW7S9j8DwW5GoN1U0mU3moAresu1CN+6x3SKdLtO1NRlhI7Oe+err16tHB8gANLo645z99GeymrYzJ alice2 twokey.pub", "key_options": null, "keyfile": "/home/alice/.ssh/authorized_keys", "manage_dir": true, "path": null, "state": "present", "unique": false, "user": "alice"} changed: [test.local] => (item=({'name': 'alice'}, 'roles/builder/files/bob/id_rsa.pub')) => {"changed": true, "item": [{"name": "alice"}, "roles/builder/files/bob/id_rsa.pub"], "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC2LvY73j+274/rqT/KkpxgMX0gjZ0dkY3YGxYtwMmgenCscTcsroPDELRPSrhRjzNHFgbcb9w4otlB/3Ax3XRpwENVsnv0k6B9LWj3whMr319fa1orRZVLet7rmiDf13jpaqp1cXEsKVM/3Ra0DH6e6hgfcG69JV9dr1Kya9hH0HUHGUkfy4mUo1mWQFdqRDe4Oo7sGsJMPoEkPSz+nSo0n+Ldn/0P9j/+4FxlnFHAdAuP7/94N60RmtgiIJsUx/zNpgEJMQzW7S9j8DwW5GoN1U0mU3moAresu1CN+6x3SKdLtO1NRlhI7Oe+err16tHB8gANLo645z99GeymrYzJ bob1 id_rsa.pub", "key_options": null, "keyfile": "/home/alice/.ssh/authorized_keys", "manage_dir": true, "path": null, "state": "present", "unique": false, "user": "alice"}

PLAY RECAP ********************************************************************
test-7.puzzled.xs4all.nl   : ok=3    changed=1    unreachable=0    failed=0

$ patrick@test ]# cat /home/alice/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC2LvY73j+274/rqT/KkpxgMX0gjZ0dkY3YGxYtwMmgenCscTcsroPDELRPSrhRjzNHFgbcb9w4otlB/3Ax3XRpwENVsnv0k6B9LWj3whMr319fa1orRZVLet7rmiDf13jpaqp1cXEsKVM/3Ra0DH6e6hgfcG69JV9dr1Kya9hH0HUHGUkfy4mUo1mWQFdqRDe4Oo7sGsJMPoEkPSz+nSo0n+Ldn/0P9j/+4FxlnFHAdAuP7/94N60RmtgiIJsUx/zNpgEJMQzW7S9j8DwW5GoN1U0mU3moAresu1CN+6x3SKdLtO1NRlhI7Oe+err16tHB8gANLo645z99GeymrYzJ bob1 id_rsa.pub

--
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/54163BE5.2010807%40puzzled.xs4all.nl.
For more options, visit https://groups.google.com/d/optout.

Reply via email to