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