0

I want to pass a variable in the Jinja file template and use it as src for the community.kubernetes.k8s module

- name: deploy the config-file
  community.kubernetes.k8s:
    state: present
    src: templates/fluentbit-config.yml.j2

fluentbit-config.yml.j2 is below:

apiVersion: logging.kubesphere.io/v1alpha2
kind: FluentBitConfig
metadata:
  name: "{{ fluentBitConfigName }}"
  namespace: kubesphere-logging-system
  labels:
    app.kubernetes.io/name: fluent-bit
spec:
  inputSelector:
    matchLabels:
      logging.kubesphere.io/enabled: "true"
  outputSelector:
    matchLabels:
      logging.kubesphere.io/enabled: "true"

It is not able to the variable from the defaults.

Navneet Nandan Jha
  • 1,416
  • 2
  • 17
  • 22
  • 2
    Instead of `src:`, use the [`template:` parameter](https://docs.ansible.com/ansible/latest/collections/community/kubernetes/k8s_module.html#parameter-template) to specify the template file. – Chin Huang Jun 17 '21 at 16:43
  • Thank you @ChinHuang. This is what exactly I was looking for. I feel so dumb right now not reading the full module docs. – Navneet Nandan Jha Jun 18 '21 at 07:00

0 Answers0