0
0

Removed docker_dir variable

This commit is contained in:
Opnxng 2024-11-02 18:19:03 +08:00
parent 1cd5bfdc3a
commit ffa9777538
5 changed files with 29 additions and 36 deletions

View File

@ -22,7 +22,7 @@
- name: Set permissions of privatebin directory
file:
path: "{{ docker_dir }}/privatebin/data"
path: "/home/{{ ansible_user }}/Docker/privatebin/data"
state: directory
owner: 1000
group: 1000
@ -33,12 +33,12 @@
- name: Compress privatebin directory
shell: "zip -r --password {{ backup_zip_password }} privatebin_{{ current_date.stdout }}.zip data"
args:
chdir: "{{ docker_dir }}/privatebin/"
chdir: "/home/{{ ansible_user }}/Docker/privatebin/"
when: inventory_hostname == 'oracle1'
- name: Set permissions of privatebin directory
file:
path: "{{ docker_dir }}/privatebin/data"
path: "/home/{{ ansible_user }}/Docker/privatebin/data"
state: directory
owner: 65534
group: 82
@ -62,14 +62,14 @@
- name: Remove privatebin.zip on remote server
file:
path: "{{ docker_dir }}/privatebin/privatebin_{{ current_date.stdout }}.zip"
path: "/home/{{ ansible_user }}/Docker/privatebin/privatebin_{{ current_date.stdout }}.zip"
state: absent
when: inventory_hostname == 'oracle1'
# To Restore:
# cd ./Docker/privatebin
# sudo unzip privatebin_2023-11-11.zip
# sudo chown -R 65534:82 {{ docker_dir }}/privatebin/data
# sudo chown -R 65534:82 /home/{{ ansible_user }}/Docker/privatebin/data
# ----------------------------------------------------------------------------------------------------
@ -78,7 +78,7 @@
when: inventory_hostname == 'oracle3'
- name: Prune Etherpaddb on remote server
command: find {{ docker_dir }}/etherpad/backups -type f -mtime +2 -delete
command: find /home/{{ ansible_user }}/Docker/etherpad/backups -type f -mtime +2 -delete
when: inventory_hostname == 'oracle3'
- name: Copy Etherpaddb backups
@ -103,8 +103,8 @@
- name: Compress gitea directory
archive:
path: "{{ docker_dir }}/gitea/data/"
dest: "{{ docker_dir }}/gitea/gitea_{{ current_date.stdout }}.tar"
path: "/home/{{ ansible_user }}/Docker/gitea/data/"
dest: "/home/{{ ansible_user }}/Docker/gitea/gitea_{{ current_date.stdout }}.tar"
format: tar
when: inventory_hostname == 'oracle3'
@ -120,7 +120,7 @@
- name: Remove gitea.tar on remote server
file:
path: "{{ docker_dir }}/gitea/gitea_{{ current_date.stdout }}.tar"
path: "/home/{{ ansible_user }}/Docker/gitea/gitea_{{ current_date.stdout }}.tar"
state: absent
when: inventory_hostname == 'oracle3'
@ -140,8 +140,8 @@
# - name: Compress ntfy directory
# archive:
# path: "{{ docker_dir }}/ntfy/"
# dest: "{{ docker_dir }}/ntfy.tar"
# path: "/home/{{ ansible_user }}/Docker/ntfy/"
# dest: "/home/{{ ansible_user }}/Docker/ntfy.tar"
# format: tar
# become: true
# when: inventory_hostname == 'oracle3'
@ -158,7 +158,7 @@
# - name: Remove ntfy.tar
# file:
# path: "{{ docker_dir }}/ntfy.tar"
# path: "/home/{{ ansible_user }}/Docker/ntfy.tar"
# state: absent
# when: inventory_hostname == 'oracle3'
@ -169,17 +169,17 @@
# ----------------------------------------------------------------------------------------------------
- name: Remove old weekly files from send
command: find {{ docker_dir }}/send/uploads/ -name 7-\* -mmin +10130 -exec rm {} \;
command: find /home/{{ ansible_user }}/Docker/send/uploads/ -name 7-\* -mmin +10130 -exec rm {} \;
when: inventory_hostname == 'oracle1'
- name: Remove old daily files from send
command: find {{ docker_dir }}/send/uploads/ -name 1-\* -mmin +1500 -exec rm {} \;
command: find /home/{{ ansible_user }}/Docker/send/uploads/ -name 1-\* -mmin +1500 -exec rm {} \;
when: inventory_hostname == 'oracle1'
# - name: Compress send directory
# archive:
# path: "{{ docker_dir }}/send"
# dest: "{{ docker_dir }}/send.tar"
# path: "/home/{{ ansible_user }}/Docker/send"
# dest: "/home/{{ ansible_user }}/Docker/send.tar"
# format: tar
# delegate_to: oracle1
# tags: never
@ -198,7 +198,7 @@
# - name: Remove send.tar
# file:
# path: "{{ docker_dir }}/send.tar"
# path: "/home/{{ ansible_user }}/Docker/send.tar"
# state: absent
# tags: never
# when: inventory_hostname == 'oracle1'

View File

@ -1,7 +0,0 @@
- name: Copy firefox directory
copy:
src: "firefox/"
dest: "{{ docker_dir }}/firefox"
owner: 1000
group: 1000
mode: 0755

View File

@ -2,7 +2,8 @@
set_fact:
gnupg_folder: "/home/{{ control_user }}/.gnupg"
# ----------------------------------------------------------------------------------------------------
# --------------------------------------------------
# Store git credentials with GPG and .netrc because SSH is too complicated for Gitea on Docker
- name: Remove existing .netrc
@ -17,11 +18,11 @@
state: absent
delegate_to: "{{ control_host }}"
# ----------------------------------------------------------------------------------------------------
# --------------------------------------------------
- name: Reminder to generate GPG key by hand
pause:
prompt: "Generate GPG key using gpg --gen-key --homedir /home/{{ user }}/.gnupg --pinentry-mode loopback"
prompt: "Generate GPG key using gpg --gen-key --homedir /home/{{ control_user }}/.gnupg --pinentry-mode loopback"
delegate_to: "{{ control_host }}"
- name: Set up .netrc

View File

@ -6,18 +6,18 @@
- vars/secrets.yaml
- vars/services.yaml
tasks:
# ----------------------------------------------------------------------------------------------------
- name: Docker Compose down
command: "docker-compose -f {{ docker_dir }}/{{ item }}/docker-compose.yaml down"
command: "docker-compose -f /home/{{ ansible_user }}/Docker/{{ item }}/docker-compose.yaml down"
loop: "{{ down[inventory_hostname] }}"
when: down is defined and inventory_hostname in down
ignore_errors: yes
- name: Remove project directory
file:
path: "{{ docker_dir }}/{{ item }}"
path: "/home/{{ ansible_user }}/Docker/{{ item }}"
state: absent
become: true
loop: "{{ remove[inventory_hostname] }}"
@ -28,7 +28,7 @@
- name: Create project directory
file:
path: "{{ docker_dir }}/{{ item }}"
path: "/home/{{ ansible_user }}/Docker/{{ item }}"
state: directory
owner: 1000
group: 1000
@ -45,7 +45,7 @@
- name: Copy Docker Compose
template:
src: "compose/{{ item }}.yaml.j2"
dest: "{{ docker_dir }}/{{ item }}/docker-compose.yaml"
dest: "/home/{{ ansible_user }}/Docker/{{ item }}/docker-compose.yaml"
owner: 1000
group: 1000
mode: 0755
@ -55,11 +55,11 @@
# ----------------------------------------------------------------------------------------------------
- name: Docker Compose pull
command: "docker-compose -f {{ docker_dir }}/{{ item }}/docker-compose.yaml pull"
command: "docker-compose -f /home/{{ ansible_user }}/Docker/{{ item }}/docker-compose.yaml pull"
loop: "{{ compose[inventory_hostname] }}"
when: compose is defined and inventory_hostname in compose
- name: Docker Compose up
command: "docker-compose -f {{ docker_dir }}/{{ item }}/docker-compose.yaml up --remove-orphans --force-recreate -d"
command: "docker-compose -f /home/{{ ansible_user }}/Docker/{{ item }}/docker-compose.yaml up --remove-orphans --force-recreate -d"
loop: "{{ compose[inventory_hostname] }}"
when: compose is defined and inventory_hostname in compose
when: compose is defined and inventory_hostname in compose

View File

@ -1,4 +1,3 @@
docker_dir:
control_user:
control_host: