--- - name: Add PHP repository get_url: url: https://packages.sury.org/php/README.txt dest: /usr/local/src/nextcloud-playbooks/php_latest.sh - name: Update repository shell: bash /usr/local/src/nextcloud-playbooks/php_latest.sh - name: Install dependency packages apt: name: "{{ nc_dependency_packages }}" state: present register: installed - debug: var: installed - name: Download Nextcloud get_url: url: https://download.nextcloud.com/server/releases/latest.zip dest: /var/www/ - name: Create data directory file: path: "{{ nc_data_dir }}" state: directory owner: www-data group: www-data - name: Create LDAP suffix from domain name shell: echo "{{ domainname }}" | sed -e 's/^/dc=/' -e 's/\./,dc=/g' args: executable: /bin/bash register: ldap_suffix - name: Extract nextcloud zip file unarchive: src: "/var/www/latest.zip" dest: /var/www/ owner: www-data group: www-data - name: Copy occ to /usr/local/bin template: src: occ.j2 dest: /usr/local/bin/occ mode: u+x,g+x,o+x - name: Installistaion using occ shell: | occ maintenance:install --no-interaction --database "{{ nc_db }}" \ --database-host "{{ nc_db_host }}" --database-name "{{ nc_db_name}}" \ --database-user "{{ nc_db_user }}" --database-pass "{{ nc_db_pass}}" \ --admin-user "{{ nc_admin_username }}" --admin-pass "{{ nc_admin_pass }}" register: occ_install - debug: var: occ_install - name: Adding trusted domains to config.php shell: occ config:system:set trusted_domains --value {{ item.value }} {{ item.key }} with_dict: - "{{ nc_trusted_domains }}" register: occ_trusted_domains - debug: msg: "{{ occ_trusted_domains.results | json_query('[*].{ Command: cmd, Result: stdout }') }}" - name: Set data directory shell: occ config:system:set datadirectory --value="/opt/nextcloud-data" with_dict: - "{{ nc_data_directory }}" register: occ_trusted_domains - debug: msg: "{{ occ_data_directory.results | json_query('[*].{ Command: cmd, Result: stdout }') }}" - name: Installing apps shell: occ app:install "{{ item }}" with_items: - "{{ nc_app_list }}" register: occ_app_install - debug: var: occ_app_install.stdout - name: Enable ldap shell: occ app:enable user_ldap - name: Create empty ldap config shell: occ ldap:create-empty-config - name: Ldap configuration shell: occ ldap:set-config s01 "{{item.key}} {{item.value}}" with_dict: "{{ ldap }}" - name: Provision email accounts for PostgreSQL community.postgresql.postgresql_query: db: "{{ nc_db_name }}" login_host: "{{ nc_db_host}}" login_user: "{{ nc_db_user }}" login_password: "{{ nc_db_pass }}" query: INSERT into oc_mail_provisionings (provisioning_domain,email_template,imap_user,imap_host,imap_port,imap_ssl_mode,smtp_user,smtp_host,smtp_port,smtp_ssl_mode) VALUES ('*', '%EMAIL%', '%EMAIL%' , '{{ domainname }}', 993, 'ssl','%USERID%','{{ domainname }}',587,'tls') when: "{{ nc_db == 'pgsql' }}" - name: Provision email accounts for MySQL community.mysql.mysql_query: login_db: "{{ nc_db_name }}" login_user: "{{ nc_db_user }}" login_password: "{{ nc_db_pass }}" login_unix_socket: /var/run/mysqld/mysqld.sock query: INSERT into oc_mail_provisionings (provisioning_domain,email_template,imap_user,imap_host,imap_port,imap_ssl_mode,smtp_user,smtp_host,smtp_port,smtp_ssl_mode) VALUES ('*', '%EMAIL%', '%EMAIL%' , '{{ domainname }}', 993, 'ssl','%USERID%','{{ domainname }}',587,'tls') when: "{{ nc_db == 'mysql' }}" - name: Configure Redis host shell: occ config:system:set redis "hostname" --value "{{ redis_host }}" - name: Configure Redis Port shell: occ config:system:set redis "port" --value "{{ redis_port }}" - name: Configure memory caching with Redis shell: occ config:system:set memcache."{{ item }}" --value "\\OC\\Memcache\\Redis" with_items: - local - distributed - locking - name: Install nginx config template: src: nexcloud.j2 dest: /etc/nginx/sites-enabled/nextcloud