nc_apps.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ---
  2. - name: parse the item values
  3. ansible.builtin.set_fact:
  4. nc_app_name: "{{ item.key }}"
  5. nc_app_cfg: "{{ item.value }}"
  6. - name: "Install and enable Nextcloud Apps"
  7. block:
  8. - name: "[ App {{ nc_app_name }} ] - Download Archive in apps folder."
  9. ansible.builtin.unarchive:
  10. copy: false
  11. src: "{{ nc_app_cfg }}"
  12. dest: "{{ nextcloud_webroot }}/apps/"
  13. owner: "{{ nextcloud_websrv_user }}"
  14. group: "{{ nextcloud_websrv_group }}"
  15. creates: "{{ nextcloud_webroot }}/apps/{{ nc_app_name }}"
  16. when: nc_app_cfg is not none
  17. - name: "[ App {{ nc_app_name }} ] - enable the application."
  18. become_user: "{{ nextcloud_websrv_user }}"
  19. become_flags: "{{ ansible_become_flags | default(omit) }}"
  20. become: true
  21. ansible.builtin.command: php occ app:enable "{{ nc_app_name }}"
  22. args:
  23. chdir: "{{ nextcloud_webroot }}"
  24. when: nc_app_cfg is not none
  25. when: nc_app_cfg is string
  26. - name: "Install Apps"
  27. block:
  28. - name: verify the app's yaml declaration
  29. ansible.builtin.assert:
  30. that:
  31. - (nc_app_cfg.source is defined) and (nc_app_cfg.source is string)
  32. msg: "{{ nc_app_name }} is not well declared."
  33. - name: "[ App {{ nc_app_name }} ] - Download Archive in apps folder."
  34. ansible.builtin.unarchive:
  35. copy: false
  36. src: "{{ nc_app_cfg.source }}"
  37. dest: "{{ nextcloud_webroot }}/apps/"
  38. owner: "{{ nextcloud_websrv_user }}"
  39. group: "{{ nextcloud_websrv_group }}"
  40. creates: "{{ nextcloud_webroot }}/apps/{{ nc_app_name }}"
  41. when: nc_app_cfg.source is not none
  42. - name: "[ App {{ nc_app_name }} ] - enable the application."
  43. become_user: "{{ nextcloud_websrv_user }}"
  44. become_flags: "{{ ansible_become_flags | default(omit) }}"
  45. become: true
  46. ansible.builtin.command: php occ app:enable "{{ nc_app_name }}"
  47. args:
  48. chdir: "{{ nextcloud_webroot }}"
  49. when: nc_app_cfg.source is not none
  50. - name: "[ App {{ nc_app_name }} ] - Configure the application "
  51. become_user: "{{ nextcloud_websrv_user }}"
  52. become_flags: "{{ ansible_become_flags | default(omit) }}"
  53. become: true
  54. ansible.builtin.command: php occ config:app:set {{ nc_app_name }} {{ item_cfg.key }} --value="{{ item_cfg.value }}"
  55. args:
  56. chdir: "{{ nextcloud_webroot }}"
  57. with_dict: "{{ nc_app_cfg.conf | default({}) }}"
  58. loop_control:
  59. loop_var: item_cfg
  60. when: nc_app_cfg.conf is defined
  61. when: (nc_app_cfg is mapping)