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, 2019 in Ansible by Karthik
931 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, 2019 by Monish

Related Questions In Ansible

0 votes
1 answer
+1 vote
3 answers
+1 vote
2 answers
0 votes
1 answer
+15 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,058 views
+2 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, 2019 in Ansible by Sasha
899 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP