main.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. ---
  2. # tasks file for nextcloud
  3. - include_tasks: "prep_os/{{ ansible_os_family }}.yml"
  4. - include_tasks: "prep_php/{{ ansible_os_family }}.yml"
  5. - name: Main... Create shared directories
  6. file:
  7. path: "{{ item }}"
  8. state: directory
  9. owner: "{{ nextcloud_websrv_user }}"
  10. group: "{{ nextcloud_websrv_group }}"
  11. mode: 0770
  12. with_items:
  13. - "{{ nc_data_dir }}"
  14. - "{{ http_webroot }}/nextcloud"
  15. when: nc_multiple != ""
  16. - name: Main... Mount shared directories
  17. mount:
  18. src: "{{ nfs_server }}:{{ item.src }}"
  19. path: "{{ item.path }}"
  20. state: mounted
  21. fstype: nfs
  22. opts: nosharecache,context="system_u:object_r:httpd_sys_rw_content_t:s0"
  23. with_items:
  24. - { src: "{{ nfs_data_path }}", path: "{{ nc_data_dir }}" }
  25. - { src: "{{ nfs_web_path }}", path: "{{ http_webroot }}/nextcloud" }
  26. when: nc_multiple != ""
  27. - name: Main... Check if Nextcloud is downloaded
  28. stat:
  29. path: "{{ http_webroot }}/nextcloud/index.php"
  30. register: nc_nextcloud_downloaded
  31. - name: Main... Download and Install Nextcloud
  32. include_tasks: "nc_download.yml"
  33. when: (nc_nextcloud_downloaded.stat.isreg is undefined) or (not nc_nextcloud_downloaded.stat.isreg)
  34. - name: Main... Check Nextcloud status
  35. become_user: "{{ nextcloud_websrv_user }}"
  36. become: true
  37. shell: "{{ php_bin }} occ status --output=json"
  38. args:
  39. chdir: "{{ http_webroot }}/nextcloud"
  40. register: jsoncontent
  41. - name: Main... Set Nextcloud variables status
  42. set_fact:
  43. nc_status: "{{ jsoncontent.stdout | from_json }}"
  44. - name: Main... The nc_status content
  45. debug: var=nc_status
  46. - name: Main... Install nextcloud
  47. include_tasks: nc_install.yml
  48. when: nc_status.installed|bool == false
  49. - name: Main... Check Selinux
  50. include_tasks: "selinux.yml"
  51. when:
  52. - (ansible_os_family == "RedHat")
  53. - (ansible_selinux.status == "enabled")
  54. - name: Main... Setup nextcloud
  55. include_tasks: nc_setup.yml
  56. when: nc_status.installed|bool == false
  57. #- name: Setup... Set Trusted Local Domain
  58. # become_user: "{{ nextcloud_websrv_user }}"
  59. # become: true
  60. # shell: "{{ php_bin }} occ config:system:set trusted_domains 0 --value={{ nc_trusted_domain }}"
  61. # args:
  62. # chdir: "{{ http_webroot }}/nextcloud"
  63. - name: Setup... Configure Cron
  64. cron:
  65. name: "Nextcloud Cronjob"
  66. minute: "*/{{ nc_cron_period }}"
  67. user: "{{ nextcloud_websrv_user }}"
  68. job: "{{ php_bin }} -f {{ http_webroot }}/nextcloud/cron.php"
  69. cron_file: "nextcloud"
  70. when: (nc_background_cron | bool)
  71. #- name: Main... Setting stronger directories ownership
  72. # file:
  73. # path: "{{ item }}"
  74. # state: directory
  75. # owner: "{{ nextcloud_websrv_user }}"
  76. # group: "{{ nextcloud_websrv_group }}"
  77. # mode: 0770
  78. # with_items:
  79. # - "{{ nc_data_dir }}"
  80. # - "{{ http_webroot }}/nextcloud"
  81. - name: Main... Restart {{ http_service_name }} service
  82. service:
  83. name: "{{ http_service_name }}"
  84. state: restarted
  85. - name: Main... First run Cron
  86. become_user: "{{ nextcloud_websrv_user }}"
  87. become: true
  88. shell: "{{ php_bin }} -f cron.php"
  89. args:
  90. chdir: "{{ http_webroot }}/nextcloud"