mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
nextcloud add iiab_installed and tweeks
This commit is contained in:
parent
2180a6655f
commit
5e7fdfe87b
4 changed files with 128 additions and 136 deletions
|
|
@ -1,18 +1,8 @@
|
||||||
# This should go in computed_network.yml, but here for now
|
# This should go in computed_network.yml, but here for now
|
||||||
# 2019-09-04: THE NEXT 4 LINES ARE UNUSED (due to changes in roles/nextcloud/templates/nextcloud.conf.j2)
|
#- name: Compute Nextcloud listen ip addr for nextcloud.conf
|
||||||
- name: Compute Nextcloud listen ip addr for nextcloud.conf
|
# set_fact:
|
||||||
set_fact:
|
# nextcloud_required_ip: "{{ ansible_default_ipv4.network }}/{{ ansible_default_ipv4.netmask }}"
|
||||||
nextcloud_required_ip: "{{ ansible_default_ipv4.network }}/{{ ansible_default_ipv4.netmask }}"
|
# when: ansible_default_ipv4.network is defined
|
||||||
when: ansible_default_ipv4.network is defined
|
|
||||||
|
|
||||||
- name: Install Apache's nextcloud.conf from template, for http://box/nextcloud
|
|
||||||
template:
|
|
||||||
src: nextcloud.conf.j2
|
|
||||||
dest: "/etc/{{ apache_config_dir }}/nextcloud.conf"
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
when: nextcloud_enabled | bool
|
|
||||||
|
|
||||||
- name: Create symlink nextcloud.conf from sites-enabled to sites-available for http://box/nextcloud (debuntu)
|
- name: Create symlink nextcloud.conf from sites-enabled to sites-available for http://box/nextcloud (debuntu)
|
||||||
file:
|
file:
|
||||||
|
|
@ -34,75 +24,29 @@
|
||||||
when: not nextcloud_enabled and is_redhat
|
when: not nextcloud_enabled and is_redhat
|
||||||
|
|
||||||
- name: Restart Apache, enabling/disabling http://box/nextcloud
|
- name: Restart Apache, enabling/disabling http://box/nextcloud
|
||||||
service:
|
systemd:
|
||||||
name: "{{ apache_service }}"
|
name: "{{ apache_service }}"
|
||||||
|
daemon-reload: yes
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
# the install wizard does not succeed if already installed
|
- name: Add 'nextcloud' variable values to {{ iiab_ini_file }}
|
||||||
- name: Determine if Nextcloud is installed
|
ini_file:
|
||||||
shell: >
|
path: "{{ iiab_ini_file }}"
|
||||||
php {{ nextcloud_prefix }}/nextcloud/occ status |
|
section: Nextcloud
|
||||||
gawk '/installed:/ { print $3 }'
|
option: "{{ item.option }}"
|
||||||
become: yes
|
value: "{{ item.value }}"
|
||||||
become_user: "{{ apache_user }}"
|
with_items:
|
||||||
register: returned
|
- option: name
|
||||||
|
value: Nextcloud
|
||||||
- name: Run Nextcloud initial install wizard
|
- option: description
|
||||||
shell: >
|
value: '"NextCloud is a local server-based facility for sharing files, photos, contacts, calendars, etc."'
|
||||||
cd {{ nextcloud_prefix }}/nextcloud;
|
- option: path
|
||||||
php occ maintenance:install
|
value: "{{ nextcloud_prefix }}/nextcloud"
|
||||||
--database "mysql"
|
#- option: nextcloud_force_install
|
||||||
--database-name "{{ nextcloud_dbname }}"
|
# value: "{{ nextcloud_force_install }}"
|
||||||
--database-user "{{ nextcloud_dbuser }}"
|
- option: nextcloud_orig_src_file
|
||||||
--database-pass "{{ nextcloud_dbpassword }}"
|
value: "{{ nextcloud_orig_src_file }}"
|
||||||
--admin-user "{{ nextcloud_admin_user }}"
|
- option: nextcloud_src_file
|
||||||
--admin-pass "{{ nextcloud_admin_password }}"
|
value: "{{ nextcloud_src_file }}"
|
||||||
become: yes
|
- option: nextcloud_enabled
|
||||||
become_user: "{{ apache_user }}"
|
value: "{{ nextcloud_enabled }}"
|
||||||
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: yes
|
|
||||||
become_user: "{{ apache_user }}"
|
|
||||||
when: nextcloud_enabled and returned.stdout == "false"
|
|
||||||
|
|
||||||
# Code below was NEVER RUNNING as of 2018-10-29, as "wc | cut -d' ' -f1" ALWAYS
|
|
||||||
# returns null (rather than the intended returned_count !) This line could
|
|
||||||
# be replaced by ALTERNATIVE 1 or ALTERNATIVE 2 below IF it truly needs fixing.
|
|
||||||
#
|
|
||||||
# Or perhaps default user/password nextcloud/nextcloudmysql (from variables
|
|
||||||
# nextcloud_user/nextcloud_user_password) is just not needed in the end...
|
|
||||||
#
|
|
||||||
# NOTE: COMMENTS (FOLLOWING '#' SIGN) WITHIN A SHELL COMMAND CAUSE IT TO *FAIL*
|
|
||||||
#
|
|
||||||
#- name: Determine if Nextcloud user exists already
|
|
||||||
# shell: >
|
|
||||||
# php {{ nextcloud_prefix }}/nextcloud/occ user:list |
|
|
||||||
# grep {{ nextcloud_user }} | wc | cut -d' ' -f1 # USELESS
|
|
||||||
# #grep {{ nextcloud_user }} | wc -l # ALTERNATIVE 1
|
|
||||||
# #grep {{ nextcloud_user }} | wc | awk '{print $1}' # ALTERNATIVE 2
|
|
||||||
# become: yes
|
|
||||||
# become_user: "{{ apache_user }}"
|
|
||||||
# register: returned_count
|
|
||||||
#
|
|
||||||
# debug:
|
|
||||||
# var: returned_count
|
|
||||||
#
|
|
||||||
## nextcloud wants to make users rather than just mysql users and not done
|
|
||||||
#- name: Create the default user
|
|
||||||
# shell: >
|
|
||||||
# OC_PASS={{ nextcloud_user_password }};
|
|
||||||
# php {{ nextcloud_prefix }}/nextcloud/occ user:add
|
|
||||||
# --password-from-env --display-name={{ nextcloud_user }}
|
|
||||||
# --group="users" {{ nextcloud_user }}
|
|
||||||
# become: yes
|
|
||||||
# become_user: "{{ apache_user }}"
|
|
||||||
# when: nextcloud_enabled and returned_count == "0"
|
|
||||||
|
|
||||||
# 2019-09-04: NEXT 5 LINES APPEAR INEFFECTIVE DURING 1ST INSTALL? (possibly "overwrite.cli.url" appears later, when Nextcloud's web install completes using http://box/nextcloud ?)
|
|
||||||
- name: Try to remove overwrite.cli.url line (Rewrite URL) from /opt/nextcloud/config/config.php
|
|
||||||
lineinfile:
|
|
||||||
regexp: "overwrite.cli.url"
|
|
||||||
state: absent
|
|
||||||
path: "{{ nextcloud_prefix }}/nextcloud/config/config.php"
|
|
||||||
|
|
|
||||||
|
|
@ -174,53 +174,15 @@
|
||||||
mode: 0750
|
mode: 0750
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: 'Create MySQL database with name: {{ nextcloud_dbname }}'
|
- name: Install Apache's nextcloud.conf from template, for http://box/nextcloud
|
||||||
mysql_db:
|
template:
|
||||||
name: "{{ nextcloud_dbname }}"
|
src: nextcloud.conf.j2
|
||||||
when: mysql_enabled and nextcloud_enabled
|
dest: "/etc/{{ apache_config_dir }}/nextcloud.conf"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
- name: Add username/password to the MySQL database (associated with trusted IP's like localhost)
|
- name: Add 'nextcloud_installed' variable values to {{ iiab_installed }}
|
||||||
mysql_user:
|
|
||||||
name: "{{ nextcloud_dbuser }}"
|
|
||||||
host: "{{ item }}"
|
|
||||||
password: "{{ nextcloud_dbpassword }}"
|
|
||||||
priv: "{{ nextcloud_dbname }}.*:ALL,GRANT"
|
|
||||||
with_items:
|
|
||||||
- "{{ nextcloud_dbhost }}"
|
|
||||||
- 127.0.0.1
|
|
||||||
- ::1
|
|
||||||
- localhost
|
|
||||||
when: mysql_enabled and nextcloud_enabled
|
|
||||||
|
|
||||||
# Appears unnec as nextcloud_enabled.yml (just below) does the same
|
|
||||||
#- name: Restart Apache
|
|
||||||
# service:
|
|
||||||
# name: "{{ apache_service }}"
|
|
||||||
# state: restarted
|
|
||||||
## when: nextcloud_enabled | bool # taken care of by nextcloud_enabled.yml below
|
|
||||||
# when: not nextcloud_enabled
|
|
||||||
|
|
||||||
# Enables or disable Nextcloud!
|
|
||||||
- include_tasks: enable_or_disable.yml
|
|
||||||
|
|
||||||
- name: Add 'nextcloud' variable values to {{ iiab_ini_file }}
|
|
||||||
ini_file:
|
ini_file:
|
||||||
path: "{{ iiab_ini_file }}"
|
path: "{{ iiab_installed }}"
|
||||||
section: Nextcloud
|
value: nextcloud_installed
|
||||||
option: "{{ item.option }}"
|
|
||||||
value: "{{ item.value }}"
|
|
||||||
with_items:
|
|
||||||
- option: name
|
|
||||||
value: Nextcloud
|
|
||||||
- option: description
|
|
||||||
value: '"NextCloud is a local server-based facility for sharing files, photos, contacts, calendars, etc."'
|
|
||||||
- option: path
|
|
||||||
value: "{{ nextcloud_prefix }}/nextcloud"
|
|
||||||
#- option: nextcloud_force_install
|
|
||||||
# value: "{{ nextcloud_force_install }}"
|
|
||||||
- option: nextcloud_orig_src_file
|
|
||||||
value: "{{ nextcloud_orig_src_file }}"
|
|
||||||
- option: nextcloud_src_file
|
|
||||||
value: "{{ nextcloud_src_file }}"
|
|
||||||
- option: nextcloud_enabled
|
|
||||||
value: "{{ nextcloud_enabled }}"
|
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,12 @@
|
||||||
#set_fact:
|
#set_fact:
|
||||||
# nextcloud_force_install: True
|
# nextcloud_force_install: True
|
||||||
include_tasks: install.yml
|
include_tasks: install.yml
|
||||||
when: nextcloud_install and not nextcloud_page.stat.exists
|
when: nextcloud_install and (not nextcloud_installed is defined or not nextcloud_page.stat.exists)
|
||||||
|
|
||||||
# - debug:
|
- name: Provision NextCloud's Mysql DB
|
||||||
# var: nextcloud_force_install
|
include_tasks: prov-db.yml
|
||||||
|
when: nextcloud_install and not installing
|
||||||
|
|
||||||
# - debug:
|
- name: Enables or disable Nextcloud!
|
||||||
# msg: "nextcloud_force_install: {{ nextcloud_force_install }}"
|
include_tasks: enable_or_disable.yml
|
||||||
|
when: nextcloud_install or nextcloud_installed is defined
|
||||||
|
|
|
||||||
84
roles/nextcloud/tasks/prov-db.yml
Normal file
84
roles/nextcloud/tasks/prov-db.yml
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
- name: 'Create MySQL database with name: {{ nextcloud_dbname }}'
|
||||||
|
mysql_db:
|
||||||
|
name: "{{ nextcloud_dbname }}"
|
||||||
|
|
||||||
|
- name: Add username/password to the MySQL database (associated with trusted IP's like localhost)
|
||||||
|
mysql_user:
|
||||||
|
name: "{{ nextcloud_dbuser }}"
|
||||||
|
host: "{{ item }}"
|
||||||
|
password: "{{ nextcloud_dbpassword }}"
|
||||||
|
priv: "{{ nextcloud_dbname }}.*:ALL,GRANT"
|
||||||
|
with_items:
|
||||||
|
- "{{ nextcloud_dbhost }}"
|
||||||
|
- 127.0.0.1
|
||||||
|
- ::1
|
||||||
|
- localhost
|
||||||
|
|
||||||
|
# the install wizard does not succeed if already installed
|
||||||
|
- name: Determine if Nextcloud is installed
|
||||||
|
shell: >
|
||||||
|
php {{ nextcloud_prefix }}/nextcloud/occ status |
|
||||||
|
gawk '/installed:/ { print $3 }'
|
||||||
|
become: yes
|
||||||
|
become_user: "{{ apache_user }}"
|
||||||
|
register: returned
|
||||||
|
|
||||||
|
- name: Run Nextcloud initial install wizard
|
||||||
|
shell: >
|
||||||
|
cd {{ nextcloud_prefix }}/nextcloud;
|
||||||
|
php occ maintenance:install
|
||||||
|
--database "mysql"
|
||||||
|
--database-name "{{ nextcloud_dbname }}"
|
||||||
|
--database-user "{{ nextcloud_dbuser }}"
|
||||||
|
--database-pass "{{ nextcloud_dbpassword }}"
|
||||||
|
--admin-user "{{ nextcloud_admin_user }}"
|
||||||
|
--admin-pass "{{ nextcloud_admin_password }}"
|
||||||
|
become: yes
|
||||||
|
become_user: "{{ apache_user }}"
|
||||||
|
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: yes
|
||||||
|
become_user: "{{ apache_user }}"
|
||||||
|
when: nextcloud_enabled and returned.stdout == "false"
|
||||||
|
|
||||||
|
# Code below was NEVER RUNNING as of 2018-10-29, as "wc | cut -d' ' -f1" ALWAYS
|
||||||
|
# returns null (rather than the intended returned_count !) This line could
|
||||||
|
# be replaced by ALTERNATIVE 1 or ALTERNATIVE 2 below IF it truly needs fixing.
|
||||||
|
#
|
||||||
|
# Or perhaps default user/password nextcloud/nextcloudmysql (from variables
|
||||||
|
# nextcloud_user/nextcloud_user_password) is just not needed in the end...
|
||||||
|
#
|
||||||
|
# NOTE: COMMENTS (FOLLOWING '#' SIGN) WITHIN A SHELL COMMAND CAUSE IT TO *FAIL*
|
||||||
|
#
|
||||||
|
#- name: Determine if Nextcloud user exists already
|
||||||
|
# shell: >
|
||||||
|
# php {{ nextcloud_prefix }}/nextcloud/occ user:list |
|
||||||
|
# grep {{ nextcloud_user }} | wc | cut -d' ' -f1 # USELESS
|
||||||
|
# #grep {{ nextcloud_user }} | wc -l # ALTERNATIVE 1
|
||||||
|
# #grep {{ nextcloud_user }} | wc | awk '{print $1}' # ALTERNATIVE 2
|
||||||
|
# become: yes
|
||||||
|
# become_user: "{{ apache_user }}"
|
||||||
|
# register: returned_count
|
||||||
|
#
|
||||||
|
# debug:
|
||||||
|
# var: returned_count
|
||||||
|
#
|
||||||
|
## nextcloud wants to make users rather than just mysql users and not done
|
||||||
|
#- name: Create the default user
|
||||||
|
# shell: >
|
||||||
|
# OC_PASS={{ nextcloud_user_password }};
|
||||||
|
# php {{ nextcloud_prefix }}/nextcloud/occ user:add
|
||||||
|
# --password-from-env --display-name={{ nextcloud_user }}
|
||||||
|
# --group="users" {{ nextcloud_user }}
|
||||||
|
# become: yes
|
||||||
|
# become_user: "{{ apache_user }}"
|
||||||
|
# when: nextcloud_enabled and returned_count == "0"
|
||||||
|
|
||||||
|
# 2019-09-04: NEXT 5 LINES APPEAR INEFFECTIVE DURING 1ST INSTALL? (possibly "overwrite.cli.url" appears later, when Nextcloud's web install completes using http://box/nextcloud ?)
|
||||||
|
- name: Try to remove overwrite.cli.url line (Rewrite URL) from /opt/nextcloud/config/config.php
|
||||||
|
lineinfile:
|
||||||
|
regexp: "overwrite.cli.url"
|
||||||
|
state: absent
|
||||||
|
path: "{{ nextcloud_prefix }}/nextcloud/config/config.php"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue