1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 11:42:08 +00:00
iiab/roles/nextcloud/tasks/nextcloud_enabled.yml

76 lines
2.8 KiB
YAML
Raw Normal View History

# This should go in computed_network.yml, but here for now
2017-05-29 22:02:55 +00:00
- name: Compute nextcloud listen ip addr for nextcloud.conf
set_fact:
nextcloud_required_ip: "{{ ansible_default_ipv4.network }}/{{ ansible_default_ipv4.netmask }}"
when: ansible_default_ipv4.network is defined
- name: Enable nextcloud by copying template to httpd config
template: src=nextcloud.conf.j2
dest=/etc/{{ apache_config_dir }}/nextcloud.conf
owner=root
group=root
mode=0644
2017-05-30 02:37:12 +00:00
when: nextcloud_enabled
2017-05-29 22:02:55 +00:00
- name: Enable nextcloud
file: path=/etc/apache2/sites-enabled/nextcloud.conf
src=/etc/apache2/sites-available/nextcloud.conf
state=link
2017-05-30 02:37:12 +00:00
when: nextcloud_enabled and is_debuntu
2017-05-29 22:02:55 +00:00
2017-05-30 03:04:04 +00:00
- name: For redhat, remove the config file
file: path=/etc/{{ apache_config_dir }}/nextcloud.conf
2017-05-29 22:02:55 +00:00
state=absent
2017-05-30 03:04:04 +00:00
when: not nextcloud_enabled and is_redhat
2017-05-29 22:02:55 +00:00
- name: Restart apache, so it picks up the new aliases
service: name={{ apache_service }} state=restarted
# the install wizard does not succeed if already installed
- name: Determine if nextcloud is installed
2017-06-19 13:56:54 +00:00
shell: >
sudo -u {{ apache_user }} php
'{{ nextcloud_prefix }}/nextcloud/occ' status |
gawk '/installed:/ { print $3 }'
2017-06-20 22:25:07 +00:00
register: returned
2017-05-29 22:02:55 +00:00
- name: Run nextcloud initial install wizard
2017-06-19 01:16:28 +00:00
shell: >
cd {{ nextcloud_prefix }}/nextcloud;
sudo -u {{ apache_user }} php occ maintenance:install
2017-06-19 01:16:28 +00:00
--database "mysql"
--database-name "{{ nextcloud_dbname }}"
--database-user "{{ nextcloud_dbuser }}"
2017-06-19 01:16:28 +00:00
--database-pass "{{ nextcloud_dbpassword }}"
--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 }}"
2017-06-20 22:25:07 +00:00
when: nextcloud_enabled and returned.stdout == "false"
2017-05-29 22:02:55 +00:00
2017-06-19 13:56:54 +00:00
- name: Determine if nextcloud user exists already
shell: >
sudo -u {{ apache_user }} php
'{{ nextcloud_prefix }}/nextcloud/occ' user:list |
2017-06-19 13:56:54 +00:00
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
2017-06-19 13:56:54 +00:00
'OC_PASS={{ nextcloud_user_password }};
php {{ nextcloud_prefix }}/nextcloud/occ user:add
--password-from-env --display-name={{ nextcloud_user }}
--group="users" {{ nextcloud_user }}'
when: nextcloud_enabled and returned_count == "0"
2017-05-29 22:02:55 +00:00
- name: Remove Rewrite URL
lineinfile: regexp='overwrite.cli.url'
state=absent
dest="{{ nextcloud_prefix }}/nextcloud/config/config.php"