--- - name: check for config file stat: path: /var/www/nextcloud/config/config.php register: _nextcloud_config_file - name: nextcloud initial config file template: src: config.php.j2 dest: /var/www/nextcloud/config/config.php owner: www-data group: www-data when: not _nextcloud_config_file.stat.isreg is defined - name: install nextcloud command: php occ maintenance:install --admin-user "{{ nextcloud_admin_user }}" --admin-pass "{{ nextcloud_admin_pass }}" --database "{{ nextcloud_database_type }}" --database-host "{{ nextcloud_database_host }}" --database-name "{{ nextcloud_database_name }}" --database-user "{{ nextcloud_database_user }}" --database-pass "{{ nextcloud_database_pass }}" args: chdir: /var/www/nextcloud become: true become_user: www-data become_method: sudo when: not _nextcloud_config_file.stat.isreg is defined