title: How to pass variables to a Kubernetes YAML file from Ansible?
body: <p>I am to trying to pass variables to kubernetes YAML file from Ansible but somehow values are not being populated.</p>
  
  <p>Here is my playbook:</p>
  
  <pre><code>- hosts: master
    gather_facts: no
    vars:
      logstash_port: 5044
    tasks:
     - name: Creating kubernetes pod
       command: kubectl create -f logstash.yml
  </code></pre>
  
  <p><code>logstash.yml</code>:</p>
  
  <pre><code>apiVersion: v1
  kind: Pod
  metadata: logstash
  spec:
    containers:
    - name: logstash
      image: logstash
      ports:
        - containerPort: {{ logstash_port }}
  </code></pre>
  
  <p>Is there a better way to pass arguments to Kubernetes YAML file that is being invoked using command task?</p>