diff --git a/defaults/main.yml b/defaults/main.yml index eff240a..8e40c63 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -10,6 +10,7 @@ nextcloud_DB_type: postgres # mysql or postgres nextcloud_admin_user: admin nextcloud_admin_password: nextcloud_datadirectory: /var/nextcloud +nextcloud_data_directory_creation: true nextcloud_web_root: /usr/share/webapps/nextcloud nextcloud_trusted_domains: - localhost @@ -18,11 +19,15 @@ nextcloud_trusted_domains: nextcloud_config_options: # additional options to set in config.php - option: overwrite.cli.url - value: https://nextcloud.example.com + value: "'https://nextcloud.example.com'" - option: maintenance - value: false + value: "false" - option: loglevel - value: 2 + value: "'2'" + - option: installed + value: "true" + - option: config_is_read_only + value: "false" nextcloud_fail2ban_jail_maxretry: 10 nextcloud_fail2ban_jail_findtime: 3600 diff --git a/tasks/main.yml b/tasks/main.yml index 0b6002b..ada5ef5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -39,14 +39,14 @@ group: http # not required. Name of the group that should own the file/directory, as would be fed to I(chown). state: directory # not required. choices: absent;directory;file;hard;link;touch. If C(directory), all intermediate subdirectories will be created if they do not exist. Since Ansible 1.7 they will be created with the supplied permissions. If C(file), the file will NOT be created if it does not exist; see the C(touch) value or the M(copy) or M(template) module if you want that behavior. If C(link), the symbolic link will be created or changed. Use C(hard) for hardlinks. If C(absent), directories will be recursively deleted, and files or symlinks will be unlinked. Note that C(absent) will not cause C(file) to fail if the C(path) does not exist as the state did not change. If C(touch) (new in 1.4), an empty file will be created if the C(path) does not exist, while an existing file or directory will receive updated file access and modification times (similar to the way `touch` works from the command line). owner: http # not required. Name of the user that should own the file/directory, as would be fed to I(chown). + when: nextcloud_data_directory_creation == true - name: création du fichier .ocdata in data become: true + become_user: http file: path: "{{ nextcloud_datadirectory }}/.ocdata" - group: http # not required. Name of the group that should own the file/directory, as would be fed to I(chown). state: touch # not required. choices: absent;directory;file;hard;link;touch. If C(directory), all intermediate subdirectories will be created if they do not exist. Since Ansible 1.7 they will be created with the supplied permissions. If C(file), the file will NOT be created if it does not exist; see the C(touch) value or the M(copy) or M(template) module if you want that behavior. If C(link), the symbolic link will be created or changed. Use C(hard) for hardlinks. If C(absent), directories will be recursively deleted, and files or symlinks will be unlinked. Note that C(absent) will not cause C(file) to fail if the C(path) does not exist as the state did not change. If C(touch) (new in 1.4), an empty file will be created if the C(path) does not exist, while an existing file or directory will receive updated file access and modification times (similar to the way `touch` works from the command line). - owner: http # not required. Name of the user that should own the file/directory, as would be fed to I(chown). @@ -93,6 +93,16 @@ with_indexed_items: - '{{ nextcloud_trusted_domains }}' +- name: ensure correct data folder is set + become: true + lineinfile: + path: '{{ nextcloud_web_root }}/config/config.php' + regexp: '^\s*''datadirectory''' + line: ' ''datadirectory'' => ''{{ nextcloud_datadirectory }}'',' + insertafter: '\$CONFIG' + when: nextcloud_datadirectory is defined + + - name: ensure correct database parameter in config.php become: true lineinfile: @@ -101,7 +111,7 @@ line: ' ''{{ item.option }}'' => ''{{ item.value }}'',' insertafter: '\$CONFIG' with_items: '{{ nextcloud_db_options }}' - when: nextcloud_config_options is defined + when: nextcloud_db_options is defined