mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-26 21:45:20 +02:00
Moved update commands to nextcloud role
This commit is contained in:
parent
a57fe718de
commit
39a54294dd
@ -160,23 +160,6 @@ def upgrade_listmonk():
|
|||||||
run_command('echo "y" | docker compose run -T application ./listmonk --upgrade')
|
run_command('echo "y" | docker compose run -T application ./listmonk --upgrade')
|
||||||
print("Upgrade complete.")
|
print("Upgrade complete.")
|
||||||
|
|
||||||
def update_nextcloud():
|
|
||||||
"""
|
|
||||||
Performs the necessary Nextcloud update procedures, including maintenance and app updates.
|
|
||||||
"""
|
|
||||||
print("Start Nextcloud upgrade procedure.")
|
|
||||||
update_procedure("docker-compose exec -T -u www-data application /var/www/html/occ upgrade")
|
|
||||||
print("Start Nextcloud repairing procedure.")
|
|
||||||
update_procedure("docker-compose exec -T -u www-data application /var/www/html/occ maintenance:repair --include-expensive")
|
|
||||||
print("Start Nextcloud update procedure.")
|
|
||||||
update_procedure("docker-compose exec -T -u www-data application /var/www/html/occ app:update --all")
|
|
||||||
print("Start Nextcloud add-missing procedure.")
|
|
||||||
update_procedure("docker-compose exec -T -u www-data application /var/www/html/occ db:add-missing-columns")
|
|
||||||
update_procedure("docker-compose exec -T -u www-data application /var/www/html/occ db:add-missing-indices")
|
|
||||||
update_procedure("docker-compose exec -T -u www-data application /var/www/html/occ db:add-missing-primary-keys")
|
|
||||||
print("Deactivate Maintanance Mode")
|
|
||||||
update_procedure("docker-compose exec -T -u www-data application /var/www/html/occ maintenance:mode --off")
|
|
||||||
|
|
||||||
def update_procedure(command):
|
def update_procedure(command):
|
||||||
"""
|
"""
|
||||||
Attempts to execute a command up to a maximum number of retries.
|
Attempts to execute a command up to a maximum number of retries.
|
||||||
@ -239,8 +222,6 @@ if __name__ == "__main__":
|
|||||||
upgrade_listmonk()
|
upgrade_listmonk()
|
||||||
elif os.path.basename(dir_path) == "mastodon":
|
elif os.path.basename(dir_path) == "mastodon":
|
||||||
update_mastodon()
|
update_mastodon()
|
||||||
elif os.path.basename(dir_path) == "nextcloud":
|
|
||||||
update_nextcloud()
|
|
||||||
|
|
||||||
# @todo implement dedicated procedure for bluesky
|
# @todo implement dedicated procedure for bluesky
|
||||||
# @todo implement dedicated procedure for taiga
|
# @todo implement dedicated procedure for taiga
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
|
|
||||||
- name: Copy include instructions to the container
|
- name: Copy include instructions to the container
|
||||||
command: >
|
command: >
|
||||||
docker cp {{ nextcloud_host_include_instructions_file }} {{ nextcloud_container }}:{{ nextcloud_docker_include_instructions_file }}
|
docker cp {{ nextcloud_host_include_instructions_file }} {{ NEXTCLOUD_CONTAINER }}:{{ nextcloud_docker_include_instructions_file }}
|
||||||
|
|
||||||
- name: Append generated config to config.php only if not present
|
- name: Append generated config to config.php only if not present
|
||||||
command: >
|
command: >
|
||||||
docker exec -u {{ nextcloud_docker_user }} {{ nextcloud_container }} sh -c "
|
docker exec -u {{ NEXTCLOUD_DOCKER_USER }} {{ NEXTCLOUD_CONTAINER }} sh -c "
|
||||||
grep -q '{{ nextcloud_docker_config_additives_directory }}' {{ nextcloud_docker_config_file }} ||
|
grep -q '{{ nextcloud_docker_config_additives_directory }}' {{ nextcloud_docker_config_file }} ||
|
||||||
cat {{ nextcloud_docker_include_instructions_file }} >> {{ nextcloud_docker_config_file }}"
|
cat {{ nextcloud_docker_include_instructions_file }} >> {{ nextcloud_docker_config_file }}"
|
||||||
notify: docker compose restart
|
notify: docker compose restart
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
- name: "Add missing DB indices in Nextcloud (single run)"
|
|
||||||
ansible.builtin.shell: |
|
|
||||||
set -e
|
|
||||||
{{ nextcloud_docker_exec_occ }} db:add-missing-indices
|
|
||||||
args:
|
|
||||||
executable: /bin/bash
|
|
||||||
vars:
|
|
||||||
# Give the command enough time without async/poll overhead
|
|
||||||
ansible_command_timeout: 3600
|
|
||||||
register: db_indices_result
|
|
||||||
failed_when: db_indices_result.rc != 0
|
|
||||||
changed_when: >
|
|
||||||
('Adding additional' in (db_indices_result.stdout | default(''))) or
|
|
||||||
('Removing' in (db_indices_result.stdout | default(''))) or
|
|
||||||
('updated successfully' in (db_indices_result.stdout | default('')))
|
|
34
roles/web-app-nextcloud/tasks/02_upgrade.yml
Normal file
34
roles/web-app-nextcloud/tasks/02_upgrade.yml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
- name: Nextcloud | Upgrade
|
||||||
|
command: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} upgrade"
|
||||||
|
register: occ_upgrade
|
||||||
|
changed_when: "'Already up to date' not in occ_upgrade.stdout"
|
||||||
|
|
||||||
|
- name: Nextcloud | Maintenance repair
|
||||||
|
command: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} maintenance:repair --include-expensive"
|
||||||
|
register: occ_repair
|
||||||
|
changed_when: "'No repairs needed' not in occ_repair.stdout"
|
||||||
|
|
||||||
|
- name: Nextcloud | App update
|
||||||
|
command: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} app:update --all"
|
||||||
|
register: occ_app_update
|
||||||
|
changed_when: "'No apps found for update' not in occ_app_update.stdout"
|
||||||
|
|
||||||
|
- name: Nextcloud | Add missing columns
|
||||||
|
command: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} db:add-missing-columns"
|
||||||
|
register: occ_columns
|
||||||
|
changed_when: "'No columns found' not in occ_columns.stdout"
|
||||||
|
|
||||||
|
- name: Nextcloud | Add missing indices
|
||||||
|
command: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} db:add-missing-indices"
|
||||||
|
register: occ_indices
|
||||||
|
changed_when: "'No indices found' not in occ_indices.stdout"
|
||||||
|
|
||||||
|
- name: Nextcloud | Add missing primary keys
|
||||||
|
command: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} db:add-missing-primary-keys"
|
||||||
|
register: occ_pks
|
||||||
|
changed_when: "'No primary keys found' not in occ_pks.stdout"
|
||||||
|
|
||||||
|
- name: Nextcloud | Disable maintenance mode
|
||||||
|
command: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} maintenance:mode --off"
|
||||||
|
register: occ_maint_off
|
||||||
|
changed_when: "'already disabled' not in occ_maint_off.stdout"
|
@ -1,6 +1,6 @@
|
|||||||
- name: Ensure Nextcloud administrator is in the 'admin' group
|
- name: Ensure Nextcloud administrator is in the 'admin' group
|
||||||
command: >
|
command: >
|
||||||
docker exec -u {{ nextcloud_docker_user }} {{ nextcloud_container }}
|
docker exec -u {{ NEXTCLOUD_DOCKER_USER }} {{ NEXTCLOUD_CONTAINER }}
|
||||||
php occ group:adduser admin {{ nextcloud_administrator_username }}
|
php occ group:adduser admin {{ nextcloud_administrator_username }}
|
||||||
register: add_admin_to_group
|
register: add_admin_to_group
|
||||||
changed_when: "not ASYNC_ENABLED and 'Added user' in (add_admin_to_group.stdout | default(''))"
|
changed_when: "not ASYNC_ENABLED and 'Added user' in (add_admin_to_group.stdout | default(''))"
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
{% for item in nextcloud_system_config %}
|
{% for item in nextcloud_system_config %}
|
||||||
{{ nextcloud_docker_exec_occ }} \
|
{{ NEXTCLOUD_DOCKER_EXEC_OCC }} \
|
||||||
config:system:set {{ item.parameter }}{% if item.type is defined %} --type {{ item.type }}{% endif %} \
|
config:system:set {{ item.parameter }}{% if item.type is defined %} --type {{ item.type }}{% endif %} \
|
||||||
--value '{{ (item.value | string) | regex_replace("'", "'" ~ '"' ~ "'" ~ '"' ~ "'") }}'
|
--value '{{ (item.value | string) | regex_replace("'", "'" ~ '"' ~ "'" ~ '"' ~ "'") }}'
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
when: plugin_value.enabled | bool
|
when: plugin_value.enabled | bool
|
||||||
|
|
||||||
- name: disable {{ plugin_key }} nextcloud plugin
|
- name: disable {{ plugin_key }} nextcloud plugin
|
||||||
command: "{{ nextcloud_docker_exec_occ }} app:disable {{ plugin_key }}"
|
command: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} app:disable {{ plugin_key }}"
|
||||||
register: disable_result
|
register: disable_result
|
||||||
changed_when: >
|
changed_when: >
|
||||||
not ASYNC_ENABLED and
|
not ASYNC_ENABLED and
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
# do not set -e here; allow per-line fallbacks
|
# do not set -e here; allow per-line fallbacks
|
||||||
{% for incompatible_plugin in (plugin_value.incompatible_plugins | default([])) %}
|
{% for incompatible_plugin in (plugin_value.incompatible_plugins | default([])) %}
|
||||||
{{ nextcloud_docker_exec_occ }} app:disable {{ incompatible_plugin }} || true
|
{{ NEXTCLOUD_DOCKER_EXEC_OCC }} app:disable {{ incompatible_plugin }} || true
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
args:
|
args:
|
||||||
executable: /bin/bash
|
executable: /bin/bash
|
||||||
@ -22,7 +22,7 @@
|
|||||||
poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}"
|
poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}"
|
||||||
|
|
||||||
- name: install {{ plugin_key }} nextcloud plugin
|
- name: install {{ plugin_key }} nextcloud plugin
|
||||||
command: "{{ nextcloud_docker_exec_occ }} app:install {{ plugin_key }}"
|
command: "{{ NEXTCLOUD_DOCKER_EXEC_OCC }} app:install {{ plugin_key }}"
|
||||||
register: install_result
|
register: install_result
|
||||||
failed_when: >
|
failed_when: >
|
||||||
install_result.rc != 0
|
install_result.rc != 0
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
- name: enable {{plugin_key}} nextcloud plugin
|
- name: enable {{plugin_key}} nextcloud plugin
|
||||||
command: "{{nextcloud_docker_exec_occ}} app:enable {{plugin_key}}"
|
command: "{{NEXTCLOUD_DOCKER_EXEC_OCC}} app:enable {{plugin_key}}"
|
||||||
register: enable_result
|
register: enable_result
|
||||||
changed_when: enable_result.rc == 0 and ("already enabled" not in enable_result.stdout)
|
changed_when: enable_result.rc == 0 and ("already enabled" not in enable_result.stdout)
|
||||||
|
|
||||||
@ -19,7 +19,7 @@
|
|||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
{% for item in (plugin_configuration | default([])) %}
|
{% for item in (plugin_configuration | default([])) %}
|
||||||
{{ nextcloud_docker_exec_occ }} \
|
{{ NEXTCLOUD_DOCKER_EXEC_OCC }} \
|
||||||
config:app:set {{ item.appid }} {{ item.configkey }} \
|
config:app:set {{ item.appid }} {{ item.configkey }} \
|
||||||
--value '{{ ( (item.configvalue | to_json) if (item.configvalue is mapping) else (item.configvalue | string) )
|
--value '{{ ( (item.configvalue | to_json) if (item.configvalue is mapping) else (item.configvalue | string) )
|
||||||
| regex_replace("'", "'" ~ '"' ~ "'" ~ '"' ~ "'") }}'
|
| regex_replace("'", "'" ~ '"' ~ "'" ~ '"' ~ "'") }}'
|
||||||
|
@ -34,8 +34,8 @@
|
|||||||
template:
|
template:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: "{{ nextcloud_host_config_additives_directory }}/{{ item | basename | regex_replace('\\.j2$', '') }}"
|
dest: "{{ nextcloud_host_config_additives_directory }}/{{ item | basename | regex_replace('\\.j2$', '') }}"
|
||||||
owner: "{{ nextcloud_docker_user_id }}"
|
owner: "{{ NEXTCLOUD_DOCKER_USER_id }}"
|
||||||
group: "{{ nextcloud_docker_user_id }}"
|
group: "{{ NEXTCLOUD_DOCKER_USER_id }}"
|
||||||
loop: "{{ lookup('fileglob', role_path ~ '/templates/config/*.j2', wantlist=True) }}"
|
loop: "{{ lookup('fileglob', role_path ~ '/templates/config/*.j2', wantlist=True) }}"
|
||||||
# Not all type of changes take instantly place. Due to this reason a rebuild is required.
|
# Not all type of changes take instantly place. Due to this reason a rebuild is required.
|
||||||
notify: docker compose up
|
notify: docker compose up
|
||||||
@ -52,10 +52,14 @@
|
|||||||
- name: Flush all handlers immediately so that occ can be used
|
- name: Flush all handlers immediately so that occ can be used
|
||||||
meta: flush_handlers
|
meta: flush_handlers
|
||||||
|
|
||||||
|
- name: Update\Upgrade Nextcloud
|
||||||
|
include_tasks: 02_upgrade
|
||||||
|
when: MODE_UPDATE | bool
|
||||||
|
|
||||||
- name: Load system configuration steps
|
- name: Load system configuration steps
|
||||||
include_tasks: "{{ item }}"
|
include_tasks: "{{ item }}"
|
||||||
loop:
|
loop:
|
||||||
- 02_add_missing_indices.yml
|
- 02_upgrade
|
||||||
- 03_admin.yml
|
- 03_admin.yml
|
||||||
- 04_system_config.yml
|
- 04_system_config.yml
|
||||||
|
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
- name: Set Nextcloud LDAP bind password
|
- name: Set Nextcloud LDAP bind password
|
||||||
command: >
|
command: >
|
||||||
{{ nextcloud_docker_exec_occ }} ldap:set-config s01 ldapAgentPassword "{{ ldap.bind_credential }}"
|
{{ NEXTCLOUD_DOCKER_EXEC_OCC }} ldap:set-config s01 ldapAgentPassword "{{ ldap.bind_credential }}"
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
application:
|
application:
|
||||||
image: "{{ nextcloud_image }}:{{ nextcloud_version }}"
|
image: "{{ nextcloud_image }}:{{ nextcloud_version }}"
|
||||||
container_name: {{ nextcloud_container }}
|
container_name: {{ NEXTCLOUD_CONTAINER }}
|
||||||
volumes:
|
volumes:
|
||||||
- data:{{ NEXTCLOUD_DOCKER_WORK_DIRECTORY }}
|
- data:{{ NEXTCLOUD_DOCKER_WORK_DIRECTORY }}
|
||||||
- {{nextcloud_host_config_additives_directory}}:{{nextcloud_docker_config_additives_directory}}:ro
|
- {{nextcloud_host_config_additives_directory}}:{{nextcloud_docker_config_additives_directory}}:ro
|
||||||
|
@ -31,7 +31,7 @@ nextcloud_volume: "{{ applications | get_app_conf(
|
|||||||
|
|
||||||
nextcloud_version: "{{ applications | get_app_conf(application_id, 'docker.services.nextcloud.version') }}"
|
nextcloud_version: "{{ applications | get_app_conf(application_id, 'docker.services.nextcloud.version') }}"
|
||||||
nextcloud_image: "{{ applications | get_app_conf(application_id, 'docker.services.nextcloud.image') }}"
|
nextcloud_image: "{{ applications | get_app_conf(application_id, 'docker.services.nextcloud.image') }}"
|
||||||
nextcloud_container: "{{ applications | get_app_conf(application_id, 'docker.services.nextcloud.name') }}"
|
NEXTCLOUD_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.nextcloud.name') }}"
|
||||||
|
|
||||||
nextcloud_proxy_name: "{{ applications | get_app_conf(application_id, 'docker.services.proxy.name') }}"
|
nextcloud_proxy_name: "{{ applications | get_app_conf(application_id, 'docker.services.proxy.name') }}"
|
||||||
nextcloud_proxy_image: "{{ applications | get_app_conf(application_id, 'docker.services.proxy.image') }}"
|
nextcloud_proxy_image: "{{ applications | get_app_conf(application_id, 'docker.services.proxy.image') }}"
|
||||||
@ -56,8 +56,8 @@ NEXTCLOUD_COLLABORA_URL: "{{ domains | get_url('web-svc-c
|
|||||||
NEXTCLOUD_COLLABORA_ENABLED: "{{ applications | get_app_conf(application_id, 'plugins.richdocuments.enabled') }}"
|
NEXTCLOUD_COLLABORA_ENABLED: "{{ applications | get_app_conf(application_id, 'plugins.richdocuments.enabled') }}"
|
||||||
|
|
||||||
## User Configuration
|
## User Configuration
|
||||||
nextcloud_docker_user_id: 82 # UID of the www-data user
|
NEXTCLOUD_DOCKER_USER_id: 82 # UID of the www-data user
|
||||||
nextcloud_docker_user: "www-data" # Name of the www-data user (Set here to easy change it in the future)
|
NEXTCLOUD_DOCKER_USER: "www-data" # Name of the www-data user (Set here to easy change it in the future)
|
||||||
|
|
||||||
## Internal Paths
|
## Internal Paths
|
||||||
NEXTCLOUD_DOCKER_WORK_DIRECTORY: "/var/www/html/" # Name of the workdir in which the application is stored
|
NEXTCLOUD_DOCKER_WORK_DIRECTORY: "/var/www/html/" # Name of the workdir in which the application is stored
|
||||||
@ -67,5 +67,5 @@ nextcloud_docker_config_additives_directory: "{{ NEXTCLOUD_DOCKER_CONFIG_DIRE
|
|||||||
nextcloud_docker_include_instructions_file: "/tmp/includes.php" # Path to the temporary file which will be included to the config.php to load the additional configurations
|
nextcloud_docker_include_instructions_file: "/tmp/includes.php" # Path to the temporary file which will be included to the config.php to load the additional configurations
|
||||||
|
|
||||||
## Execution
|
## Execution
|
||||||
nextcloud_docker_exec: "docker exec -u {{ nextcloud_docker_user }} {{ nextcloud_container }}" # General execute composition
|
NEXTCLOUD_DOCKER_EXEC: "docker exec -u {{ NEXTCLOUD_DOCKER_USER }} {{ NEXTCLOUD_CONTAINER }}" # General execute composition
|
||||||
nextcloud_docker_exec_occ: "{{nextcloud_docker_exec}} {{ NEXTCLOUD_DOCKER_WORK_DIRECTORY }}occ" # Execute docker occ command
|
NEXTCLOUD_DOCKER_EXEC_OCC: "{{NEXTCLOUD_DOCKER_EXEC}} {{ NEXTCLOUD_DOCKER_WORK_DIRECTORY }}occ" # Execute docker occ command
|
Loading…
x
Reference in New Issue
Block a user