Skip to content

Instantly share code, notes, and snippets.

@lanky
Last active October 7, 2016 13:52
Show Gist options
  • Save lanky/20f28ab072e9a991928eb9700255bc86 to your computer and use it in GitHub Desktop.
Save lanky/20f28ab072e9a991928eb9700255bc86 to your computer and use it in GitHub Desktop.
---
# vim: set ft=ansible:
- name: find files
hosts: localhost
tasks:
- name: find local configuration files
find:
paths: resources-minimal
patterns: "*.yml"
register: configfiles
- name: push and test
hosts: hostA:hostB
tasks:
- include: repeatme.yml
with_items: "{{ configfiles.files }}"
################# repeatme.yml ###########
---
# task include file, run once for each item in our file list
- name: copy config file
copy:
src: "{{ item }}"
dest: /path/to/destination
when: inventory_hostname == "hostA"
- name: reload service on hostA
service:
name: myservice
state: restarted
when: inventory_hostname == "hostA"
- name: perform GET test from B
get_url:
url: URL TO HOST A
when: inventory_hostname == hostB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment