How can I create a Kubernetes Secret with Ansible?
Here is my example, that works for me, hope it help.
- name: CREATE MONGOSECRETS SECRET k8s: state: present definition: apiVersion: v1 kind: Secret type: Opaque metadata: name: "{{ secret_name }}" namespace: "{{ project_name | lower }}" data: config_data.json: "{{ lookup('template', mongo_conn_templates_path + '/config_data.json' ) | tojson | b64encode }}"