chore: rename roles to reflect upstream naming scheme

This commit is contained in:
2021-10-16 15:14:50 +02:00
parent 6d383fb81d
commit 1caf613ff2
16 changed files with 3 additions and 3 deletions

23
roles/apps/README.md Normal file
View File

@ -0,0 +1,23 @@
# `finallycoffee.nextcloud.nextcloud-apps` ansible role
This role can be used to install/update, remove, enable and disable
nextcloud apps.
## Examples
```yaml
nextcloud_apps:
# Install cospend app
- name: cospend
state: present
# Make sure mail app is installed, but not enabled
- name: mail
state: present
enabled: no
# Uninstall photos app
- name: photos
state: absent
# Make sure federation app is always up-to-date
- name: federation
state: latest
```

View File

@ -0,0 +1,5 @@
---
nextcloud_container_name: nextcloud
nextcloud_apps: []
nextcloud_run_user: nextcloud

View File

@ -0,0 +1,7 @@
---
- name: restart-nextcloud
docker_container:
name: "{{ nextcloud_container_name }}"
state: started
restart: yes

50
roles/apps/tasks/main.yml Normal file
View File

@ -0,0 +1,50 @@
---
- name: Ensure nextcloud user is created
user:
name: "{{ nextcloud_run_user }}"
state: present
register: nextcloud_user_res
when: false
- name: Install apps using php occ
community.docker.docker_container_exec:
container: "{{ nextcloud_container_name }}"
command: "php occ app:{{ verb }} {{ item.name }}"
user: "{{ nextcloud_run_user }}"
tty: yes
register: app_install_res
failed_when: "app_install_res.rc == 1 and 'already installed' not in app_install_res.stdout"
changed_when: "'already installed' not in app_install_res.stdout"
vars:
verb: >-
{%- if item.state|default('present') == 'present' -%}
install
{%- elif item.state == 'latest' -%}
update
{%- elif item.state == 'absent' -%}
remove
{%- endif -%}
loop: "{{ nextcloud_apps }}"
notify:
- restart-nextcloud
- name: Ensure apps are enabled/disabled
community.docker.docker_container_exec:
container: "{{ nextcloud_container_name }}"
command: "php occ app:{{ verb }} {{ item.name }}"
user: "{{ nextcloud_run_user }}"
tty: yes
register: app_status_res
failed_when: "app_status_res.rc == 1 and 'No such app enabled' not in app_status_res.stdout"
changed_when: "'already enabled' not in app_status_res.stdout and 'No such app enabled' not in app_status_res.stdout"
vars:
verb: >-
{%- if item.state|default('present') in ['latest', 'present'] and item.enabled|default(True) -%}
enable
{%- elif item.enabled == False -%}
disable
{%- endif -%}
loop: "{{ nextcloud_apps }}"
notify:
- restart-nextcloud