ansible/playbooks/manual/sync-hosts.yml

30 lines
883 B
YAML
Raw Normal View History

2020-09-28 16:59:08 -05:00
# Synchronizes files in /tmp/staging between remote hosts
# The following variables need to be supplied with the
# --extra-vars flag for the playbook to work:
2020-09-28 16:59:08 -05:00
# 'remote_src_host', 'remote_dest_host'
#
# Example:
# ansible-playbook sync-hosts.yml --extra-vars \
# "remote_src_host=bodhi-backend01.iad2.fedoraproject.org \
# remote_dest_host=sundries01.iad2.fedoraproject.org"
---
- hosts: localhost
user: root
2020-09-28 16:59:08 -05:00
tasks:
2020-09-28 16:59:08 -05:00
- name: copy files from remote_src_host to control node
run_once: yes
fetch:
src: /tmp/staging
dest: /tmp/staging
2020-09-28 16:59:08 -05:00
flat: yes
validate_checksum: yes
when: "{{ inventory_hostname == 'remote_src_host' }}"
2020-09-28 16:59:08 -05:00
- name: copy files from control node to remote_dest_host
ansible.builtin.copy:
src: /tmp/staging
2020-09-28 16:59:08 -05:00
dest: /tmp/staging
when: "{{ inventory_hostname == 'remote_dest_host' }}"