diff --git a/.gitignore b/.gitignore index 4eaf927..7aa3435 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ terraform/proxmox/terraform.tfstate* terraform/proxmox/terraform-pluging* terraform/proxmox/terraform-plugin-proxmox.log terraform/proxmox/terraform.tfstate - +group_vars/all/backblaze.yml diff --git a/roles/storage_configuration/tasks/glusterfs.yml b/roles/storage_configuration/tasks/glusterfs.yml index 7951933..0576414 100644 --- a/roles/storage_configuration/tasks/glusterfs.yml +++ b/roles/storage_configuration/tasks/glusterfs.yml @@ -1,3 +1,5 @@ +- name: Re-gather facts + setup: ~ #- install GlusterFS server - name: Add Gluster Key diff --git a/roles/storage_configuration/tasks/main.yml b/roles/storage_configuration/tasks/main.yml index 4e0ce07..aadebdb 100644 --- a/roles/storage_configuration/tasks/main.yml +++ b/roles/storage_configuration/tasks/main.yml @@ -1,6 +1,7 @@ - include_tasks: glusterfs.yml - include_tasks: glusterfs_client.yml - include_tasks: samba.yml +- include_tasks: s3fsfuse.yml diff --git a/roles/storage_configuration/tasks/s3fsfuse.yml b/roles/storage_configuration/tasks/s3fsfuse.yml new file mode 100644 index 0000000..fbaaba7 --- /dev/null +++ b/roles/storage_configuration/tasks/s3fsfuse.yml @@ -0,0 +1,55 @@ +- name: Install packages for s3fs fuse + apt: + pkg: + - libfuse-dev + - fuse + - build-essential + - libcurl4-openssl-dev + - libxml2-dev + - pkg-config + - libssl-dev + - automake + - git + +- name: Create directory for mounting blackblaze s3fs fuse to + file: + path: /backups/backblaze + state: directory + owner: root + +- name: clone repo + ansible.builtin.git: + repo: https://github.com/s3fs-fuse/s3fs-fuse + clone: yes + dest: /tmp/s3fs-fuse + +- name: install s3fs + shell: | + cd /tmp/s3fs-fuse + ./autogen.sh + ./configure + make + make install + +- name: symlink binary + ansible.builtin.file: + src: /usr/local/bin/s3fs + dest: /usr/bin + state: link + force: no + ignore_errors: true + +- name: Create s3fs backblaze password file + ansible.builtin.template: + src: passwd-s3fs.j2 + dest: /etc/passwd-s3fs + mode: 0600 + owner: root + +# clever bit to add a line/block to fstab file but use a template as a basis and add a marker. +- name: Manage fstab file + blockinfile: + path: /etc/fstab + block: "{{ lookup('template', 'baremetal_fstab_s3fs.j2') }}" + marker: "# {mark} ANSIBLE MANAGED BLOCK for s3fs Mount" + when: "'baremetal_hosts' in group_names" \ No newline at end of file diff --git a/roles/storage_configuration/templates/baremetal_fstab_s3fs.j2 b/roles/storage_configuration/templates/baremetal_fstab_s3fs.j2 new file mode 100644 index 0000000..7e94d3e --- /dev/null +++ b/roles/storage_configuration/templates/baremetal_fstab_s3fs.j2 @@ -0,0 +1 @@ +s3fs#{{ backblaze.backblaze_bucket }} {{ backblaze.backblaze_dir }} fuse _netdev,use_xattr,umask=022,parallel_count=10,retries=100,dbglevel=debug,allow_other,use_path_request_style,url=https://s3.us-west-000.backblazeb2.com,nomixupload,nonempty 0 0 \ No newline at end of file diff --git a/roles/storage_configuration/templates/baremetal_smb.conf.j2 b/roles/storage_configuration/templates/baremetal_smb.conf.j2 index 8d5f4a5..0fc2c80 100644 --- a/roles/storage_configuration/templates/baremetal_smb.conf.j2 +++ b/roles/storage_configuration/templates/baremetal_smb.conf.j2 @@ -259,3 +259,14 @@ force user = root force group = root admin users = root, jon +[backblaze] +comment = Backblaze Backups +path = "{{ backblaze.backblaze_dir }}" +writeable = yes +guest ok = no +create mask = 0644 +directory mask = 0755 +valid users = root, jon +force user = root +force group = root +admin users = root, jon \ No newline at end of file diff --git a/roles/storage_configuration/templates/passwd-s3fs.j2 b/roles/storage_configuration/templates/passwd-s3fs.j2 new file mode 100644 index 0000000..e7f79db --- /dev/null +++ b/roles/storage_configuration/templates/passwd-s3fs.j2 @@ -0,0 +1,2 @@ +{{ backblaze.backblaze_creds.key_id }}:{{ backblaze.backblaze_creds.app_key }} + \ No newline at end of file