Browse Source

more improvements

master
parent
commit
cc8cb3f30d
14 changed files with 88 additions and 41 deletions
  1. +5
    -2
      defaults/main.yml
  2. +13
    -5
      tasks/access.yml
  3. +5
    -0
      tasks/apache2.yml
  4. +4
    -4
      tasks/apps.yml
  5. +3
    -3
      tasks/check.yaml
  6. +5
    -5
      tasks/configure.yml
  7. +29
    -10
      tasks/core.yml
  8. +10
    -3
      tasks/install.yml
  9. +1
    -1
      tasks/main.yml
  10. +6
    -1
      tasks/reset.yml
  11. +1
    -1
      tasks/upgrade.yml
  12. +4
    -4
      templates/apache-vhost.conf.j2
  13. +1
    -1
      templates/config.php.j2
  14. +1
    -1
      templates/nextcloud-cron.service

+ 5
- 2
defaults/main.yml View File

@@ -2,9 +2,12 @@ nextcloud_state: installed


nextcloud_archive_directory: /opt/nextcloud nextcloud_archive_directory: /opt/nextcloud


nextcloud_directory: /var/www/nextcloud
nextcloud_directory: /var/www/nextcloud-{{nextcloud_version}}


nextcloud_data_directory: /var/lib/nextcloud/data
nextcloud_lib_directory: /var/lib/nextcloud
nextcloud_data_directory: "{{nextcloud_lib_directory}}/data"

nextcloud_log_directory: /var/log/nextcloud


nextcloud_version: 14.0.3 nextcloud_version: 14.0.3




+ 13
- 5
tasks/access.yml View File

@@ -2,7 +2,7 @@


- name: nextcloud directory - name: nextcloud directory
file: file:
path: /var/www/nextcloud
path: "{{nextcloud_directory}}"
state: directory state: directory
owner: root owner: root
group: www-data group: www-data
@@ -10,7 +10,7 @@


- name: nextcloud subdirectories - name: nextcloud subdirectories
file: file:
path: /var/www/nextcloud/{{item}}
path: "{{nextcloud_directory}}/{{item}}"
state: directory state: directory
owner: www-data owner: www-data
group: www-data group: www-data
@@ -20,7 +20,14 @@
- apps - apps
- themes - themes
- updater - updater
- data

- name: nextcloud data directory
file:
path: "{{nextcloud_lib_directory}}"
state: directory
owner: www-data
group: www-data
mode: 0750


- name: nextcloud data directory - name: nextcloud data directory
file: file:
@@ -28,18 +35,19 @@
state: directory state: directory
owner: www-data owner: www-data
group: www-data group: www-data
mode: 0750
recurse: yes recurse: yes


- name: nextcloud log directory - name: nextcloud log directory
file: file:
path: /var/log/nextcloud
path: "{{nextcloud_log_directory}}"
state: directory state: directory
owner: www-data owner: www-data
group: www-data group: www-data


- name: nextcloud htaccess webserver access - name: nextcloud htaccess webserver access
file: file:
path: /var/www/nextcloud/.htaccess
path: "{{nextcloud_directory}}/.htaccess"
state: file state: file
owner: www-data owner: www-data
group: www-data group: www-data


+ 5
- 0
tasks/apache2.yml View File

@@ -28,3 +28,8 @@
src: apache2-ports.conf.j2 src: apache2-ports.conf.j2
dest: /etc/apache2/ports.conf dest: /etc/apache2/ports.conf
notify: restart apache2 notify: restart apache2

- name: start apache2
service:
name: apache2
state: started

+ 4
- 4
tasks/apps.yml View File

@@ -3,7 +3,7 @@
- name: occ app list - name: occ app list
command: php occ app:list command: php occ app:list
args: args:
chdir: /var/www/nextcloud
chdir: "{{nextcloud_directory}}"
register: _nextcloud_occ_app_list register: _nextcloud_occ_app_list
changed_when: false changed_when: false
become: true become: true
@@ -14,7 +14,7 @@
command: php occ app:install {{item}} command: php occ app:install {{item}}
with_items: "{{ nextcloud_apps | difference(_nextcloud_apps_present) }}" with_items: "{{ nextcloud_apps | difference(_nextcloud_apps_present) }}"
args: args:
chdir: /var/www/nextcloud
chdir: "{{nextcloud_directory}}"
become: true become: true
become_user: www-data become_user: www-data
become_method: sudo become_method: sudo
@@ -22,7 +22,7 @@
- name: occ app list - name: occ app list
command: php occ app:list command: php occ app:list
args: args:
chdir: /var/www/nextcloud
chdir: "{{nextcloud_directory}}"
register: _nextcloud_occ_app_list register: _nextcloud_occ_app_list
changed_when: false changed_when: false
become: true become: true
@@ -33,7 +33,7 @@
command: php occ app:enable {{item}} command: php occ app:enable {{item}}
with_items: "{{ nextcloud_apps | difference(_nextcloud_apps_enabled) }}" with_items: "{{ nextcloud_apps | difference(_nextcloud_apps_enabled) }}"
args: args:
chdir: /var/www/nextcloud
chdir: "{{nextcloud_directory}}"
become: true become: true
become_user: www-data become_user: www-data
become_method: sudo become_method: sudo

+ 3
- 3
tasks/check.yaml View File

@@ -3,7 +3,7 @@
- name: nextcloud core integrity check - name: nextcloud core integrity check
command: php occ integrity:check-core command: php occ integrity:check-core
args: args:
chdir: /var/www/nextcloud
chdir: {{nextcloud_directory}}
changed_when: false changed_when: false
become: true become: true
become_user: www-data become_user: www-data
@@ -12,7 +12,7 @@
- name: occ app list - name: occ app list
command: php occ app:list command: php occ app:list
args: args:
chdir: /var/www/nextcloud
chdir: {{nextcloud_directory}}
register: _nextcloud_occ_app_list register: _nextcloud_occ_app_list
changed_when: false changed_when: false
become: true become: true
@@ -23,7 +23,7 @@
command: php occ integrity:check-app {{item}} command: php occ integrity:check-app {{item}}
with_items: "{{ _nextcloud_apps_present }}" with_items: "{{ _nextcloud_apps_present }}"
args: args:
chdir: /var/www/nextcloud
chdir: {{nextcloud_directory}}
changed_when: false changed_when: false
become: true become: true
become_user: www-data become_user: www-data


+ 5
- 5
tasks/configure.yml View File

@@ -5,32 +5,32 @@
- name: nextcloud list config - name: nextcloud list config
command: php occ config:list command: php occ config:list
args: args:
chdir: /var/www/nextcloud
chdir: "{{nextcloud_directory}}"
register: _nextcloud_config_cmd register: _nextcloud_config_cmd
changed_when: false changed_when: false


- name: nextcloud occ config:app:delete trusted_domains - name: nextcloud occ config:app:delete trusted_domains
command: php occ config:system:delete trusted_domains command: php occ config:system:delete trusted_domains
args: args:
chdir: /var/www/nextcloud
chdir: "{{nextcloud_directory}}"
when: _nextcloud_config.system.trusted_domains != nextcloud_server_names when: _nextcloud_config.system.trusted_domains != nextcloud_server_names


- name: nextcloud occ config:system:set trusted_domains - name: nextcloud occ config:system:set trusted_domains
command: php occ config:system:set trusted_domains {{ item.0 }} --value={{ item.1 }} command: php occ config:system:set trusted_domains {{ item.0 }} --value={{ item.1 }}
args: args:
chdir: /var/www/nextcloud
chdir: "{{nextcloud_directory}}"
with_indexed_items: "{{ nextcloud_server_names }}" with_indexed_items: "{{ nextcloud_server_names }}"
when: _nextcloud_config.system.trusted_domains != nextcloud_server_names when: _nextcloud_config.system.trusted_domains != nextcloud_server_names


- name: nextcloud occ maintenance:update:htaccess - name: nextcloud occ maintenance:update:htaccess
command: php occ maintenance:update:htaccess command: php occ maintenance:update:htaccess
args: args:
chdir: /var/www/nextcloud
chdir: "{{nextcloud_directory}}"


- name: nextcloud occ background:cron - name: nextcloud occ background:cron
command: php occ background:cron command: php occ background:cron
args: args:
chdir: /var/www/nextcloud
chdir: "{{nextcloud_directory}}"


become: true become: true
become_user: www-data become_user: www-data


+ 29
- 10
tasks/core.yml View File

@@ -5,37 +5,56 @@
url: https://apps.nextcloud.com/api/v1/platforms.json url: https://apps.nextcloud.com/api/v1/platforms.json
register: _nextcloud_platforms register: _nextcloud_platforms


- name: nextcloud version dir
file:
path: "{{nextcloud_archive_directory}}/{{ nextcloud_version }}"
state: directory

- name: nextcloud core archive checksum download - name: nextcloud core archive checksum download
get_url: get_url:
url: https://download.nextcloud.com/server/releases/nextcloud-{{ nextcloud_version }}.tar.bz2.sha256 url: https://download.nextcloud.com/server/releases/nextcloud-{{ nextcloud_version }}.tar.bz2.sha256
dest: "{{nextcloud_archive_directory}}/nextcloud-{{ nextcloud_version }}.tar.bz2.sha256"
dest: "{{nextcloud_archive_directory}}/{{ nextcloud_version }}/nextcloud-{{ nextcloud_version }}.tar.bz2.sha256"


- name: nextcloud core archive checksum - name: nextcloud core archive checksum
shell: cat "{{nextcloud_archive_directory}}/nextcloud-{{ nextcloud_version }}.tar.bz2.sha256"
shell: cat "{{nextcloud_archive_directory}}/{{ nextcloud_version }}/nextcloud-{{ nextcloud_version }}.tar.bz2.sha256"
register: _nextcloud_server_archive_checksum register: _nextcloud_server_archive_checksum
changed_when: false changed_when: false


- name: nextcloud core archive download - name: nextcloud core archive download
get_url: get_url:
url: https://download.nextcloud.com/server/releases/nextcloud-{{ nextcloud_version }}.tar.bz2 url: https://download.nextcloud.com/server/releases/nextcloud-{{ nextcloud_version }}.tar.bz2
dest: "{{nextcloud_archive_directory}}/nextcloud-{{ nextcloud_version }}.tar.bz2"
dest: "{{nextcloud_archive_directory}}/{{ nextcloud_version }}/nextcloud-{{ nextcloud_version }}.tar.bz2"
checksum: sha256:{{ _nextcloud_server_archive_checksum.stdout_lines[0].split(' ')[0] }} checksum: sha256:{{ _nextcloud_server_archive_checksum.stdout_lines[0].split(' ')[0] }}


- name: nextcloud core archive signature download - name: nextcloud core archive signature download
get_url: get_url:
url: https://download.nextcloud.com/server/releases/nextcloud-{{ nextcloud_version }}.tar.bz2.asc url: https://download.nextcloud.com/server/releases/nextcloud-{{ nextcloud_version }}.tar.bz2.asc
dest: "{{nextcloud_archive_directory}}/nextcloud-{{ nextcloud_version }}.tar.bz2.asc"
dest: "{{nextcloud_archive_directory}}/{{ nextcloud_version }}/nextcloud-{{ nextcloud_version }}.tar.bz2.asc"


- name: nextcloud core archive signature check - name: nextcloud core archive signature check
command: gpg --no-default-keyring --keyring "{{nextcloud_archive_directory}}/keyring.gpg" command: gpg --no-default-keyring --keyring "{{nextcloud_archive_directory}}/keyring.gpg"
--verify "{{nextcloud_archive_directory}}/nextcloud-{{ nextcloud_version }}.tar.bz2.asc"
"{{nextcloud_archive_directory}}/nextcloud-{{ nextcloud_version }}.tar.bz2"
--verify "{{nextcloud_archive_directory}}/{{ nextcloud_version }}/nextcloud-{{ nextcloud_version }}.tar.bz2.asc"
"{{nextcloud_archive_directory}}/{{ nextcloud_version }}/nextcloud-{{ nextcloud_version }}.tar.bz2"
changed_when: false changed_when: false


- name: nextcloud core extract
- name: nextcloud core archive extract
unarchive: unarchive:
src: "{{nextcloud_archive_directory}}/nextcloud-{{ nextcloud_version }}.tar.bz2"
src: "{{nextcloud_archive_directory}}/{{ nextcloud_version }}/nextcloud-{{ nextcloud_version }}.tar.bz2"
remote_src: yes remote_src: yes
dest: /var/www/
dest: "{{nextcloud_archive_directory}}/{{ nextcloud_version }}"
owner: root owner: root
group: www-data
group: root

- name: nextcloud core archive sync
synchronize:
src: "{{nextcloud_archive_directory}}/{{ nextcloud_version }}/nextcloud/"
dest: "{{nextcloud_directory}}"
archive: no
recursive: yes
delegate_to: '{{ inventory_hostname }}'

- name: link to current nextcloud directory
file:
src: "{{nextcloud_directory}}"
dest: /var/www/nextcloud
state: link

+ 10
- 3
tasks/install.yml View File

@@ -2,13 +2,19 @@


- name: check for config file - name: check for config file
stat: stat:
path: /var/www/nextcloud/config/config.php
path: "{{nextcloud_directory}}/config/config.php"
register: _nextcloud_config_file register: _nextcloud_config_file


- name: stop apache2
service:
name: apache2
state: stopped
when: not _nextcloud_config_file.stat.isreg is defined

- name: nextcloud initial config file - name: nextcloud initial config file
template: template:
src: config.php.j2 src: config.php.j2
dest: /var/www/nextcloud/config/config.php
dest: "{{nextcloud_directory}}/config/config.php"
owner: www-data owner: www-data
group: www-data group: www-data
when: not _nextcloud_config_file.stat.isreg is defined when: not _nextcloud_config_file.stat.isreg is defined
@@ -23,8 +29,9 @@
--database-name "{{ nextcloud_database_name }}" --database-name "{{ nextcloud_database_name }}"
--database-user "{{ nextcloud_database_user }}" --database-user "{{ nextcloud_database_user }}"
--database-pass "{{ nextcloud_database_pass }}" --database-pass "{{ nextcloud_database_pass }}"
--data-dir "{{ nextcloud_data_directory }}"
args: args:
chdir: /var/www/nextcloud
chdir: "{{nextcloud_directory}}"
become: true become: true
become_user: www-data become_user: www-data
become_method: sudo become_method: sudo


+ 1
- 1
tasks/main.yml View File

@@ -24,7 +24,7 @@


- import_tasks: apps.yml - import_tasks: apps.yml


- import_tasks: check.yaml
#- import_tasks: check.yaml


- import_tasks: upgrade.yml - import_tasks: upgrade.yml




+ 6
- 1
tasks/reset.yml View File

@@ -1,8 +1,13 @@
--- ---


- name: stop apache2
service:
name: apache2
state: stopped

- name: delete nextcloud directory - name: delete nextcloud directory
file: file:
path: /var/www/nextcloud
path: "{{nextcloud_directory}}"
state: absent state: absent


- name: drop mysql database - name: drop mysql database


+ 1
- 1
tasks/upgrade.yml View File

@@ -3,7 +3,7 @@
- name: upgrade nextcloud - name: upgrade nextcloud
command: php occ upgrade command: php occ upgrade
args: args:
chdir: /var/www/nextcloud
chdir: "{{nextcloud_directory}}"
become: true become: true
become_user: www-data become_user: www-data
become_method: sudo become_method: sudo

+ 4
- 4
templates/apache-vhost.conf.j2 View File

@@ -17,9 +17,9 @@
Include /etc/letsencrypt/options-ssl-apache.conf Include /etc/letsencrypt/options-ssl-apache.conf
{% endif %} {% endif %}


DocumentRoot /var/www/nextcloud
DocumentRoot {{nextcloud_directory}}


<Directory /var/www/nextcloud/>
<Directory {{nextcloud_directory}}/>


Options +FollowSymlinks Options +FollowSymlinks
AllowOverride All AllowOverride All
@@ -28,8 +28,8 @@
Dav off Dav off
</IfModule> </IfModule>


SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
SetEnv HOME {{nextcloud_directory}}
SetEnv HTTP_HOME {{nextcloud_directory}}


</Directory> </Directory>




+ 1
- 1
templates/config.php.j2 View File

@@ -8,7 +8,7 @@ $CONFIG = array(
'appcodechecker' => true, 'appcodechecker' => true,
'updatechecker' => true, 'updatechecker' => true,
'log_type' => 'file', 'log_type' => 'file',
'logfile' => '/var/log/nextcloud/nextcloud.log',
'logfile' => '{{nextcloud_log_directory}}/nextcloud.log',
'loglevel' => 2, 'loglevel' => 2,
'logtimezone' => 'UTC', 'logtimezone' => 'UTC',
'appstoreenabled' => true, 'appstoreenabled' => true,


+ 1
- 1
templates/nextcloud-cron.service View File

@@ -4,7 +4,7 @@ Description=nextcloud cron job
[Service] [Service]
User=www-data User=www-data
Group=www-data Group=www-data
ExecStart=/usr/bin/php -f /var/www/nextcloud/cron.php
ExecStart=/usr/bin/php -f {{nextcloud_directory}}/cron.php


[Install] [Install]
WantedBy=basic.target WantedBy=basic.target

Loading…
Cancel
Save