From d91f3eca86688c83748ac0dea6b16c0473b9d1a6 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 1 Oct 2020 22:00:07 +0200 Subject: [PATCH] Update to 2020-10-01 22:00 --- roles/repo_seadrive/tasks/main.yml | 3 ++- roles/seadrive/tasks/main.yml | 45 ++++++++++++++++++++++++++++---------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/roles/repo_seadrive/tasks/main.yml b/roles/repo_seadrive/tasks/main.yml index 8c82583..367840e 100644 --- a/roles/repo_seadrive/tasks/main.yml +++ b/roles/repo_seadrive/tasks/main.yml @@ -4,5 +4,6 @@ yum_repository: name: seadrive description: Seadrive seafile client - baseurl: http://linux-clients.seafile.com/seadrive-rpm + baseurl: http://linux-clients.seafile.com/seadrive-rpm/centos$releasever gpgcheck: False + tags: repo,seadrive diff --git a/roles/seadrive/tasks/main.yml b/roles/seadrive/tasks/main.yml index 06eda7d..b9a687f 100644 --- a/roles/seadrive/tasks/main.yml +++ b/roles/seadrive/tasks/main.yml @@ -5,81 +5,102 @@ name: - seadrive - fuse + tags: seadrive - name: Ensure fuse is loaded modprobe: name=fuse state=present + tags: seadrive - name: Create global directories file: path={{ item }} state=directory mode=755 - with_items: + loop: - /etc/seadrive - /var/cache/seadrive + tags: seadrive - name: Create cache directories file: path={{ item.data_dir | default('/var/cache/seadrive/' + item.id) }} state=directory owner={{ item.user | default('root') }} mode=700 - with_items: "{{ seadrive_daemons }}" + loop: "{{ seadrive_daemons }}" + tags: seadrive - name: Create drive directories file: path={{ item.drive_dir }} state=directory owner={{ item.user | default('root') }} mode=700 - with_items: "{{ seadrive_daemons }}" + loop: "{{ seadrive_daemons }}" ignore_errors: True # Needed if allow_other is not set as root can't check the mount point + tags: seadrive - name: Make sure allow_other is available for user lineinfile: dest=/etc/fuse.conf regexp='^user_allow_other' line='user_allow_other' + tags: seadrive - name: List existing instances shell: ls /etc/systemd/system/seadrive-*.service | perl -ne 's/.*\/seadrive\-(.*)\.service/$1/ && print "$1\n"' register: seadrive_instances changed_when: False + tags: seadrive - name: List managed instances set_fact: seadrive_managed_instances={{ seadrive_daemons | map(attribute='id') | list }} + tags: seadrive - name: List instances to be removed set_fact: seadrive_remove_instances={{ seadrive_instances.stdout_lines | difference(seadrive_managed_instances) }} + tags: seadrive - name: Stop unmanaged instances service: name=seadrive-{{ item }} state=stopped enabled=False - with_items: "{{ seadrive_remove_instances }}" + loop: "{{ seadrive_remove_instances }}" + tags: seadrive - name: Remove unmanaged instances file: path=/etc/systemd/system/seadrive-{{ item }}.service state=absent - with_items: "{{ seadrive_remove_instances }}" + loop: "{{ seadrive_remove_instances }}" register: seadrive_remove_units + tags: seadrive - name: Remove unmanaged config file: path=/etc/seadrive/{{ item }}.conf state=absent - with_items: "{{ seadrive_remove_instances }}" + loop: "{{ seadrive_remove_instances }}" + tags: seadrive - name: Remove unmanaged cache directories file: path=/var/cache/seadrive/{{ item }} state=absent - with_items: "{{ seadrive_remove_instances }}" + loop: "{{ seadrive_remove_instances }}" + tags: seadrive - name: Obtain API Tokens uri: url: "{{ item.server }}/api2/auth-token/" method: POST - body: "username={{ item.login }}&password={{ item.pass }}" + body: + username: "{{ item.login }}" + password: "{{ item.pass }}" + body_format: form-urlencoded return_content: True register: seadrive_tokens when: item.token is not defined - with_items: "{{ seadrive_daemons }}" + loop: "{{ seadrive_daemons }}" + tags: seadrive - name: Deploy systemd units template: src=seadrive.service.j2 dest=/etc/systemd/system/seadrive-{{ item.id }}.service - with_items: "{{ seadrive_daemons }}" register: seadrive_new_units notify: restart seadrive + loop: "{{ seadrive_daemons }}" + tags: seadrive - name: Deploy configurations template: src=seadrive.conf.j2 dest=/etc/seadrive/{{ item.id }}.conf owner={{ item.user | default('root') }} mode=600 - with_items: "{{ seadrive_daemons }}" + loop: "{{ seadrive_daemons }}" notify: restart seadrive + tags: seadrive - name: Reload systemd command: systemctl daemon-reload when: seadrive_new_units.changed or seadrive_remove_units.changed + tags: seadrive - name: Start and enable managed instances service: name=seadrive-{{ item.id }} state=started enabled=yes - with_items: "{{ seadrive_daemons }}" + loop: "{{ seadrive_daemons }}" + tags: seadrive