title: Receiving error AnsibleUndefinedVariable while executing my ansible playbook
body: <p><em><strong>YAML File (nsupdate.yml)</strong></em></p>
  <p>This is the yaml file to install multiple packages on the remote server.</p>
  <pre class="lang-yaml prettyprint-override"><code>- hosts: nsupdate
          
    remote_user: root
    roles:
      - postfix
      - nginx
      - certbot
      - bind9
      - postgresql
      - nsupdate_info
  </code></pre>
  <p><strong>host file</strong></p>
  <p>This is the host file and remote server IP is mentioned in it</p>
  <pre><code>[nsupdate]
  101.50.x.x (host IP Address)
  </code></pre>
  <p><strong>Error Received</strong>
  When I run this playbook, error is received that variable 'nsupdate' is not defined. However, I have defined it in the host file.</p>
  <pre><code>[root@games ansible-nsupdate.info]# ansible-playbook nsupdate.yml
  
  PLAY [nsupdate] **********************************************************************************************************************************************
  
  TASK [Gathering Facts] ***************************************************************************************************************************************
  ok: [101.50.x.x]
  
  TASK [postfix : Install Postfix] *****************************************************************************************************************************
  ok: [101.50.x.x]
  
  TASK [postfix : Install Postfix configuration] ***************************************************************************************************************
  failed: [101.50.x.x] (item={u'dest': u'/etc/postfix/main.cf', u'src': u'main.cf.j2'}) =&gt; {&quot;ansible_loop_var&quot;: &quot;item&quot;, &quot;changed&quot;: false, &quot;item&quot;: {&quot;dest&quot;: &quot;/etc/postfix/main.cf&quot;, &quot;src&quot;: &quot;main.cf.j2&quot;}, &quot;msg&quot;: &quot;AnsibleUndefinedVariable: 'nsupdate' is undefined&quot;}
  
  PLAY RECAP ***************************************************************************************************************************************************
  101.50.x.x              : ok=2    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
  
      
  </code></pre>
  <p><strong>Error received is within this task file</strong></p>
  <p>This is the task file for installation of Postfix package.</p>
  <p><strong><code>main.yml</code></strong></p>
  <pre class="lang-yaml prettyprint-override"><code>- name: Install Postfix
    apt:
      pkg: [ &quot;postfix&quot;, &quot;libsasl2-modules&quot; ]
      install_recommends: false
     
  - name: Install Postfix configuration
    template:
      src: &quot;{{ item.src }}&quot;
      dest: &quot;{{ item.dest }}&quot;
      mode: 0644
    with_items:
      - { src: &quot;main.cf.j2&quot;, dest: &quot;/etc/postfix/main.cf&quot; }
      - { src: &quot;header_check.j2&quot;, dest: &quot;/etc/postfix/header_check&quot; }
      - { src: &quot;sender_canonical_maps.j2&quot;, dest: &quot;/etc/postfix/sender_canonical_maps&quot; }
    notify: reload postfix
  </code></pre>
  <p>Can anyone please suggest how to fix this error/issue.</p>