install s3cmd from apt

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-09-29 22:38:42 +02:00
parent 3e41d2ac69
commit 3356b07065
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
5 changed files with 12 additions and 39 deletions

View File

@ -1,11 +1,4 @@
---
# tool for uploading to s3 compatible backends
s3cmd_version: '2.1.0'
s3cmd_name: 's3cmd-{{ s3cmd_version }}'
s3cmd_archive: '{{ s3cmd_name }}.tar.gz'
s3cmd_checksum: 'md5:2637f1b36f5d9db4f60af3b18eb34958'
s3cmd_url: 'https://github.com/s3tools/s3cmd/releases/download/v{{ s3cmd_version }}/{{ s3cmd_archive }}'
backup_name: 'default'
backup_directory: ~
backup_script_dir: '/var/lib/backups'

10
tasks/install.yml Normal file
View File

@ -0,0 +1,10 @@
---
- name: Install s3cmd tool
apt:
name: s3cmd
- name: Create s3cmd config
template:
src: s3cfg.j2
dest: /root/.s3cfg
mode: 0400

View File

@ -1,4 +1,4 @@
---
- include_tasks: s3cmd.yml
- include_tasks: install.yml
- include_tasks: script.yml
- include_tasks: timer.yml

View File

@ -1,30 +0,0 @@
---
- name: Check if s3cmd is installed
stat:
path: /usr/local/bin/s3cmd
register: s3cmd
- name: Download s3cmd archive
get_url:
url: '{{ s3cmd_url }}'
dest: /tmp
when: not s3cmd.stat.exists
- name: Extract s3cmd archive
unarchive:
src: '/tmp/{{ s3cmd_archive }}'
dest: /tmp
remote_src: yes
when: not s3cmd.stat.exists
- name: Install s3cmd
command: python setup.py install
args:
chdir: '/tmp/{{ s3cmd_name }}'
when: not s3cmd.stat.exists
- name: Create s3cmd config
template:
src: s3cfg.j2
dest: /root/.s3cfg
mode: 0400

View File

@ -8,5 +8,5 @@ ARCHIVES=$(ls -Art ${BACKUPS_DIR} | tail -n ${BACKUPS_NUM})
for ARCHIVE in ${ARCHIVES}; do
echo "Uploading: ${ARCHIVE} >> ${BUCKET_NAME}"
/usr/local/bin/s3cmd put "${BACKUPS_DIR}/${ARCHIVE}" "${BUCKET_NAME}"
/usr/bin/s3cmd put "${BACKUPS_DIR}/${ARCHIVE}" "${BUCKET_NAME}"
done