main.yml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. ---
  2. # Verify client secret
  3. - name: "Verify client secret is available"
  4. fail:
  5. msg: "Client secret is not set or empty"
  6. when: client_secret is not defined or client_secret | default('') | trim == ''
  7. # First disable maintenance mode to ensure app commands work
  8. - name: "Ensure maintenance mode is off before starting"
  9. become: true
  10. command:
  11. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ maintenance:mode --off"
  12. ignore_errors: true
  13. - name: "Uninstall Sociallogin app"
  14. become: true
  15. command:
  16. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ app:remove sociallogin"
  17. ignore_errors: true
  18. - name: "Install sociallogin app"
  19. become: true
  20. command:
  21. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ app:install sociallogin"
  22. - name: "Create users group"
  23. become: true
  24. command:
  25. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ group:add nextcloud-users"
  26. ignore_errors: true # Falls die Gruppe bereits existiert
  27. - name: "Create admin group if not exists"
  28. become: true
  29. command:
  30. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ group:add nextcloud-admins"
  31. ignore_errors: true
  32. - name: "Create youpi group"
  33. become: true
  34. command:
  35. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ group:add nextcloud-youpi"
  36. ignore_errors: true
  37. # Configure Social Login
  38. - name: "Set Social Login custom providers config"
  39. become: true
  40. command:
  41. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ config:app:set sociallogin custom_providers --value='{{ sso_config | to_json }}'"
  42. register: config_result
  43. - name: "Debug config result"
  44. debug:
  45. var: config_result
  46. verbosity: 1
  47. - name: "Verify Social Login config"
  48. become: true
  49. command:
  50. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ config:app:get sociallogin custom_providers"
  51. register: verify_config
  52. - name: "Debug verification result"
  53. debug:
  54. var: verify_config
  55. verbosity: 1
  56. # Configure Social Login settings
  57. - name: "Set Social Login prevent_create_email_exists"
  58. become: true
  59. command:
  60. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ config:app:set sociallogin prevent_create_email_exists --value='1'"
  61. - name: "Set Social Login update_profile_on_login"
  62. become: true
  63. command:
  64. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ config:app:set sociallogin update_profile_on_login --value='1'"
  65. - name: "Set Social Login restrict_users_wo_mapped_groups"
  66. become: true
  67. command:
  68. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ config:app:set sociallogin restrict_users_wo_mapped_groups --value='1'"
  69. - name: "Set Social Login restrict_users_wo_assigned_groups"
  70. become: true
  71. command:
  72. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ config:app:set sociallogin restrict_users_wo_assigned_groups --value='1'"
  73. # Data directory setup
  74. - name: "Create .ncdata file"
  75. become: true
  76. command:
  77. cmd: "docker exec -u 33 nextcloud sh -c 'echo \"# Nextcloud data directory\" > {{ nextcloud_data_dir }}/.ncdata'"
  78. - name: "Set data folder ownership"
  79. become: true
  80. command:
  81. cmd: "docker exec -u 0 nextcloud chown -R 33:33 {{ nextcloud_data_dir }}"
  82. - name: "Set data folder permissions"
  83. become: true
  84. command:
  85. cmd: "docker exec -u 0 nextcloud chmod -R 770 {{ nextcloud_data_dir }}"
  86. # Restart the app to apply changes
  87. - name: "Disable sociallogin app"
  88. become: true
  89. command:
  90. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ app:disable sociallogin"
  91. - name: "Enable sociallogin app"
  92. become: true
  93. command:
  94. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ app:enable sociallogin"
  95. - name: "Verify sociallogin configuration"
  96. become: true
  97. command:
  98. cmd: "docker exec -u 33 nextcloud php /var/www/html/occ config:app:get sociallogin custom_providers"
  99. register: sso_config_verification
  100. - name: "Display SSO configuration"
  101. debug:
  102. var: sso_config_verification.stdout