Is it possible to create and k8s secret from a file in ansible?
Currently, I am doing it like this but it only works on the first run because if I run the playbook again it says the secret already exists
- name: generate keypair
openssh_keypair:
path: /srv/{{item.namespace}}/id_{{item.name}}_rsa
when: item.additional_keys == true
loop: "{{ containers_release }}"
- name: create private key secret for auth api
shell: kubectl -n {{ item.namespace }} create secret generic id-{{ item.name }}-rsa-priv --from-file=/srv/{{ item.namespace }}/id_authapi_rsa
when: item.additional_keys == true
loop: "{{ containers_release }}"
- name: create public key secret for {{ item.name }}
shell: kubectl -n {{ item.namespace }} create secret generic id-{{ item.name }}-rsa-pub --from-file=/srv/{{ item.namespace }}/id_{{ item.name }}_rsa.pub
when: item.additional_keys == true
loop: "{{ containers_release }}"