Skip to content

Commit

Permalink
Add new variable "nextcloud_remove_unknown_apps" to uninstall all non…
Browse files Browse the repository at this point in the history
…-listed
  • Loading branch information
simonspa committed Nov 12, 2019
1 parent b0be11b commit cc478b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ nextcloud_urls:
# You would normally need only one. If you specify more than one, the first one
# will be as the "main" one, for pretty urls, etc.

nextcloud_remove_unknown_apps: false
# Setting to choose whether to remove or keep external apps which have not been
# installed through this role, but manually or via the Nextcloud admin interface

nextcloud_apps: []
# Nextcloud apps to be installed, removed, enabled or disabled
# It is a list of hashes. Eg
Expand All @@ -90,7 +94,9 @@ nextcloud_apps: []
# disabled
#
# Installation and removal is only supported for external apps, apps shipped
# with Nextcloud can only be enabled or disabled.
# with Nextcloud can only be enabled or disabled. By default, only apps with
# the explicit state `absent` are removed, to remove all apps missing from the
# list, set `nextcloud_remove_unknown_apps: true`.
# Currently, always the latest version available from the App Store is
# installed.

Expand Down
10 changes: 8 additions & 2 deletions tasks/core/apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@
]
}}
- name: Set default package state
set_fact:
_default_state: >-
{% if nextcloud_remove_unknown_apps == true %}absent{%
else %}enabled{% endif %}
# Remove all apps from the list of external apps which
# - is not in the configured list of apps
# - is not in the configured list of apps (if nextcloud_remove_unknown_apps is true)
# - is in the configured list of apps but have their state set to "absent"
- name: Remove external apps
command: php occ app:remove "{{ item }}"
Expand All @@ -54,7 +60,7 @@
changed_when: result is not failed
when: >-
((nextcloud_apps | selectattr('name', 'search', item) | list | first
| default({'state':'absent'})).state | default('enabled')) == 'absent'
| default({'state':_default_state})).state | default('enabled')) == 'absent'
# Install all apps from the configured list which
# - are external apps (not in the shipped apps list) and
Expand Down

0 comments on commit cc478b9

Please sign in to comment.