On 27/11/2013 20:24, Khuong Dinh Pham wrote:
> Hi
> 
> I have this setup in my hosts
> 
> server1 ansible_ssh_host=server1.xxx.com
> server2 ansible_ssh_host=server2.yyy.com
> server3 ansible_ssh_host=server3.yyy.com
> 
> [frontendservers]
> server1
> server2
> server3
> 
> [frontendcluster1]
> server1
> server2
> 
> My playbook:
> ---
>   hosts: frontendservers
>   tasks:
>     - name: testing
>       command: copy some file
>       when: $host part of 'frontendcluster1' group
> 
> I only want the command to be executed for server1 and server2? How can
> I achieve that?

Hi Khuong,

Just create a group for these hosts, and change your hosts: line in the
playbook :

[onlythose]
server1
server2



- hosts: onlythose
  tasks:
    - name: testing
      command: copy some file


Cheers,

M
-- 
Michel Blanc
{ :github => "@leucos", :twitter => "@b9m", :gpg => "0X24B35C22" }

-- 
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].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to