Skip to content

Instantly share code, notes, and snippets.

@gustavomcarmo
Created September 13, 2018 18:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gustavomcarmo/26519f7551ee54cf88e36b6109211d80 to your computer and use it in GitHub Desktop.
Save gustavomcarmo/26519f7551ee54cf88e36b6109211d80 to your computer and use it in GitHub Desktop.
Ansible playbook to backup all Docker volumes in a remote host and then upload the backup file to a raw Nexus repository.
---
- hosts: remote
gather_facts: no
tasks:
- name: Make the volumes backup
archive:
path: /var/lib/docker/volumes
dest: volumes.tar.gz
- name: Make the backup available (requires vault-password-file)
uri:
url: https://www.example.com/nexus/repository/backups/volumes.tar.gz
method: PUT
src: volumes.tar.gz
remote_src: true
user: admin
password: "{{ nexus_password }}"
force_basic_auth: yes
headers:
Content-Type: application/octet-stream
vars:
nexus_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000
register: upload_result
failed_when: upload_result.status != 201
changed_when: upload_result.status == 201
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment