nextcloud apps role

This commit is contained in:
Janik von Rotz committed 2021-05-14 12:27:26 +02:00
1 parent 8f2052a32d
commit d107a03af2
6 files changed
+183 -47

No files matched your search

+49 -46
View File
@@ -12,52 +12,55 @@ Role dependency graph:
Role details:
* [docker](roles/docker/README.md) - Install Docker for Ubuntu and CentOS.
* [docker-network](roles/docker-network/README.md) - Configure Docker network.
* [docker-volume](roles/docker-volume/README.md) - Configure Docker volume.
* [postgres](roles/postgres/README.md) - Deploy PostgreSQL database container.
* [openldap](roles/openldap/README.md) - Deploy OpenLDAP Docker container.
* [odoo](roles/odoo/README.md) - Deploy Odoo container.
* [odoo-scripts](roles/odoo-scripts/README.md) - Install Odoo scripts.
* [debug](roles/debug/README.md) - Debug Ansible variables.
* [certbot](roles/certbot/README.md) - Deploy Let's Encrypt certificates.
* [nginx](roles/nginx/README.md) - Deploy Nginx proxy with Certbot.
* [clean](roles/clean/README.md) - Cleanup Ansible roles.
* [mysql](roles/mysql/README.md) - Deploy MySQL database container.
* [bookstack](roles/bookstack/README.md) - Deploy BookStack container.
* [nextcloud](roles/nextcloud/README.md) - Deploy Nextcloud container.
* [moodle](roles/moodle/README.md) - Deploy Moodle container.
* [iam](roles/iam/README.md) - Configures users and groups.
* [restic-client](roles/restic-client/README.md) - Configure Restic client backup jobs.
* [restic-server](roles/restic-server/README.md) - Deploy Restic server container.
* [elasticsearch](roles/elasticsearch/README.md) - Deploy ElasticSearch Docker cluster.
* [kibana](roles/elasticsearch/README.md) - Deploy Kibana Docker container.
* [logstash](roles/logstash/README.md) - Deploy Logstash Docker container.
* [metricbeat](roles/metricbeat/README.md) - Deploy Metricbeat Docker container.
* [cadvisor](roles/cadvisor/README.md) - Deploy cAdvisor Docker container.
* [node-exporter](roles/node-exporter/README.md) - Deploy Node exporter container and install custom metric script.
* [prometheus](roles/prometheus/README.md) - Deploy Prometheus Docker container.
* [grafana](roles/grafana/README.md) - Deploy Grafana Docker container.
* [keycloak](roles/keycloak/README.md) - Deploy Keycloak Docker container.
* [update](roles/update/README.md) - Install system and package updates.
* [package](roles/package/README.md) - Set env vars and install packages.
* [odoo-apps](roles/odoo-apps/README.md) - Install Odoo apps from file, url, public or private GitHub repo.
* [nginx-waf](roles/nginx-waf/README.md) - Deploy Nginx with ModSecurity and Core Rule Set.
* [maintenance](roles/maintenance/README.md) - Maintain operating system and disk space.
* [commento](roles/commento/README.md) - Deploy Commento container.
* [ufw](roles/ufw/README.md) - Configure UFW rules.
* [remark42](roles/remark42/README.md) - Deploy Remark42 container.
* [odoo-enterprise](roles/odoo-enterprise/README.md) - Checkout the Odoo Enterprise git repository.
* [onlyoffice-documentserver](roles/onlyoffice-documentserver/README.md) - Deploy OnlyOffice Document Server container.
* [nextcloud-exporter](roles/nextcloud-exporter/README.md) - Deploy Nextcloud exporter container.
* [pgadmin](roles/pgadmin/README.md) - Install pgAdmin container.
* [bigbluebutton](roles/bigbluebutton/README.md) - Install BigBlueButton with https and greenlight.
* [bigbluebutton-exporter](roles/bigbluebutton-exporter/README.md) - Deploy BigBlueButton exporter container.
* [vercel](roles/vercel/README.md) - Manage vercel domain and dns entries.
* [locale](roles/locale/README.md) - Set system locale.
* [postgres-exporter](roles/postgres-exporter/README.md) - Deploy PostgreSQL exporter container.
* [fstab](roles/fstab/README.md) - Configure the fstab file.
* [redis](roles/redis/README.md) - Deploy Redis container.
| Role | Description |
| ---------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [bigbluebutton-exporter](roles/bigbluebutton-exporter/README.md) | Deploy BigBlueButton exporter container. |
| [bigbluebutton](roles/bigbluebutton/README.md) | Install BigBlueButton with https and greenlight. |
| [bookstack](roles/bookstack/README.md) | Deploy BookStack container. |
| [cadvisor](roles/cadvisor/README.md) | Deploy cAdvisor Docker container. |
| [certbot](roles/certbot/README.md) | Deploy Let's Encrypt certificates. |
| [clean](roles/clean/README.md) | Cleanup Ansible roles. |
| [commento](roles/commento/README.md) | Deploy Commento container. |
| [debug](roles/debug/README.md) | Debug Ansible variables. |
| [docker-network](roles/docker-network/README.md) | Configure Docker network. |
| [docker-volume](roles/docker-volume/README.md) | Configure Docker volume. |
| [docker](roles/docker/README.md) | Install Docker for Ubuntu and CentOS. |
| [elasticsearch](roles/elasticsearch/README.md) | Deploy ElasticSearch Docker cluster. |
| [fstab](roles/fstab/README.md) | Configure the fstab file. |
| [grafana](roles/grafana/README.md) | Deploy Grafana Docker container. |
| [iam](roles/iam/README.md) | Configures users and groups. |
| [keycloak](roles/keycloak/README.md) | Deploy Keycloak Docker container. |
| [kibana](roles/elasticsearch/README.md) | Deploy Kibana Docker container. |
| [locale](roles/locale/README.md) | Set system locale. |
| [logstash](roles/logstash/README.md) | Deploy Logstash Docker container. |
| [maintenance](roles/maintenance/README.md) | Maintain operating system and disk space. |
| [metricbeat](roles/metricbeat/README.md) | Deploy Metricbeat Docker container. |
| [moodle](roles/moodle/README.md) | Deploy Moodle container. |
| [mysql](roles/mysql/README.md) | Deploy MySQL database container. |
| [nextcloud-apps](roles/nextcloud-apps/README.md) | Install, update and remove Nextcloud apps. |
| [nextcloud-exporter](roles/nextcloud-exporter/README.md) | Deploy Nextcloud exporter container. |
| [nextcloud](roles/nextcloud/README.md) | Deploy Nextcloud container. |
| [nginx-waf](roles/nginx-waf/README.md) | Deploy Nginx with ModSecurity and Core Rule Set. |
| [nginx](roles/nginx/README.md) | Deploy Nginx proxy with Certbot. |
| [node-exporter](roles/node-exporter/README.md) | Deploy Node exporter container and install custom metric script. |
| [odoo-apps](roles/odoo-apps/README.md) | Install Odoo apps from file, url, public or private GitHub repo. |
| [odoo-enterprise](roles/odoo-enterprise/README.md) | Checkout the Odoo Enterprise git repository. |
| [odoo-scripts](roles/odoo-scripts/README.md) | Install Odoo scripts. |
| [odoo](roles/odoo/README.md) | Deploy Odoo container. |
| [onlyoffice-documentserver](roles/onlyoffice-documentserver/README.md) | Deploy OnlyOffice Document Server container. |
| [openldap](roles/openldap/README.md) | Deploy OpenLDAP Docker container. |
| [package](roles/package/README.md) | Set env vars and install packages. |
| [pgadmin](roles/pgadmin/README.md) | Install pgAdmin container. |
| [postgres-exporter](roles/postgres-exporter/README.md) | Deploy PostgreSQL exporter container. |
| [postgres](roles/postgres/README.md) | Deploy PostgreSQL database container. |
| [prometheus](roles/prometheus/README.md) | Deploy Prometheus Docker container. |
| [redis](roles/redis/README.md) | Deploy Redis container. |
| [remark42](roles/remark42/README.md) | Deploy Remark42 container. |
| [restic-client](roles/restic-client/README.md) | Configure Restic client backup jobs. |
| [restic-server](roles/restic-server/README.md) | Deploy Restic server container. |
| [ufw](roles/ufw/README.md) | Configure UFW rules. |
| [update](roles/update/README.md) | Install system and package updates. |
| [vercel](roles/vercel/README.md) | Manage vercel domain and dns entries. |
WIP:
+2
View File
@@ -5,6 +5,8 @@
tags: redis
- role: nextcloud
tags: nextcloud
- role: nextcloud-apps
tags: nextcloud-apps
- role: onlyoffice-documentserver
tags: onlyoffice-documentserver
- role: nextcloud-exporter
+30
View File
@@ -0,0 +1,30 @@
# Ansible Nextcloud apps role
Install, update and remove Nextcloud apps.
## Usage
Configure the role.
**vars.yml**
```yml
nextcloud_hostname: nextcloud01 # default: "/usr/share/{{ odoo_hostname }}"
nextcloud_apps:
- name: calendar
state: present
- name: files_external
state: disabled
- name: admin_audit
state: absent
- name: contacts
state: enabled
```
And include it in your playbook.
```yml
- hosts: nextclcoud-apps
roles:
- role: nextcloud-apps
```
+5
View File
@@ -0,0 +1,5 @@
- name: "Include {{ role_name }} tasks"
include_tasks: "{{ role_name }}.yml"
when: nextcloud_apps is defined
tags:
- nextcloud-apps
@@ -0,0 +1,96 @@
- name: Read apps shipped with Nextcloud
command: "docker exec -u www-data {{ nextcloud_hostname }} php occ app:list --shipped=true --no-warnings --output=json"
register: _result
changed_when: false
- name: Parse occ command response as JSON
set_fact:
nextcloud_shipped_apps: "{{ _result.stdout | from_json }}"
- name: Read external apps installed by the user
command: "docker exec -u www-data {{ nextcloud_hostname }} php occ app:list --shipped=false --no-warnings --output=json"
register: _result
changed_when: false
- name: Parse occ command response as JSON
set_fact:
nextcloud_installed_apps: "{{ _result.stdout | from_json }}"
- name: List installed apps
debug:
var: nextcloud_installed_apps
- name: List shipped apps
debug:
var: nextcloud_shipped_apps
- name: List configured apps
debug:
var: nextcloud_apps
# Note: Shipped apps cannot be removed
- name: Remove unwanted apps
command: "docker exec -u www-data {{ nextcloud_hostname }} php occ app:remove {{ item.name }}"
loop: "{{ nextcloud_apps }}"
register: result
failed_when: result.stdout is not search('removed') or result is failed
changed_when: result is not failed
when:
- item.name in (nextcloud_installed_apps.enabled
| combine(nextcloud_installed_apps.disabled))
- item.state | default('enabled') == 'absent'
- name: Install apps
command: "docker exec -u www-data {{ nextcloud_hostname }} php occ app:install {{ item.name }}"
loop: "{{ nextcloud_apps }}"
register: result
failed_when: result.stdout is not search('installed') or result is failed
changed_when: result is not failed
when:
- item.name not in (nextcloud_shipped_apps.enabled
| combine(nextcloud_shipped_apps.disabled))
- item.name not in (nextcloud_installed_apps.enabled
| combine(nextcloud_installed_apps.disabled))
- item.state | default('enabled') != 'absent'
# Update list of available apps after installation and removal:
- name: Re-read installed apps
command: "docker exec -u www-data {{ nextcloud_hostname }} php occ app:list --shipped=false --no-warnings --output=json"
register: _result
changed_when: false
- name: Parse occ command response as JSON
set_fact:
nextcloud_installed_apps: "{{ _result.stdout | from_json }}"
- name: Enable apps
command: "docker exec -u www-data {{ nextcloud_hostname }} php occ app:enable {{ item.name }}"
loop: "{{ nextcloud_apps }}"
when:
- (item.state | default('enabled')) == 'enabled'
- item.name not in (
nextcloud_installed_apps.enabled
| combine(nextcloud_shipped_apps.enabled)
)
- name: Disable apps
command: "docker exec -u www-data {{ nextcloud_hostname }} php occ app:disable {{ item.name }}"
loop: "{{ nextcloud_apps }}"
when:
- (item.state | default('enabled')) == 'disabled'
- item.name not in (
nextcloud_installed_apps.disabled
| combine(nextcloud_shipped_apps.disabled)
)
- name: Update enabled apps
command: "docker exec -u www-data {{ nextcloud_hostname }} php occ app:update {{ item.key }}"
loop: >-
{{
nextcloud_installed_apps.enabled
| combine(nextcloud_shipped_apps.enabled)
| dict2items
}}
register: result
failed_when: result.stdout is search('not installed') or result is failed
changed_when: result.stdout is search('updated') and result is not failed