Beautiful, Kai, thanks! I was just testing something like that, and it
seems to work:
- hosts: Host2
gather_facts: false
tasks:
- name: Stop 1Point Import Services
win_service: name={{ item }} state=stopped
with_items:
["ImportRecipientsService","ImportRecipientsService_V2","OnepointImportService_High","OnepointImportService_Higher","OnepointImportService_Highest","OnepointImportServi
ce_Low"]
*when: hostvars['Host1']['import_job_count'] is defined*
tags:
- stop_opm_import_services
Does that seem right to you?
On Friday, August 24, 2018 at 8:44:40 AM UTC-4, Dimitri Yioulos wrote:
>
> Hello, all.
>
> I've created the following playbook:
>
> ---
>> - hosts: Host1
>> gather_facts: false
>> tasks:
>> - name: SQL Query Pending Import Jobs
>> script: /etc/ansible/files/mssql_opm_getImportJobs.ps1
>> register: import_job_count
>> - debug:
>> msg: "Number of running imports: {{ import_job_count.rc }}"
>> tags:
>> - test
>> - hosts: Host2
>> gather_facts: false
>> tasks:
>> - name: Stop 1Point Import Services
>> win_service: name={{ item }} state=stopped
>> with_items:
>> ["ImportRecipientsService","ImportRecipientsService_V2","OnepointImportService_High","OnepointImportService_Higher","OnepointImportService_Highest","OnepointImportServi
>> ce_Low"]
>> when: import_job_count.stdout == "0"
>> tags:
>> - stop_opm_import_services
>
>
> As I hope you can see, the idea is to use the register value from the
> first play to work in the second, which is aimed at another host. I get
> "'import_job_count' is undefined" because the register value doesn't
> persist. Is there any way to do this?
>
> With thanks.
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/78ebb43b-354f-4945-b70b-79bb1c049e4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.