fix: restore command now seperated
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
- name: Make build artifact.
|
||||
hosts: localhost
|
||||
vars_files: ../config/ansible.json
|
||||
vars_files: ../config/ansible.secret.json
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Build image.
|
||||
community.docker.docker_image_build:
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
- name: Deploy artifact to instance.
|
||||
hosts: localhost
|
||||
become: true
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
- ../config/ansible.json
|
||||
- ../config/infrastructure.json
|
||||
- ../config/ansible.secret.json
|
||||
- ../config/infrastructure.secret.tf.json
|
||||
vars:
|
||||
ansible_connection: aws_ssm
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
@@ -26,15 +27,17 @@
|
||||
access_key: "{{ aws_access_key }}"
|
||||
secret_key: "{{ aws_secret_key }}"
|
||||
|
||||
- name: Create data directory.
|
||||
ansible.builtin.file:
|
||||
path: /home/ssm-user/data
|
||||
state: directory
|
||||
mode: '0777'
|
||||
|
||||
- name: Load image.
|
||||
community.docker.docker_image_load:
|
||||
path: /root/image.tar.gz
|
||||
register: image
|
||||
|
||||
- name: Create a volume.
|
||||
community.docker.docker_volume:
|
||||
name: data
|
||||
|
||||
- name: Run image.
|
||||
community.docker.docker_container:
|
||||
name: server
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
- name: Deploy artifact to instance.
|
||||
hosts: localhost
|
||||
become: true
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
- ../config/ansible.json
|
||||
- ../config/infrastructure.json
|
||||
- ../config/ansible.secret.json
|
||||
- ../config/infrastructure.secret.tf.json
|
||||
vars:
|
||||
ansible_connection: aws_ssm
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
@@ -27,23 +28,38 @@
|
||||
access_key: "{{ boot_id.value }}"
|
||||
secret_key: "{{ boot_secret.value }}"
|
||||
amazon.aws.s3_object:
|
||||
bucket: "{{ boot_bucket }}"
|
||||
object: "{{ boot_key }}"
|
||||
dest: /home/ssm-user/backup.tar.xz
|
||||
bucket: "{{ restore_bucket | mandatory(msg='You must specify the bucket of the data.') }}"
|
||||
object: "{{ restore_key | mandatory(msg='You must specify the key of the data.') }}"
|
||||
dest: /home/ssm-user/backup.tar.gz
|
||||
mode: get
|
||||
|
||||
- name: Ensure backup directory exists.
|
||||
ansible.builtin.file:
|
||||
path: /home/ssm-user/data
|
||||
path: /home/ssm-user/backup
|
||||
state: directory
|
||||
mode: '0777'
|
||||
|
||||
- name: Extract backup.
|
||||
ansible.builtin.unarchive:
|
||||
src: /home/ssm-user/backup.tar.xz
|
||||
dest: /home/ssm-user/data
|
||||
src: /home/ssm-user/backup.tar.gz
|
||||
dest: /home/ssm-user/backup
|
||||
remote_src: true
|
||||
|
||||
- name: Move backup files to data folder.
|
||||
ansible.builtin.copy:
|
||||
remote_src: true
|
||||
src: /home/ssm-user/backup/backup/my-app-backup/
|
||||
dest: /home/ssm-user/data/
|
||||
mode: '0777'
|
||||
|
||||
- name: Update permissions.
|
||||
ansible.builtin.file:
|
||||
path: /home/ssm-user/data
|
||||
recurse: true
|
||||
mode: '0777'
|
||||
owner: 1000
|
||||
group: 1000
|
||||
|
||||
- name: Restart containers.
|
||||
community.docker.docker_container:
|
||||
name: "{{ item }}"
|
||||
|
||||
Reference in New Issue
Block a user