diff --git a/roles/nextcloud/defaults/main.yml b/roles/nextcloud/defaults/main.yml index 1dc0835bd..19f7f7a87 100644 --- a/roles/nextcloud/defaults/main.yml +++ b/roles/nextcloud/defaults/main.yml @@ -15,7 +15,7 @@ nextcloud_dbpassword: nextcloudmysql nextcloud_user: nextcloud nextcloud_user_password: nextcloudmysql -nextcloud_admin_user: root -nextcloud_admin_password: "{{ mysql_root_password }}" +nextcloud_admin_user: 'Admin' +nextcloud_admin_password: 'changeme' nextcloud_required_ip: 10.0.0.0/8 192.168.0.0/16 diff --git a/roles/nextcloud/tasks/main.yml b/roles/nextcloud/tasks/main.yml index 3c9da2154..2087ad167 100644 --- a/roles/nextcloud/tasks/main.yml +++ b/roles/nextcloud/tasks/main.yml @@ -18,13 +18,13 @@ - name: ubuntu and debian treat names differently package: name={{ item }} state=present - with_items: + with_items: - libapache2-mod-php5 when: is_debian - name: ubuntu and debian treat names differently package: name={{ item }} state=present - with_items: + with_items: - libapache2-mod-php - php-imagick - php-zip @@ -33,7 +33,7 @@ - name: Install list of packages for debuntu package: name={{ item }} state=present - with_items: + with_items: - php{{ php_version }}-gd - php{{ php_version }}-json - php{{ php_version }}-mysql @@ -41,10 +41,10 @@ - php{{ php_version }}-intl - php{{ php_version }}-mcrypt when: is_debuntu - -- name: Install list of packages + +- name: Install list of packages package: name={{ item }} state=present - with_items: + with_items: - php - php-gd - php-json @@ -55,16 +55,16 @@ # centos does not have a package for php-imagick # - php-imagick when: is_redhat - + - name: Copy it to permanent location /opt - unarchive: src={{ downloads_dir }}/{{ nextcloud_src_file }} + unarchive: src={{ downloads_dir }}/{{ nextcloud_src_file }} dest={{ nextcloud_prefix }} creates={{ nextcloud_prefix }}/nextcloud/version.php when: not is_F18 # ansible 1.4.1 does not have "creates" - name: Copy it to permanent location /opt - unarchive: src={{ downloads_dir }}/{{ nextcloud_src_file }} + unarchive: src={{ downloads_dir }}/{{ nextcloud_src_file }} dest={{ nextcloud_prefix }} when: is_F18 diff --git a/roles/nextcloud/tasks/nextcloud_enabled.yml b/roles/nextcloud/tasks/nextcloud_enabled.yml index 0ecaff49d..811f7da90 100644 --- a/roles/nextcloud/tasks/nextcloud_enabled.yml +++ b/roles/nextcloud/tasks/nextcloud_enabled.yml @@ -1,4 +1,4 @@ - # This should go in computed_network.yml, but here for now + # This should go in computed_network.yml, but here for now - name: Compute nextcloud listen ip addr for nextcloud.conf set_fact: nextcloud_required_ip: "{{ ansible_default_ipv4.network }}/{{ ansible_default_ipv4.netmask }}" @@ -29,34 +29,40 @@ # the install wizard does not succeed if already installed - name: Determine if nextcloud is installed shell: > - sudo -u {{ apache_user }} php - '{{ nextcloud_prefix }}/nextcloud/occ' status | + sudo -u {{ apache_user }} php + '{{ nextcloud_prefix }}/nextcloud/occ' status | grep installed: | cut -d' ' -f5 register: returned - name: Run nextcloud initial install wizard shell: > cd {{ nextcloud_prefix }}/nextcloud; - sudo -u {{ apache_user }} php occ maintenance:install + sudo -u {{ apache_user }} php occ maintenance:install --database "mysql" --database-name "{{ nextcloud_dbname }}" - --database-user "{{ nextcloud_dbuser }}" + --database-user "{{ nextcloud_dbuser }}" --database-pass "{{ nextcloud_dbpassword }}" - --admin-user "root" - --admin-pass "{{ mysql_root_password }}" + --admin-user "{{ nextcloud_admin_user }}" + --admin-pass "{{ nextcloud_admin_password }}" + when: nextcloud_enabled and returned.stdout == "false" + +- name: allow access from all hosts and ips + command: php '{{ nextcloud_prefix }}/nextcloud/occ' config:system:set trusted_domains 1 --value=* + become: true + become_user: "{{ apache_user }}" when: nextcloud_enabled and returned.stdout == "false" - name: Determine if nextcloud user exists already shell: > - sudo -u {{ apache_user }} php - '{{ nextcloud_prefix }}/nextcloud/occ' user:list | + sudo -u {{ apache_user }} php + '{{ nextcloud_prefix }}/nextcloud/occ' user:list | grep {{ nextcloud_user }} | wc | cut -d' ' -f1 register: returned_count # nextcloud wants to make users rather than just mysql users and not done - name: create the default user shell: > - su -s /bin/sh {{ apache_user }} -c + su -s /bin/sh {{ apache_user }} -c 'OC_PASS={{ nextcloud_user_password }}; php {{ nextcloud_prefix }}/nextcloud/occ user:add --password-from-env --display-name={{ nextcloud_user }}