diff --git a/roles/nextcloud/handlers/main.yml b/roles/nextcloud/handlers/main.yml index ed236e4..e183736 100644 --- a/roles/nextcloud/handlers/main.yml +++ b/roles/nextcloud/handlers/main.yml @@ -1,3 +1,3 @@ --- - name: restart notify_push - ansible.builtin.command: supervisorctl restart notify_push + command: supervisorctl restart notify_push diff --git a/roles/nextcloud/tasks/apps.yml b/roles/nextcloud/tasks/apps.yml index 01c8c4a..4f32d7d 100644 --- a/roles/nextcloud/tasks/apps.yml +++ b/roles/nextcloud/tasks/apps.yml @@ -1,21 +1,23 @@ --- - name: install notify_push + when: installation.changed block: - name: install app - ansible.builtin.command: + command: chdir: ~/html cmd: php occ app:install notify_push + creates: ~/html/apps/notify_push - name: set permissions - ansible.builtin.file: - path: ~/html/apps/notify_push/x86_64/notify_push + file: + path: ~/html/apps/notify_push/bin/x86_64/notify_push mode: 0744 - name: create symlink - ansible.builtin.file: + file: path: ~/bin/notify_push - src: ~/html/apps/notify_push/x86_64/notify_push + src: ~/html/apps/notify_push/bin/x86_64/notify_push state: link - name: create service - ansible.builtin.template: + template: src: notify_push_service.j2 dest: ~/etc/services.d/notify_push.ini mode: 0644 @@ -23,19 +25,21 @@ - reload supervisorctl - update supervisorctl - name: get backend list - ansible.builtin.command: uberspace web backend list + command: uberspace web backend list register: backends - name: add backend - when: backend.stdout.find('http:7867') == -1 - ansible.builtin.command: uberspace web backend set /push --http --port 7867 + when: backends.stdout.find('http:7867') == -1 + command: uberspace web backend set /push --http --port 7867 - name: get ip route - ansible.builtin.command: ip route + command: /usr/sbin/ip route register: ip - name: set trusted proxies - ansible.builtin.command: + command: chdir: ~/html - cmd: php occ config:system:set trusted_proxies 0 --value="{{ ip.stdout.split().8 }}" + cmd: php occ config:system:set trusted_proxies 0 --value="{{ ip.stdout.split().15 }}" + - name: Flush handlers + meta: flush_handlers - name: configure notify_push app with backend - ansible.builtin.command: + command: chdir: ~/html cmd: php occ notify_push:setup https://{{ domain }}/push \ No newline at end of file diff --git a/roles/nextcloud/tasks/config.yml b/roles/nextcloud/tasks/config.yml index acb7d4a..43776ab 100644 --- a/roles/nextcloud/tasks/config.yml +++ b/roles/nextcloud/tasks/config.yml @@ -1,90 +1,95 @@ --- - name: configure email - when: use_sendmail + when: use_sendmail and installation.changed block: - name: mail_domain - ansible.builtin.command: + command: chdir: ~/html cmd: php occ config:system:set mail_domain --value="uber.space" - name: mail_from_address - ansible.builtin.command: + command: chdir: ~/html cmd: php occ config:system:set mail_from_address --value="{{ uberspace_user }}" - name: smtp_mode - ansible.builtin.command: + command: chdir: ~/html cmd: php occ config:system:set mail_smtpmode --value="sendmail" - name: sendmail_mode - ansible.builtin.command: + command: chdir: ~/html cmd: php occ config:system:set mail_sendmailmode --value="pipe" - name: initialize URL rewriting + when: installation.changed block: - name: rewrite base - ansible.builtin.command: + command: chdir: ~/html cmd: php occ config:system:set htaccess.RewriteBase --value='/' - name: update htaccess - ansible.builtin.command: + command: chdir: ~/html cmd: php occ maintenance:update:htaccess - name: initialize cronjob + when: installation.changed block: - name: update crontab - ansible.builtin.cron: + cron: name: nextcloud-cron state: present job: php -f $HOME/html/cron.php > $HOME/logs/nextcloud-cron.log 2>&1 - minute: */5 + minute: "*/5" - name: use cronjob for background - ansible.builtin.command: + command: chdir: ~/html cmd: php occ background:cron - name: set up redis + when: installation.changed block: - name: set redis host - ansible.builtin.command: + command: chdir: ~/html cmd: php occ config:system:set redis host --value="/home/{{ uberspace_user }}/.redis/sock" - name: set redis port - ansible.builtin.command: + command: chdir: ~/html cmd: php occ config:system:set redis port --value=0 - name: set redis timeout - ansible.builtin.command: + command: chdir: ~/html - cmd: php occ config:system:set redis port --value=1.5 + cmd: php occ config:system:set redis timeout --value=1.5 - name: enable file locking - ansible.builtin.command: + command: chdir: ~/html cmd: php occ config:system:set filelocking.enabled --value='true' - name: use Redis for memcache.locking - ansible.builtin.command: + command: chdir: ~/html cmd: php occ config:system:set memcache.locking --value='\OC\Memcache\Redis' - name: use Redis for memcache.distributed - ansible.builtin.command: + command: chdir: ~/html cmd: php occ config:system:set memcache.distributed --value='\OC\Memcache\Redis' - name: set default phone region - ansible.builtin.command: + when: installation.changed + command: chdir: ~/html cmd: php occ config:system:set default_phone_region --value='{{ phone_region }}' - name: perform database maintenance + when: installation.changed block: - name: add missing indices - ansible.builtin.command: + command: chdir: ~/html cmd: php occ db:add-missing-indices --no-interaction - name: add missing columns - ansible.builtin.command: + command: chdir: ~/html cmd: php occ db:add-missing-columns --no-interaction - name: add missing primary keys - ansible.builtin.command: + command: chdir: ~/html cmd: php occ db:add-missing-primary-keys --no-interaction - name: convert filecache bigint - ansible.builtin.command: + command: chdir: ~/html cmd: php occ db:convert-filecache-bigint --no-interaction diff --git a/roles/nextcloud/tasks/download.yml b/roles/nextcloud/tasks/download.yml index 640487d..2f2d54e 100644 --- a/roles/nextcloud/tasks/download.yml +++ b/roles/nextcloud/tasks/download.yml @@ -1,17 +1,18 @@ --- - name: download Nextcloud and extract archive - ansible.builtin.unarchive: + unarchive: src: https://download.nextcloud.com/server/releases/latest.tar.bz2 dest: ~/ remote_src: yes creates: ~/nextcloud register: nextcloud_archive - name: copy files to web root - ansible.builtin.copy: + copy: src: ~/nextcloud/ dest: ~/html remote_src: yes + when: nextcloud_archive is successful - name: remove nocontent.html - ansible.builtin.file: + file: path: ~/html/nocontent.html state: absent \ No newline at end of file diff --git a/roles/nextcloud/tasks/mysql.yml b/roles/nextcloud/tasks/mysql.yml index bca3ecf..7073d8b 100644 --- a/roles/nextcloud/tasks/mysql.yml +++ b/roles/nextcloud/tasks/mysql.yml @@ -1,4 +1,4 @@ --- - name: create MySQL database community.mysql.mysql_db: - name: "{{ uberspace_user }}"_nextcloud + name: "{{ uberspace_user }}_nextcloud" diff --git a/roles/nextcloud/tasks/php.yml b/roles/nextcloud/tasks/php.yml index 6883db8..8af0420 100644 --- a/roles/nextcloud/tasks/php.yml +++ b/roles/nextcloud/tasks/php.yml @@ -1,27 +1,27 @@ --- - name: enable PHP opcache - ansible.builtin.template: + template: src: opcache.j2 dest: ~/etc/php.d/opcache.ini mode: 0644 notify: - restart php - name: enable PHP APCu - ansible.builtin.template: + template: src: apcu.j2 dest: ~/etc/php.d/apcu.ini mode: 0644 notify: - restart php - name: set PHP memory limit to 512 MB - ansible.builtin.template: + template: src: memory_limit.j2 dest: ~/etc/php.d/memory_limit.ini mode: 0644 notify: - restart php - name: disable PHP output buffering - ansible.builtin.template: + template: src: output_buffering.j2 dest: ~/etc/php.d/output_buffering.ini mode: 0644 diff --git a/roles/nextcloud/tasks/prepare_updates.yml b/roles/nextcloud/tasks/prepare_updates.yml index 439aedc..565d6db 100644 --- a/roles/nextcloud/tasks/prepare_updates.yml +++ b/roles/nextcloud/tasks/prepare_updates.yml @@ -1,11 +1,11 @@ --- - name: create update script - ansible.builtin.template: + template: src: update.j2 dest: ~/bin/nextcloud-update mode: 0744 - name: create cronjob for updates - ansible.builtin.cron: + cron: name: nextcloud-update state: present job: $HOME/bin/nextcloud-update > $HOME/logs/nextcloud-update.log 2>&1 diff --git a/roles/nextcloud/tasks/setup.yml b/roles/nextcloud/tasks/setup.yml index 76d51d9..a3fb5a0 100644 --- a/roles/nextcloud/tasks/setup.yml +++ b/roles/nextcloud/tasks/setup.yml @@ -1,26 +1,34 @@ --- - name: run installation script - ansible.builtin.command: + command: chdir: ~/html cmd: php occ maintenance:install --admin-user "{{ nextcloud_admin_user }}" --admin-pass "{{ nextcloud_admin_password }}" --database 'mysql' --database-name "{{ uberspace_user }}_nextcloud" --database-user "{{ uberspace_user }}" --database-pass "{{ mysql_password }}" --data-dir "/home/{{ uberspace_user }}/nextcloud_data" creates: ~/nextcloud_data + register: installation - name: set domain as trusted - ansible.builtin.command: + command: chdir: ~/html cmd: php occ config:system:set trusted_domains 0 --value="{{ domain }}" + when: installation.changed - name: set domain as overwrite cli url - ansible.builtin.command: + command: chdir: ~/html cmd: php occ config:system:set overwrite.cli.url --value="https://{{ domain }}" + when: installation.changed - name: create symlinks for logs + when: installation.changed block: - name: symlink for nextcloud log - ansible.builtin.file: + file: path: ~/logs/nextcloud.log src: ~/nextcloud_data/nextcloud.log state: link + - name: touch updater.log + file: + path: ~/nextcloud_data/updater.log + state: touch - name: symlink for nextcloud updater log - ansible.builtin.file: + file: path: ~/logs/nextcloud-updater.log src: ~/nextcloud_data/updater.log state: link diff --git a/roles/redis/templates/redis_service.j2 b/roles/redis/templates/redis_service.j2 index 47535c0..73d2477 100644 --- a/roles/redis/templates/redis_service.j2 +++ b/roles/redis/templates/redis_service.j2 @@ -1,5 +1,5 @@ [program:redis] -command=redis-server %(ENV_HOME)s/.redis/conf +command=redis-server %(ENV_HOME)s/.redis/config directory=%(ENV_HOME)s/.redis autostart=yes autorestart=yes