From 53502ae102eb54383ec20537d669b202f3b00dec Mon Sep 17 00:00:00 2001 From: Koen Ekelschot Date: Sun, 7 Apr 2024 13:40:10 +0200 Subject: [PATCH 1/4] Fix creation of users Signed-off-by: Koen Ekelschot --- tasks/local_git_users.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/local_git_users.yml b/tasks/local_git_users.yml index c2a3c1d..3a741c9 100644 --- a/tasks/local_git_users.yml +++ b/tasks/local_git_users.yml @@ -2,7 +2,7 @@ - name: Identify gitea users ansible.builtin.command: su - {{ gitea_user }} -c '{{ gitea_full_executable_path }} -c {{ gitea_configuration_path }}/gitea.ini admin user list' become: true - register: _giteusers + register: _giteausers changed_when: false - name: Use gitea cli to create user @@ -18,5 +18,5 @@ - '"successfully created" not in gitearesult.stdout' changed_when: - '"successfully created!" in gitearesult.stdout' - when: "_giteusers is defined and item.name in _giteusers" + when: "_giteausers is defined and item.name not in _giteausers" loop: "{{ gitea_users }}" From 11d5b82dc3bdcddf87cfa33044f95b1b17e21af3 Mon Sep 17 00:00:00 2001 From: Koen Ekelschot Date: Sun, 7 Apr 2024 13:56:18 +0200 Subject: [PATCH 2/4] use correct variable Signed-off-by: Koen Ekelschot --- tasks/local_git_users.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/local_git_users.yml b/tasks/local_git_users.yml index 3a741c9..4c34613 100644 --- a/tasks/local_git_users.yml +++ b/tasks/local_git_users.yml @@ -15,8 +15,8 @@ --must-change-password={{ item.must_change_password }} --admin={{ item.admin }}' register: _gitearesult failed_when: - - '"successfully created" not in gitearesult.stdout' + - '"successfully created" not in _gitearesult.stdout' changed_when: - - '"successfully created!" in gitearesult.stdout' + - '"successfully created!" in _gitearesult.stdout' when: "_giteausers is defined and item.name not in _giteausers" loop: "{{ gitea_users }}" From 44c27a6a2b9ad9aa0047c98f9814490a5a47eb03 Mon Sep 17 00:00:00 2001 From: Koen Ekelschot Date: Sun, 7 Apr 2024 14:16:16 +0200 Subject: [PATCH 3/4] Fix newlines in command Signed-off-by: Koen Ekelschot --- tasks/local_git_users.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/local_git_users.yml b/tasks/local_git_users.yml index 4c34613..df19334 100644 --- a/tasks/local_git_users.yml +++ b/tasks/local_git_users.yml @@ -8,10 +8,10 @@ - name: Use gitea cli to create user become: true ansible.builtin.command: | - su - {{ gitea_user }} -c - '{{ gitea_full_executable_path }} -c {{ gitea_configuration_path }}/gitea.ini - admin user create --username "{{ item.name }}" - --password "{{ item.password }}" --email "{{ item.email }}" + su - {{ gitea_user }} -c \ + '{{ gitea_full_executable_path }} -c {{ gitea_configuration_path }}/gitea.ini \ + admin user create --username "{{ item.name }}" \ + --password "{{ item.password }}" --email "{{ item.email }}" \ --must-change-password={{ item.must_change_password }} --admin={{ item.admin }}' register: _gitearesult failed_when: From 1ad7487f719b64ccea33453afd219d8b78bd6ac0 Mon Sep 17 00:00:00 2001 From: Koen Ekelschot Date: Sun, 7 Apr 2024 15:27:00 +0200 Subject: [PATCH 4/4] use stdout Signed-off-by: Koen Ekelschot --- tasks/local_git_users.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/local_git_users.yml b/tasks/local_git_users.yml index df19334..a8d9109 100644 --- a/tasks/local_git_users.yml +++ b/tasks/local_git_users.yml @@ -18,5 +18,5 @@ - '"successfully created" not in _gitearesult.stdout' changed_when: - '"successfully created!" in _gitearesult.stdout' - when: "_giteausers is defined and item.name not in _giteausers" + when: "_giteausers is defined and item.name not in _giteausers.stdout" loop: "{{ gitea_users }}"