|
|
@ -5,81 +5,102 @@ |
|
|
|
name: |
|
|
|
name: |
|
|
|
- seadrive |
|
|
|
- seadrive |
|
|
|
- fuse |
|
|
|
- fuse |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: Ensure fuse is loaded |
|
|
|
- name: Ensure fuse is loaded |
|
|
|
modprobe: name=fuse state=present |
|
|
|
modprobe: name=fuse state=present |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: Create global directories |
|
|
|
- name: Create global directories |
|
|
|
file: path={{ item }} state=directory mode=755 |
|
|
|
file: path={{ item }} state=directory mode=755 |
|
|
|
with_items: |
|
|
|
loop: |
|
|
|
- /etc/seadrive |
|
|
|
- /etc/seadrive |
|
|
|
- /var/cache/seadrive |
|
|
|
- /var/cache/seadrive |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: Create cache directories |
|
|
|
- name: Create cache directories |
|
|
|
file: path={{ item.data_dir | default('/var/cache/seadrive/' + item.id) }} state=directory owner={{ item.user | default('root') }} mode=700 |
|
|
|
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 |
|
|
|
- name: Create drive directories |
|
|
|
file: path={{ item.drive_dir }} state=directory owner={{ item.user | default('root') }} mode=700 |
|
|
|
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 |
|
|
|
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 |
|
|
|
- name: Make sure allow_other is available for user |
|
|
|
lineinfile: dest=/etc/fuse.conf regexp='^user_allow_other' line='user_allow_other' |
|
|
|
lineinfile: dest=/etc/fuse.conf regexp='^user_allow_other' line='user_allow_other' |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: List existing instances |
|
|
|
- name: List existing instances |
|
|
|
shell: ls /etc/systemd/system/seadrive-*.service | perl -ne 's/.*\/seadrive\-(.*)\.service/$1/ && print "$1\n"' |
|
|
|
shell: ls /etc/systemd/system/seadrive-*.service | perl -ne 's/.*\/seadrive\-(.*)\.service/$1/ && print "$1\n"' |
|
|
|
register: seadrive_instances |
|
|
|
register: seadrive_instances |
|
|
|
changed_when: False |
|
|
|
changed_when: False |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: List managed instances |
|
|
|
- name: List managed instances |
|
|
|
set_fact: seadrive_managed_instances={{ seadrive_daemons | map(attribute='id') | list }} |
|
|
|
set_fact: seadrive_managed_instances={{ seadrive_daemons | map(attribute='id') | list }} |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: List instances to be removed |
|
|
|
- name: List instances to be removed |
|
|
|
set_fact: seadrive_remove_instances={{ seadrive_instances.stdout_lines | difference(seadrive_managed_instances) }} |
|
|
|
set_fact: seadrive_remove_instances={{ seadrive_instances.stdout_lines | difference(seadrive_managed_instances) }} |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: Stop unmanaged instances |
|
|
|
- name: Stop unmanaged instances |
|
|
|
service: name=seadrive-{{ item }} state=stopped enabled=False |
|
|
|
service: name=seadrive-{{ item }} state=stopped enabled=False |
|
|
|
with_items: "{{ seadrive_remove_instances }}" |
|
|
|
loop: "{{ seadrive_remove_instances }}" |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: Remove unmanaged instances |
|
|
|
- name: Remove unmanaged instances |
|
|
|
file: path=/etc/systemd/system/seadrive-{{ item }}.service state=absent |
|
|
|
file: path=/etc/systemd/system/seadrive-{{ item }}.service state=absent |
|
|
|
with_items: "{{ seadrive_remove_instances }}" |
|
|
|
loop: "{{ seadrive_remove_instances }}" |
|
|
|
register: seadrive_remove_units |
|
|
|
register: seadrive_remove_units |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: Remove unmanaged config |
|
|
|
- name: Remove unmanaged config |
|
|
|
file: path=/etc/seadrive/{{ item }}.conf state=absent |
|
|
|
file: path=/etc/seadrive/{{ item }}.conf state=absent |
|
|
|
with_items: "{{ seadrive_remove_instances }}" |
|
|
|
loop: "{{ seadrive_remove_instances }}" |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: Remove unmanaged cache directories |
|
|
|
- name: Remove unmanaged cache directories |
|
|
|
file: path=/var/cache/seadrive/{{ item }} state=absent |
|
|
|
file: path=/var/cache/seadrive/{{ item }} state=absent |
|
|
|
with_items: "{{ seadrive_remove_instances }}" |
|
|
|
loop: "{{ seadrive_remove_instances }}" |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: Obtain API Tokens |
|
|
|
- name: Obtain API Tokens |
|
|
|
uri: |
|
|
|
uri: |
|
|
|
url: "{{ item.server }}/api2/auth-token/" |
|
|
|
url: "{{ item.server }}/api2/auth-token/" |
|
|
|
method: POST |
|
|
|
method: POST |
|
|
|
body: "username={{ item.login }}&password={{ item.pass }}" |
|
|
|
body: |
|
|
|
|
|
|
|
username: "{{ item.login }}" |
|
|
|
|
|
|
|
password: "{{ item.pass }}" |
|
|
|
|
|
|
|
body_format: form-urlencoded |
|
|
|
return_content: True |
|
|
|
return_content: True |
|
|
|
register: seadrive_tokens |
|
|
|
register: seadrive_tokens |
|
|
|
when: item.token is not defined |
|
|
|
when: item.token is not defined |
|
|
|
with_items: "{{ seadrive_daemons }}" |
|
|
|
loop: "{{ seadrive_daemons }}" |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: Deploy systemd units |
|
|
|
- name: Deploy systemd units |
|
|
|
template: src=seadrive.service.j2 dest=/etc/systemd/system/seadrive-{{ item.id }}.service |
|
|
|
template: src=seadrive.service.j2 dest=/etc/systemd/system/seadrive-{{ item.id }}.service |
|
|
|
with_items: "{{ seadrive_daemons }}" |
|
|
|
|
|
|
|
register: seadrive_new_units |
|
|
|
register: seadrive_new_units |
|
|
|
notify: restart seadrive |
|
|
|
notify: restart seadrive |
|
|
|
|
|
|
|
loop: "{{ seadrive_daemons }}" |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: Deploy configurations |
|
|
|
- name: Deploy configurations |
|
|
|
template: src=seadrive.conf.j2 dest=/etc/seadrive/{{ item.id }}.conf owner={{ item.user | default('root') }} mode=600 |
|
|
|
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 |
|
|
|
notify: restart seadrive |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: Reload systemd |
|
|
|
- name: Reload systemd |
|
|
|
command: systemctl daemon-reload |
|
|
|
command: systemctl daemon-reload |
|
|
|
when: seadrive_new_units.changed or seadrive_remove_units.changed |
|
|
|
when: seadrive_new_units.changed or seadrive_remove_units.changed |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|
|
|
|
|
|
|
|
|
- name: Start and enable managed instances |
|
|
|
- name: Start and enable managed instances |
|
|
|
service: name=seadrive-{{ item.id }} state=started enabled=yes |
|
|
|
service: name=seadrive-{{ item.id }} state=started enabled=yes |
|
|
|
with_items: "{{ seadrive_daemons }}" |
|
|
|
loop: "{{ seadrive_daemons }}" |
|
|
|
|
|
|
|
tags: seadrive |
|
|
|