Variable is Undefined error

35 views
Skip to first unread message

nandha kumar

unread,
Aug 9, 2019, 8:49:13 AM8/9/19
to Ansible Project
Hello Team,

I am trying to use the variable in the following task which i registered in the previous task.
However, i am getting "variable is undefined error"
Could you please suggest us,what could be the reason

Thanks,
Nandhakumar

Dick Visser

unread,
Aug 9, 2019, 8:53:49 AM8/9/19
to ansible...@googlegroups.com
Hi

Could you please tell clearly:

What the relevant tasks/playbooks/code/variables look like
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/71692be3-f531-480a-825b-8052c63924d2%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

nandha kumar

unread,
Aug 9, 2019, 9:15:23 AM8/9/19
to ansible...@googlegroups.com
Do you want me to post the playbook Dick?

Thanks,
Nandhakumar

Angel Rengifo Cancino

unread,
Aug 9, 2019, 9:16:28 AM8/9/19
to Ansible Project
Hi:
Please share as much details as possible of your code and the way you invoke it from CLI. We cannot guess!

Thanks,
Nandhakumar

nandha kumar

unread,
Aug 9, 2019, 9:23:59 AM8/9/19
to ansible...@googlegroups.com
Hello Angel,Dick,

Below is my playbook:
***********************************************************************************
---
- hosts: all
  gather_facts: False
  roles:
    - pagefile
- name: STOP_Services_CMS
  hosts: cmsserver
  gather_facts: False
  tasks:
    - name: Get services for Datasevices
      win_shell: 'Get-Service | Where {($_.DisplayName -like "*Apache*") -OR ($_.DisplayName -like "*Server Intell*")} | Select-Object Name, DisplayName | ConvertTo-Json'
      register: nandhu
    - name: Stop services of Dataservices
      win_service:
        name: "{{ item.Name }}"
        state: stopped
      with_items: "{{ nandhu.stdout }}"
- name: STOP_Services_JS
  hosts: jobserver
  gather_facts: False
  tasks:
    - name: Stop services in Job servers
      win_service:
        name: DI_JOBSERVICE
        state: stopped
      register: service_status
    - debug:
        var: service_status.state
- name: reboot the servers
  hosts: cmsserver
  gather_facts: False
  tasks:
    - name: reboot the CMS_servers
      win_reboot:
      when: service_status.state == 'stopped'
      register: reboot_CMS
- name: reboot the_Jobservers
  hosts: jobserver
  gather_facts: False
  tasks:
    - name: Reboot the Jobs servers
      win_reboot:
      register: reboot_Jobserver
***********************************************************************************************
in First step ,i am trying to find the pagefile szie in windows servers and changing the page file size as well.
that is what the role "pagefile" does.
Once the role is completed, services needs to be stopped in all servers in sequence.
first in CMS server group and then job_server group.

Reboot has to be done,only the registered value is equal to "stopped"

Here is the problem comes.
 I am getting the registered variable as expected. however, reboot is not happening and failing with undefined register varaible error
Please help me to get the issue resolved


Thanks,
Nandhakumar

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.

Angel Rengifo Cancino

unread,
Aug 9, 2019, 9:41:22 AM8/9/19
to Ansible Project
As I see, you're trying to use variables from one host or group of hosts (cmsserver) from another different group (jobserver). Those variables have a name in common but they're still different; you can't use reference them as if they were the same.

But I believe this post might help you:


Hope that helps
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.

nandha kumar

unread,
Aug 12, 2019, 3:24:00 AM8/12/19
to ansible...@googlegroups.com
Hello Angel,

i have gone through the document.
The articles talks about the values which can be gathered os gather_Facts.
My case is bit different.Mine is a custom output which i am storing in a different register
so kindly suggest the way to get a solution for this

Thanks,
Nandhakumar

To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/57879cab-7d2d-4665-92e7-dac93b63e788%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages