|
|
|
@ -23,22 +23,21 @@
|
|
|
|
|
block:
|
|
|
|
|
- name: Gather existing users
|
|
|
|
|
shell: >
|
|
|
|
|
docker-compose exec {{ kimai.services.mysql.service_name }} mysql -u{{ kimai.services.mysql.user }} -p{{ kimai.services.mysql.password}} --execute "SELECT username,roles FROM {{ kimai.services.mysql.db }}.kimai2_users;" -sN 2>/dev/null | awk '{ gsub(/^[ \t]+|[ \t]+$/, ""); gsub(/[ ]+/," "); print $1,"|",$2}' > /kimai_users.txt
|
|
|
|
|
docker-compose exec {{ kimai.services.mysql.service_name }} mysql -u{{ kimai.services.mysql.user }} -p{{ kimai.services.mysql.password}} --execute "SELECT username,roles FROM {{ kimai.services.mysql.db }}.kimai2_users;" -sN 2>/dev/null | awk '{ gsub(/^[ \t]+|[ \t]+$/, ""); gsub(/[ ]+/," "); print $1,"|",$2}' > ./kimai_users.txt
|
|
|
|
|
args:
|
|
|
|
|
chdir: "{{ kimai.general.base_path }}"
|
|
|
|
|
|
|
|
|
|
- name: Check existing kimai_users
|
|
|
|
|
command: grep -Fqe "{{ item.key }}" /kimai_users.txt
|
|
|
|
|
command: grep -Fqe "{{ item.key }}" ./kimai_users.txt
|
|
|
|
|
args:
|
|
|
|
|
chdir: "{{ kimai.general.base_path }}"
|
|
|
|
|
check_mode: 'no'
|
|
|
|
|
ignore_errors: 'yes'
|
|
|
|
|
ignore_errors: 'no'
|
|
|
|
|
register: admin_lines
|
|
|
|
|
loop: "{{ kimai.main.users | dict2items | selectattr('value.role', 'search', 'ROLE_SUPER_ADMIN')}}"
|
|
|
|
|
changed_when: admin_lines.rc != 0
|
|
|
|
|
failed_when: admin_lines is not defined or admin_lines.rc > 1
|
|
|
|
|
|
|
|
|
|
- name: Debug admins to json
|
|
|
|
|
debug:
|
|
|
|
|
msg: "Admins: {{ admin_lines | to_json }}"
|
|
|
|
|
|
|
|
|
|
- name: Init fact
|
|
|
|
|
set_fact:
|
|
|
|
|
kimai_users:
|
|
|
|
|