On Friday, 24 August 2018 15.54.00 CEST Dimitri Yioulos wrote:
> 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?

Yes, but a registered variable will always be defined if the task is run or 
skipped.
So if you have the play Host1 before this, the variable import_job_count will 
be defined and the when will always be true.

And a tips to improve readability, you can write your with_items like this.

  with_items: 
    - ImportRecipientsService
    - ImportRecipientsService_V2
    - OnepointImportService_High
    - OnepointImportService_Higher
    - OnepointImportService_Highest
    - OnepointImportService_Low


-- 
Kai Stian Olstad


-- 
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/3024690.KWgSXdfAFu%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to