setup_env.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ---
  2. # additional setup and fixes for OS dependent environment
  3. - name: "[ENV] controls nextcloud_trusted_domain type"
  4. ansible.builtin.fail:
  5. msg: "New versions require nextcloud_trusted_domain to be declared as a list."
  6. when: nextcloud_trusted_domain is string
  7. - name: "[ENV] - ca-certificate are up to date"
  8. # needed for downloading from download.nextcloud.com as the site use letsencrypt certificates
  9. # letsencrypt may not be trusted on older OS
  10. ansible.builtin.apt:
  11. name: "{{ item }}"
  12. state: present
  13. update_cache: true
  14. cache_valid_time: 86400
  15. loop:
  16. - acl
  17. - ca-certificates
  18. when: ansible_os_family in [ "Debian" ]
  19. # fix for debian not using sudo :
  20. # finding out if sudo is installed or not
  21. - name: "[ENV] - Debian only : checking sudo."
  22. ansible.builtin.command: "dpkg -l sudo"
  23. changed_when: false
  24. register: nc_sudo_installed_result
  25. failed_when: false
  26. when: ansible_distribution == "Debian"
  27. - name: "[ENV] - Checking su"
  28. block:
  29. - name: "[ENV] - rolling back to su."
  30. ansible.builtin.set_fact:
  31. ansible_become_method: "su"
  32. - name: "[ENV] - force su to use /bin/sh as shell"
  33. ansible.builtin.set_fact:
  34. ansible_become_flags: '-s /bin/sh'
  35. when:
  36. - nc_sudo_installed_result.rc is defined
  37. - nc_sudo_installed_result.rc != 0
  38. - name: "[ENV] - Generate database user password."
  39. ansible.builtin.set_fact:
  40. nextcloud_db_pwd: "{{ lookup( 'ansible.builtin.password', 'nextcloud_instances/'+ nextcloud_instance_name +'/db_admin.pwd' ) }}"
  41. when: nextcloud_db_pwd is not defined
  42. - name: "[ENV] - Generate database root password."
  43. ansible.builtin.set_fact:
  44. nextcloud_mysql_root_pwd: "{{ lookup( 'ansible.builtin.password', 'nextcloud_instances/'+ nextcloud_instance_name +'/db_root.pwd' ) }}"
  45. when:
  46. - nextcloud_db_backend in ["mysql", "mariadb"]
  47. - nextcloud_mysql_root_pwd is not defined