123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- ---
- # tasks file for nextcloud
- - name: Main... Set Nextcloud db_port to ProxySQL port instead of default MySQL
- set_fact:
- db_port: "6033"
- when: "'db_lbal_servers' in groups.keys()"
- - name: Main... Ovewrite Nextcloud db_host if no SQL_loadBalancer
- set_fact:
- db_host: "{{ groups['db_servers'][0] }}"
- when: "'db_lbal_servers' not in groups.keys()"
- #- name: Main... Set Nextcloud redis_host variable
- # set_fact:
- # redis_host: "{{ groups['redis_servers'][0] }}"
- # when: "'redis_servers' in groups.keys()"
- #- name: Main... Check if Nexctloud's gonna deployed on multiple web servers
- #debug: var=nc_multiple
- #"{{ groups['all'] | length }}"
- - name: Main... Show Selinux variable
- debug: var=ansible_selinux
- - include_tasks: "prep_os/{{ ansible_os_family }}.yml"
- - name: Main... Create shared directories (web & data)
- file:
- path: "{{ item }}"
- state: directory
- owner: "{{ nextcloud_websrv_user }}"
- group: "{{ nextcloud_websrv_group }}"
- mode: 0750
- with_items:
- - "{{ nc_data_dir }}"
- - "{{ http_webroot }}"
- ignore_errors: yes
- - name: Main... Mount shared directories
- include_tasks: "nc_storage.yml"
- #when: nc_multiple != ""
- when: (groups['web_servers'] | length) > 1
- #- name: Main... Check web directory
- # stat:
- # path: "{{ http_webroot }}"
- # register: is_http_webroot
- #- name: Main... Check Selinux
- # include_tasks: "prep_os/selinux.yml"
- # when:
- # - (ansible_os_family == "RedHat")
- # - (ansible_selinux.status == "enabled")
- - name: Main... Check if Nextcloud is already in the web repo
- stat:
- path: "{{ http_webroot }}/nextcloud/index.php"
- register: nc_nextcloud_downloaded
- delegate_to: "{{ groups['web_servers'][0] }}"
- run_once: true
- #- name: Main... Check is Set Nextcloud redis_host variable
- # set_fact:
- # nc_multiple: true
- # when: redis_host != ""
- #
- #- name: Main... is multiple nextcloud web servers ?
- # debug: var=nc_multiple
- - name: Main... Download and Install Nextcloud
- include_tasks: "nc_download.yml"
- args:
- apply:
- delegate_to: "{{ groups['web_servers'][0] }}"
- run_once: true
- when: (nc_nextcloud_downloaded.stat.isreg is undefined) or (not nc_nextcloud_downloaded.stat.isreg)
- - name: Main... Start {{ http_service_name }} service
- service:
- name: "{{ http_service_name }}"
- state: started
- - name: Main... Check Nextcloud status
- become_user: "{{ nextcloud_websrv_user }}"
- become: true
- shell: "{{ php_bin }} occ status --output=json"
- args:
- chdir: "{{ http_webroot }}/nextcloud"
- register: jsoncontent
- delegate_to: "{{ groups['web_servers'][0] }}"
- run_once: true
- - name: Main... Set Nextcloud variables status
- set_fact:
- nc_status: "{{ jsoncontent.stdout | from_json }}"
- delegate_to: "{{ groups['web_servers'][0] }}"
- run_once: true
- - name: Main... Check the nc_status content
- debug: var=nc_status
- delegate_to: "{{ groups['web_servers'][0] }}"
- run_once: true
- - name: Main... Install and deploy Nextcloud if needed
- include_tasks: nc_install.yml
- args:
- apply:
- delegate_to: "{{ groups['web_servers'][0] }}"
- run_once: true
- when: nc_status.installed|bool == false
- - name: Main... Setup nextcloud
- include_tasks: nc_setup.yml
- args:
- apply:
- delegate_to: "{{ groups['web_servers'][0] }}"
- run_once: true
- #when: nc_status.installed|bool == false
- - name: Main... Set Trusted Local Domain lists
- set_fact:
- list_zero:
- - "{{ nc_global_name | default() }}"
- list_one: "{{ groups['lbal_servers'] | default([]) }}"
- list_two: "{{ groups['web_servers'] }}"
- - name: Main... Merge the Trusted lists
- set_fact:
- trusted_dom: "{{ list_zero + list_one + list_two }}"
- - name: Main... Set a local redirect name
- set_fact:
- redirect_name: "{{ groups['web_servers'][0] }}"
- - name: Main... Set a global redirect name if loadbalancing
- set_fact:
- redirect_name: "{{ nc_global_name | default(nc.test) }}"
- when: groups['lbal_servers'] is defined and (groups['lbal_servers']|length>0)
- - name: Main... Set Trusted Local Domain
- become_user: "{{ nextcloud_websrv_user }}"
- become: true
- shell: "{{ php_bin }} occ config:system:set trusted_domains {{ occ_idx }} --value={{ item }}"
- args:
- chdir: "{{ http_webroot }}/nextcloud"
- loop: "{{ trusted_dom }}"
- loop_control:
- index_var: occ_idx
- pause: 2
- delegate_to: "{{ groups['web_servers'][0] }}"
- run_once: true
- - name: Main... Set Nextcloud overwrite url and host
- become_user: "{{ nextcloud_websrv_user }}"
- become: true
- shell: "{{ php_bin }} occ config:system:set {{ item.name }} --value={{ item.value }}"
- args:
- chdir: "{{ http_webroot }}/nextcloud"
- with_items:
- - { name: 'overwritehost', value: '{{ redirect_name }}' }
- - { name: 'overwrite.cli.url', value: 'https://{{ redirect_name }}' }
- delegate_to: "{{ groups['web_servers'][0] }}"
- run_once: true
- - name: Setup... Configure Cron
- cron:
- name: "Nextcloud Cronjob"
- minute: "*/{{ nc_cron_period }}"
- user: "{{ nextcloud_websrv_user }}"
- job: "{{ php_bin }} -f {{ http_webroot }}/nextcloud/cron.php"
- cron_file: "nextcloud"
- when: (nc_background_cron | bool)
- delegate_to: "{{ groups['web_servers'][0] }}"
- run_once: true
- - name: Main... Check Selinux
- include_tasks: "prep_os/selinux.yml"
- when:
- - (ansible_os_family == "RedHat")
- - (ansible_selinux.status == "enabled")
- - name: Main... Restart {{ http_service_name }} service
- service:
- name: "{{ http_service_name }}"
- state: restarted
- - name: Main... First run Cron
- become_user: "{{ nextcloud_websrv_user }}"
- become: true
- shell: "{{ php_bin }} -f cron.php"
- args:
- chdir: "{{ http_webroot }}/nextcloud"
- delegate_to: "{{ groups['web_servers'][0] }}"
- run_once: true
|