mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-10-10 18:58:10 +02:00
Introduce centralized variables: - docker_compose_command_base - docker_compose_command_exec Replaced hardcoded 'docker compose exec' with '{{ docker_compose_command_exec }}' across multiple roles (BigBlueButton, EspoCRM, Friendica, Listmonk, Mailu, Matrix, OpenProject). Ensures consistent environment file loading and reduces duplicated code. Details: https://chatgpt.com/share/68d6a276-19d0-800f-839d-d191d97f7c41
31 lines
1.2 KiB
YAML
31 lines
1.2 KiB
YAML
- name: Ensure administrator user exists and is admin
|
|
shell: >
|
|
{{ docker_compose_command_exec }} web bash -c "
|
|
cd /app &&
|
|
RAILS_ENV={{ ENVIRONMENT | lower }} bundle exec rails runner \"
|
|
u = User.find_by(login: '{{ OPENPROJECT_ADMINISTRATOR_USERNAME }}')
|
|
if u.nil?
|
|
u = User.new(
|
|
login: '{{ OPENPROJECT_ADMINISTRATOR_USERNAME }}',
|
|
mail: '{{ OPENPROJECT_ADMINISTRATOR_EMAIL }}',
|
|
firstname: 'Admin',
|
|
lastname: 'User',
|
|
password: '{{ OPENPROJECT_ADMINISTRATOR_PASSWORD }}',
|
|
password_confirmation: '{{ OPENPROJECT_ADMINISTRATOR_PASSWORD }}'
|
|
)
|
|
u.admin = true
|
|
u.save!
|
|
puts 'Administrator {{ OPENPROJECT_ADMINISTRATOR_USERNAME }} created and set as admin.'
|
|
else
|
|
u.admin = true
|
|
u.save!
|
|
puts 'User {{ OPENPROJECT_ADMINISTRATOR_USERNAME }} updated to admin.'
|
|
end
|
|
\"
|
|
"
|
|
args:
|
|
chdir: "{{ docker_compose.directories.instance }}"
|
|
async: "{{ ASYNC_TIME if ASYNC_ENABLED | bool else omit }}"
|
|
poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}"
|
|
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
|