chore: cleaned up ansible playbooks
This commit is contained in:
12
Taskfile.yml
12
Taskfile.yml
@@ -1,5 +1,4 @@
|
|||||||
version: 3
|
version: 3
|
||||||
# silent: true
|
|
||||||
|
|
||||||
includes:
|
includes:
|
||||||
tf: { taskfile: terraform, dir: terraform }
|
tf: { taskfile: terraform, dir: terraform }
|
||||||
@@ -7,14 +6,9 @@ includes:
|
|||||||
tasks:
|
tasks:
|
||||||
dev: docker compose -f compose.dev.yml up --build --force-recreate --no-deps
|
dev: docker compose -f compose.dev.yml up --build --force-recreate --no-deps
|
||||||
|
|
||||||
|
deploy:fast: ansible-playbook playbooks/fast.yml
|
||||||
build:slow: ansible-playbook playbooks/build.yml
|
deploy:slow: ansible-playbook playbooks/slow.yml
|
||||||
deploy:slow: ansible-playbook playbooks/deploy.yml
|
deploy:restore: ansible-playbook playbooks/restore.yml -e "restore_bucket={{.BUCKET}} restore_key={{.KEY}}"
|
||||||
build:fast: ansible-playbook playbooks/fast-build.yml
|
|
||||||
deploy:fast: ansible-playbook playbooks/fast-deploy.yml
|
|
||||||
restore: ansible-playbook playbooks/restore.yml -e "restore_bucket={{.BUCKET}} restore_key={{.KEY}}"
|
|
||||||
run:slow: [task: build:slow, task: deploy:slow]
|
|
||||||
run:fast: [task: build:fast, task: deploy:fast]
|
|
||||||
|
|
||||||
enter:
|
enter:
|
||||||
cmd: aws ssm start-session --target $INSTANCE_ID
|
cmd: aws ssm start-session --target $INSTANCE_ID
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
- name: Make build artifact.
|
|
||||||
hosts: localhost
|
|
||||||
vars_files: ../config/ansible.secret.json
|
|
||||||
gather_facts: false
|
|
||||||
tasks:
|
|
||||||
- name: Build image.
|
|
||||||
community.docker.docker_image_build:
|
|
||||||
name: "{{ image_name }}"
|
|
||||||
path: ../gitea
|
|
||||||
nocache: true
|
|
||||||
rebuild: always
|
|
||||||
pull: true
|
|
||||||
|
|
||||||
- name: Make temp file.
|
|
||||||
ansible.builtin.tempfile:
|
|
||||||
suffix: .tar
|
|
||||||
register: tar_file
|
|
||||||
|
|
||||||
- name: Push image to archive.
|
|
||||||
community.docker.docker_image:
|
|
||||||
name: "{{ image_name }}"
|
|
||||||
archive_path: "{{ tar_file.path }}"
|
|
||||||
source: local
|
|
||||||
|
|
||||||
- name: Compress archive to artifact.
|
|
||||||
register: compress_image
|
|
||||||
community.general.archive:
|
|
||||||
path: "{{ tar_file.path }}"
|
|
||||||
dest: "{{ tar_file.path }}.xz"
|
|
||||||
format: xz
|
|
||||||
mode: "0644"
|
|
||||||
|
|
||||||
- name: Push artifact to S3.
|
|
||||||
amazon.aws.s3_object:
|
|
||||||
bucket: "{{ image_bucket }}"
|
|
||||||
object: "{{ image_key }}"
|
|
||||||
src: "{{ tar_file.path }}.xz"
|
|
||||||
mode: put
|
|
||||||
|
|
||||||
region: "{{ aws_region }}"
|
|
||||||
access_key: "{{ aws_access_key }}"
|
|
||||||
secret_key: "{{ aws_secret_key }}"
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
- name: Make build artifact.
|
|
||||||
hosts: localhost
|
|
||||||
vars_files:
|
|
||||||
- ../config/ansible.secret.json
|
|
||||||
- ../config/infrastructure.secret.tf.json
|
|
||||||
gather_facts: false
|
|
||||||
tasks:
|
|
||||||
- name: Log into Docker.
|
|
||||||
community.docker.docker_login:
|
|
||||||
registry_url: '{{ full_domain.value }}'
|
|
||||||
username: '{{ username }}'
|
|
||||||
password: '{{ api_key }}'
|
|
||||||
reauthorize: true
|
|
||||||
|
|
||||||
- name: Build image.
|
|
||||||
community.docker.docker_image_build:
|
|
||||||
name: "{{ full_domain.value }}/{{ image_name }}:latest"
|
|
||||||
path: ../gitea
|
|
||||||
nocache: true
|
|
||||||
rebuild: always
|
|
||||||
pull: true
|
|
||||||
outputs: [{ type: image, push: true }]
|
|
||||||
platform:
|
|
||||||
- linux/amd64
|
|
||||||
- linux/arm64/v8
|
|
||||||
|
|
||||||
- name: Log out of Docker.
|
|
||||||
community.docker.docker_login:
|
|
||||||
state: absent
|
|
||||||
@@ -1,3 +1,33 @@
|
|||||||
|
- name: Make build artifact.
|
||||||
|
hosts: localhost
|
||||||
|
vars_files:
|
||||||
|
- ../config/ansible.secret.json
|
||||||
|
- ../config/infrastructure.secret.tf.json
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Log into Docker.
|
||||||
|
community.docker.docker_login:
|
||||||
|
registry_url: '{{ full_domain.value }}'
|
||||||
|
username: '{{ username }}'
|
||||||
|
password: '{{ api_key }}'
|
||||||
|
reauthorize: true
|
||||||
|
|
||||||
|
- name: Build image.
|
||||||
|
community.docker.docker_image_build:
|
||||||
|
name: "{{ full_domain.value }}/{{ image_name }}:latest"
|
||||||
|
path: ../gitea
|
||||||
|
nocache: true
|
||||||
|
rebuild: always
|
||||||
|
pull: true
|
||||||
|
outputs: [{ type: image, push: true }]
|
||||||
|
platform:
|
||||||
|
- linux/amd64
|
||||||
|
- linux/arm64/v8
|
||||||
|
|
||||||
|
- name: Log out of Docker.
|
||||||
|
community.docker.docker_login:
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Deploy artifact to instance.
|
- name: Deploy artifact to instance.
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
become: true
|
become: true
|
||||||
@@ -7,11 +37,10 @@
|
|||||||
- ../config/infrastructure.secret.tf.json
|
- ../config/infrastructure.secret.tf.json
|
||||||
vars:
|
vars:
|
||||||
ansible_connection: aws_ssm
|
ansible_connection: aws_ssm
|
||||||
ansible_python_interpreter: /usr/bin/python3
|
|
||||||
ansible_aws_ssm_plugin: "{{ ssm_plugin }}"
|
ansible_aws_ssm_plugin: "{{ ssm_plugin }}"
|
||||||
ansible_aws_ssm_bucket_name: "{{ image_bucket }}"
|
ansible_aws_ssm_bucket_name: "{{ image_bucket }}"
|
||||||
ansible_aws_ssm_instance_id: "{{ instance_id.value }}"
|
ansible_aws_ssm_instance_id: "{{ instance_id.value }}"
|
||||||
|
ansible_python_interpreter: /usr/bin/python3
|
||||||
ansible_aws_ssm_region: "{{ aws_region }}"
|
ansible_aws_ssm_region: "{{ aws_region }}"
|
||||||
ansible_aws_ssm_access_key_id: "{{ aws_access_key }}"
|
ansible_aws_ssm_access_key_id: "{{ aws_access_key }}"
|
||||||
ansible_aws_ssm_secret_access_key: "{{ aws_secret_key }}"
|
ansible_aws_ssm_secret_access_key: "{{ aws_secret_key }}"
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
ansible_aws_ssm_plugin: "{{ ssm_plugin }}"
|
ansible_aws_ssm_plugin: "{{ ssm_plugin }}"
|
||||||
ansible_aws_ssm_bucket_name: "{{ image_bucket }}"
|
ansible_aws_ssm_bucket_name: "{{ image_bucket }}"
|
||||||
ansible_aws_ssm_instance_id: "{{ instance_id.value }}"
|
ansible_aws_ssm_instance_id: "{{ instance_id.value }}"
|
||||||
|
|
||||||
ansible_aws_ssm_region: "{{ aws_region }}"
|
ansible_aws_ssm_region: "{{ aws_region }}"
|
||||||
ansible_aws_ssm_access_key_id: "{{ aws_access_key }}"
|
ansible_aws_ssm_access_key_id: "{{ aws_access_key }}"
|
||||||
ansible_aws_ssm_secret_access_key: "{{ aws_secret_key }}"
|
ansible_aws_ssm_secret_access_key: "{{ aws_secret_key }}"
|
||||||
|
|||||||
@@ -1,3 +1,46 @@
|
|||||||
|
- name: Make build artifact.
|
||||||
|
hosts: localhost
|
||||||
|
vars_files: ../config/ansible.secret.json
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Build image.
|
||||||
|
community.docker.docker_image_build:
|
||||||
|
name: "{{ image_name }}"
|
||||||
|
path: ../gitea
|
||||||
|
nocache: true
|
||||||
|
rebuild: always
|
||||||
|
pull: true
|
||||||
|
|
||||||
|
- name: Make temp file.
|
||||||
|
ansible.builtin.tempfile:
|
||||||
|
suffix: .tar
|
||||||
|
register: tar_file
|
||||||
|
|
||||||
|
- name: Push image to archive.
|
||||||
|
community.docker.docker_image:
|
||||||
|
name: "{{ image_name }}"
|
||||||
|
archive_path: "{{ tar_file.path }}"
|
||||||
|
source: local
|
||||||
|
|
||||||
|
- name: Compress archive to artifact.
|
||||||
|
register: compress_image
|
||||||
|
community.general.archive:
|
||||||
|
path: "{{ tar_file.path }}"
|
||||||
|
dest: "{{ tar_file.path }}.xz"
|
||||||
|
format: xz
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
|
- name: Push artifact to S3.
|
||||||
|
amazon.aws.s3_object:
|
||||||
|
bucket: "{{ image_bucket }}"
|
||||||
|
object: "{{ image_key }}"
|
||||||
|
src: "{{ tar_file.path }}.xz"
|
||||||
|
mode: put
|
||||||
|
|
||||||
|
region: "{{ aws_region }}"
|
||||||
|
access_key: "{{ aws_access_key }}"
|
||||||
|
secret_key: "{{ aws_secret_key }}"
|
||||||
|
|
||||||
- name: Deploy artifact to instance.
|
- name: Deploy artifact to instance.
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
become: true
|
become: true
|
||||||
@@ -11,7 +54,6 @@
|
|||||||
ansible_aws_ssm_plugin: "{{ ssm_plugin }}"
|
ansible_aws_ssm_plugin: "{{ ssm_plugin }}"
|
||||||
ansible_aws_ssm_bucket_name: "{{ image_bucket }}"
|
ansible_aws_ssm_bucket_name: "{{ image_bucket }}"
|
||||||
ansible_aws_ssm_instance_id: "{{ instance_id.value }}"
|
ansible_aws_ssm_instance_id: "{{ instance_id.value }}"
|
||||||
|
|
||||||
ansible_aws_ssm_region: "{{ aws_region }}"
|
ansible_aws_ssm_region: "{{ aws_region }}"
|
||||||
ansible_aws_ssm_access_key_id: "{{ aws_access_key }}"
|
ansible_aws_ssm_access_key_id: "{{ aws_access_key }}"
|
||||||
ansible_aws_ssm_secret_access_key: "{{ aws_secret_key }}"
|
ansible_aws_ssm_secret_access_key: "{{ aws_secret_key }}"
|
||||||
Reference in New Issue
Block a user