- hosts: '{{hosts}}' remote_user: root tasks: - name: rsync hosts lineinfile: dest: /etc/hosts line: "{{ item }}" with_items: - "192.168.13.127 elk" - "192.168.13.128 elk2" - "192.168.13.129 elk3" # ansible-playbook /etc/ansible/rsync_hosts.yml -e "hosts=java" --private-key=/etc/ansible/new_www.key