On Wed, 24 Jun 2020 03:33:02 -0700 (PDT)
soumya dutta <[email protected]> wrote:

> ... run one task in only one server of a particular group.
> 
> [aws]
> server1
> server2
> 
> [gcp]
> server3
> server4

Split the playbook into two plays. For example

  - hosts: aws
    tasks:
      - debug:
          msg: Run this task on one server only
        run_once: true
  - hosts: gcp
    tasks:
      - debug:
          msg: Run this task on one server only
        run_once: true

You might want to put such tasks into a role. For example

  - hosts: aws
    tasks:
      - include_role:
          name: my_library_of_tasks
          tasks_from: task_on_one_server_only.yml
        run_once: true
  - hosts: gcp
    tasks:
      - include_role:
          name: my_library_of_tasks
          tasks_from: task_on_one_server_only.yml
        run_once: true

HTH,

        -vlado

-- 
Vladimir Botka

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200624163248.0b114135%40gmail.com.

Attachment: pgpv2Zw2Vatd6.pgp
Description: OpenPGP digital signature

Reply via email to