install.fairie/.config/taskfiles/cloud/Taskfile-s3.yml

63 lines
2.2 KiB
YAML
Raw Normal View History

2022-12-24 12:04:59 -08:00
---
version: '3'
tasks:
bucket:create:
deps:
- :install:software:s5cmd
summary: |
# Create S3 Bucket
This task creates an S3 bucket in the given account
`AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`, `AWS_REGION` and `BUCKET_NAME` are passed from the calling task. The first 3
variables are set as environment variables
env:
AWS_ACCESS_KEY_ID: '{{.AWS_ACCESS_KEY_ID}}'
AWS_REGION: '{{.AWS_REGION}}'
AWS_SECRET_ACCESS_KEY: '{{.AWS_SECRET_ACCESS_KEY}}'
cmds:
- s5cmd mb s3://'{{.BUCKET_NAME}}'
bucket:jumpusb:populate:
deps:
- :install:software:axel
summary: |
# Populate an S3 Bucket with JumpUSB Assets
This script first downloads the script from the JumpUSB repository:
https://gitlab.com/megabyte-labs/jumpusb/-/blob/master/local/distros.json
After that, it downloads all the operating systems and uploads them to an
S3 bucket using the same path that is defined in each object's path key.
For example, the following:
```
{
"url": "https://mirrors.edge.kernel.org/zorinos-isos/16/Zorin-OS-16.1-Core-64-bit.iso",
"url_axel": "https://{mirrors.edge.kernel.org/zorinos-isos,mirror2.sandyriver.net/pub/zorinos,mirror.clarkson.edu/zorinos/isos,distro.ibiblio.org/zorinos}/16/Zorin-OS-16.1-Core-64-bit.iso",
"path": "/iso/zorin/zorin-16.1-amd64.iso",
"persistence_base": "persistence_ext4_4GB_casper-rw.dat.7z",
"persistence_file": "zorin.dat",
"live": true
}
```
1. Downloads the ISO with Axel using the `url_axel` URL (and falls back to the `url` if `url_axel` is not present)
2. Then uploads the file into the `/iso/zorin` directory of the S3 bucket where the file is named `zorin-16.1-amd64.iso
env:
DISTROS_TMP:
sh: mktemp
cmds:
- curl -sSL https://gitlab.com/megabyte-labs/jumpusb/-/raw/master/local/distros.json > "$DISTROS_TMP"
bucket:synchronize:
deps:
- :install:software:s5cmd
summary: |
# Synchronize S3 Buckets
Synchronize the contents of one S3 bucket with another using s5cmd.
cmds:
- s5cmd sync '{{.SOURCE_BUCKET}}' '{{.DEST_BUCKET}}'