Adicione várias chaves SSH usando ansible

Eu escrevi um script ansible para remover chaves SSH de servidores remotos:

---
- name: "Add keys to the authorized_keys of the user ubuntu"
  user: ubuntu
  hosts: www
  tasks:
  - name: "Remove key #1"
    authorized_key: user=ubuntu key="{{ item }}" state=absent
    with_file:
     - id_rsa_number_one.pub
  - name: "Remove key #2"
    authorized_key: user=ubuntu key="{{ item }}" state=absent
    with_file:
     - id_rsa_number_two.pub
...

Adicionar cada arquivo como uma tarefa diferente é absurdo, então tentei usarwith_fileglob:

  - name: "Remove all keys at once"
    authorized_key: user=ubuntu key="{{ item }}" state=absent
    with_fileglob:
      - /Users/adamatan/ansible/id_rsa*.pub

Mas isso falha com linhas como esta:

falhou: [www.example.com] => (item = / Usuários / adamatan / ansible / id_rsa_one.pub) => {"falhou": true, "item": "/Users/adamatan/ansible/id_rsa_one.pub" } msg: chave inválida especificada: /Users/adamatan/ansible/id_rsa_one.pub

O mesmo arquivo-chave é removido com êxito usando uma tarefa exclusiva, mas falha quando faz parte de umfileglob.

Como posso adicionar ou remover em lote chaves SSH usando o ansible?

questionAnswers(1)

yourAnswerToTheQuestion