Error message saying variable undefines - Ansible

0 votes

I have not worked much with roles. 

site.yml

---

- hosts: user1_checkserverlist
  user: user1
  roles:
    - { role: speed_manager, DNAME: "/u" }

- hosts: oracle_checkserverlist
  user: oracle
  roles:
    - { role: speed_manager, DNAME: "/tmp" }
check.yml
---

   - name: ==== Reading Variable ====
     ping:
     vars:
         dn: "{{ diskname }}"

   - name: ====Sync  to remote hosts ====

     synchronize: src="/web/roles/speed_manager/files/" dest="/tmp/mohtt/"

   - name: ====Execute shell=============

     shell: /tmp/mohtt/fixwebserver.sh {{ dn }} chdir=/tmp/mohtt

Got the following error when tried to execute the playbook:

TASK [check_bk_speed_manager : ====Execute shell=============] *****************
task path: /web/roles/speed_manager/tasks/check.yml:25
fatal: [myserver.com]: FAILED! => {"failed": true, "msg": "'dn' is undefined"}
fatal: [myserver.com]: FAILED! => {"failed": true, "msg": "'dn' is undefined"}
        to retry, use: --limit @check_bk_speed.retry
Feb 9 in Ansible by Karthik
80 views

1 answer to this question.

0 votes

Hey @Karthik, you don't really have to use a different variable if one is already defined. You could use something like this:

- name: ====Execute shell=============
  shell: /tmp/mohtt/fixwebserver.sh {{ DNAME }} chdir=/tmp/mohtt

And include with just:

- include: check.yml
answered Feb 9 by Monish

Related Questions In Ansible

0 votes
1 answer
0 votes
3 answers
0 votes
1 answer
0 votes
1 answer
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
216 views
0 votes
1 answer
+1 vote
1 answer
0 votes
1 answer

Error saying "KeyError: 'ApiVersion'" - Ansible

The reason behind this error is that ...READ MORE

answered Jan 8 in Ansible by Sasha
26 views