0

I want to add some new pub keys, when use the

authorized_key
module, it seems that ansible overwirte all records. playbook:

- name: add key
  authorized_key:
    user: "{{ user if user is defined else 'ubuntu' }}"
    state: present
    key: '{{ item }}'
    exclusive: no
#  comment: "test add comment from playbook"
  with_file:
    - public-keys/test-add.pub
    - public-keys/test-add-doge.pub

and the files:

roles/add-ssh-key/files/
└── public-keys
    ├── test-add-doge.pub
    └── test-add.pub

1 directory, 2 files

after I executed the playbook

ansible-playbook add.yml
, the
~/.ssh/authorized_keys
file was overwrited, it only remains 2 records which are
test-add.pub
and
test-add-doge.pub

So how can I keep original records without overwriting?

Anonymous Asked question May 14, 2021