1

Am trying to use kubernetes ansible module for creating the kubectl secret, below is my command

kubectl create secret generic -n default test --from-file=gcp=serviceaccount.json

Do we have any way to pass service account json file(--from-file=gcp=serviceaccount.json) in Ansible k8s module,

how to pass this --from-file in the below module?

- name: CREATE SECRET
    k8s:
      state: present
      definition: 
        apiVersion: v1
        kind: Secret
        type: Opaque             
        metadata:
          name: test
          namespace: default     
        data:
         ?? : ??
sasi
  • 4,192
  • 4
  • 28
  • 47

1 Answers1

0

Am able to resolve the issue with stringData option.

Ive passed the content of the file with stringData option

- name: CREATE SECRET
    k8s:
      state: present
      definition: 
        apiVersion: v1
        kind: Secret
        type: Opaque             
        metadata:
          name: test
          namespace: default     
        stringData:
          content of the file
sasi
  • 4,192
  • 4
  • 28
  • 47