--- - name: get_groups_json template: dest=/tmp/groups src=groups.j2 - name: copy script copy: src=makehosts.py dest=/tmp/makehosts.py mode=755 - name: make hosts data command: /tmp/makehosts.py /tmp/groups {{ domain }} register: hosts_data - name: write hosts file template: dest=/tmp/etcHosts src=etcHosts.j2 - name: fetch hosts file fetch: src=/tmp/etcHosts dest=files/etcHosts flat=yes - name: make sure our repo server is resolvable lineinfile: path: files/etcHosts line: "{{ reposerverip }} {{ reposervername }}" owner: root group: root become: True when: reposerverip is defined and reposervername is defined