Last active
November 5, 2018 20:20
-
-
Save rbreslow/af2d9bbcc600e5f87313d7c044fc0c60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: nexus | |
connection: paramiko | |
become: True | |
vars: | |
nexus_data_bucket: rasterfoundry-development-data-us-east-1 | |
service_definition: | |
version: "3" | |
services: | |
nexus-nginx: | |
image: nginx:1.14 | |
networks: | |
- nexus | |
ports: | |
- 80:80 | |
volumes: | |
- "{{ service_home }}/nginx/nexus.conf:/etc/nginx/conf.d/default.conf" | |
restart: on-failure | |
logging: | |
driver: syslog | |
options: | |
tag: nexus-nginx | |
nexus-server: | |
image: sonatype/nexus3:3.13.0 | |
networks: | |
- nexus | |
volumes: | |
- /var/cache/nexus:/nexus-data | |
restart: on-failure | |
logging: | |
driver: syslog | |
options: | |
tag: nexus-server | |
networks: | |
nexus: | |
pre_tasks: | |
- name: Update APT cache | |
apt: update_cache=yes cache_valid_time=3600 | |
tasks: | |
- name: Install Ansible aws_s3 module dependencies | |
pip: | |
name: "{{ item }}" | |
state: latest | |
with_items: | |
- boto | |
- boto3 | |
- botocore | |
- name: Download nexus-data backup from S3 | |
aws_s3: bucket="{{ nexus_data_bucket }}" object="nexus-data-backup.tar.gz" | |
mode=get dest=/tmp/nexus-data-backup.tar.gz | |
profile=default overwrite=different | |
become_user: azavea | |
register: nexus_data_updated | |
- name: Stop Nexus | |
docker_service: project_name=nexus | |
definition="{{ service_definition }}" | |
state=absent | |
- name: Unpack nexus-data backup | |
unarchive: src=/tmp/nexus-data-backup.tar.gz dest=/ | |
remote_src=yes | |
when: nexus_data_updated.changed | |
notify: | |
- Restart Nexus | |
- name: Start Nexus | |
docker_service: project_name=nexus | |
definition="{{ service_definition }}" | |
state=present | |
- name: Remove Ansible aws_s3 module dependencies | |
pip: | |
name: "{{ item }}" | |
state: absent | |
with_items: | |
- boto | |
- boto3 | |
- botocore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment