{"action":"opened","issue":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/4780","repository_url":"https://api.github.com/repos/ansible/ansible-modules-core","labels_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/4780/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/4780/comments","events_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/4780/events","html_url":"https://github.com/ansible/ansible-modules-core/issues/4780","id":176204755,"number":4780,"title":"\"authorized_key\" rearranges the keys and comments in the pre-existing authorized_keys file","user":{"login":"gerhard-tinned","id":1536065,"avatar_url":"https://avatars.githubusercontent.com/u/1536065?v=3","gravatar_id":"","url":"https://api.github.com/users/gerhard-tinned","html_url":"https://github.com/gerhard-tinned","followers_url":"https://api.github.com/users/gerhard-tinned/followers","following_url":"https://api.github.com/users/gerhard-tinned/following{/other_user}","gists_url":"https://api.github.com/users/gerhard-tinned/gists{/gist_id}","starred_url":"https://api.github.com/users/gerhard-tinned/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gerhard-tinned/subscriptions","organizations_url":"https://api.github.com/users/gerhard-tinned/orgs","repos_url":"https://api.github.com/users/gerhard-tinned/repos","events_url":"https://api.github.com/users/gerhard-tinned/events{/privacy}","received_events_url":"https://api.github.com/users/gerhard-tinned/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-10T21:45:05Z","updated_at":"2016-09-10T21:45:05Z","closed_at":null,"body":"<!--- Verify first that your issue/request is not already reported in GitHub -->\r\n\r\n##### ISSUE TYPE\r\n<!--- Pick one below and delete the rest: -->\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\n<!--- Name of the plugin/module/task -->\r\nsystem/authorized_key\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from “ansible --version” between quotes below -->\r\n```\r\nansible 2.1.1.0\r\n```\r\n\r\n##### CONFIGURATION\r\n<!---\r\nMention any settings you have changed/added/removed in ansible.cfg\r\n(or using the ANSIBLE_* environment variables).\r\n-->\r\n\r\n##### OS / ENVIRONMENT\r\n<!---\r\nMention the OS you are running Ansible from, and the OS you are\r\nmanaging, or say “N/A” for anything that is not platform-specific.\r\n-->\r\nManaging from: LinuxMint\r\nManaging: CentOS 6\r\n\r\n##### SUMMARY\r\n<!--- Explain the problem briefly -->\r\nauthorized_key is re-ordering the lines in a pre-existing authorized_keys file. This causes comments and the related lines to be re-ordered.\r\n\r\n##### STEPS TO REPRODUCE\r\n<!---\r\nFor bugs, show exactly how to reproduce the problem.\r\nFor new features, show how the feature would be used.\r\n-->\r\nThe managed host (B) should have a authorized_keys file containing multiple keys and comments. Example could look like this:\r\n\r\n```\r\n# The following is allice's key\r\nssh-rsa <key content-removed> ssh-key-comment-allice\r\n# The following is bob's key\r\nssh-rsa <key content-removed> ssh-key-comment-bob\r\n# The following is eve's key\r\nssh-rsa <key content-removed> ssh-key-comment-eve\r\n\r\n```\r\nAfter adding a key from another host (A) to the host (B) using the \"authorized_key\" task, below the pre-existing authorized_keys file as shown above is completely reordered.\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n```\r\n---\r\n- name: Generate ssh key on host (A)\r\n  user: name=root generate_ssh_key=yes ssh_key_bits=4096 ssh_key_file=.ssh/id_rsa ssh_key_type=rsa\r\n\r\n- name: Download generated ssh key from host (A)\r\n  fetch: src=/root/.ssh/id_rsa.pub dest=/tmp/ansible/{{ ansible_hostname }}_id_rsa.pub \r\n         flat=yes validate_checksum=yes\r\n\r\n- name: Upload/install the ssh-key from host (A) to host (B)\r\n  authorized_key: user=root state=present \r\n      key=\"{{ lookup('file', '/tmp/ansible/{{ ansible_hostname }}_id_rsa.pub') }}\"\r\n  delegate_to: \"{{ host_B }}\"\r\n```\r\n\r\n\r\n\r\n<!--- You can also paste gist.github.com links for larger files -->\r\n\r\n##### EXPECTED RESULTS\r\n<!--- What did you expect to happen when running the steps above? -->\r\n```\r\n# The following is allice's key\r\nssh-rsa <key content-removed> ssh-key-comment-allice\r\n# The following is bob's key\r\nssh-rsa <key content-removed> ssh-key-comment-bob\r\n# The following is eve's key\r\nssh-rsa <key content-removed> ssh-key-comment-eve\r\nssh-rsa <key content-removed> ssh-key-comment-joe\r\n```\r\nAs shown in the example, it would be expected to see the added key (in the example \"joe\") at the end of the file keeping the pre-existing lines unchanged.\r\n\r\n##### ACTUAL RESULTS\r\n<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->\r\nThe result of the reordering might look like this containing the added key for \"joe\". The exact reason and ordering is not known at this point as of such the following example is just an example.\r\n\r\n```\r\n# The following is allice's key\r\nssh-rsa <key content-removed> ssh-key-comment-eve\r\n# The following is eve's key\r\nssh-rsa <key content-removed> ssh-key-comment-joe\r\n# The following is bob's key\r\nssh-rsa <key content-removed> ssh-key-comment-allice\r\nssh-rsa <key content-removed> ssh-key-comment-bob\r\n\r\n```\r\n<!--- Paste verbatim command output between quotes below -->\r\n\r\n"}}
{"actor":{"display_login":"gerhard-tinned"}}