Update hosts file with host in group

17 views
Skip to first unread message

Roy

unread,
Aug 7, 2015, 4:10:35 PM8/7/15
to Ansible Project
Hi,

  I want to create host file with following requirements 


My inventory file

- name: Update /etc/hosts
  lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present
  when: hostvars[item].ansible_default_ipv4.address is defined
  with_items: groups['hadoop'] 

but here I need to run playbook on the group (hadoop), how can I just run on group children (hadoop-master, hadoop-slave, hadoop-gateway) or just one of the host & still get host entry for all hosts in the group.

any idea how to do that in ansible ?

Thanks
Reply all
Reply to author
Forward
0 new messages