From ffa9777538d2c85bee7d657aa302b75d674de754 Mon Sep 17 00:00:00 2001 From: Opnxng Date: Sat, 2 Nov 2024 18:19:03 +0800 Subject: [PATCH] Removed docker_dir variable --- back-up.yaml | 34 +++++++++++++++++----------------- config-tasks/firefox.yaml | 7 ------- config-tasks/gitea-netrc.yaml | 7 ++++--- deploy.yaml | 16 ++++++++-------- vars/secrets.example.yaml | 1 - 5 files changed, 29 insertions(+), 36 deletions(-) delete mode 100755 config-tasks/firefox.yaml diff --git a/back-up.yaml b/back-up.yaml index 5abbd6c..f181981 100755 --- a/back-up.yaml +++ b/back-up.yaml @@ -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' diff --git a/config-tasks/firefox.yaml b/config-tasks/firefox.yaml deleted file mode 100755 index 986b086..0000000 --- a/config-tasks/firefox.yaml +++ /dev/null @@ -1,7 +0,0 @@ - - name: Copy firefox directory - copy: - src: "firefox/" - dest: "{{ docker_dir }}/firefox" - owner: 1000 - group: 1000 - mode: 0755 \ No newline at end of file diff --git a/config-tasks/gitea-netrc.yaml b/config-tasks/gitea-netrc.yaml index b4b85b2..e95eac1 100644 --- a/config-tasks/gitea-netrc.yaml +++ b/config-tasks/gitea-netrc.yaml @@ -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 diff --git a/deploy.yaml b/deploy.yaml index 7023521..5902420 100644 --- a/deploy.yaml +++ b/deploy.yaml @@ -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 \ No newline at end of file + when: compose is defined and inventory_hostname in compose diff --git a/vars/secrets.example.yaml b/vars/secrets.example.yaml index 241afe5..736708f 100644 --- a/vars/secrets.example.yaml +++ b/vars/secrets.example.yaml @@ -1,4 +1,3 @@ -docker_dir: control_user: control_host: