From 346437fa6eb3a37b1be69268874784a73ab26e03 Mon Sep 17 00:00:00 2001 From: Roch Moreau Date: Thu, 18 Jul 2024 02:55:42 +0200 Subject: [PATCH] fix: Fix server selection in update-user while preserving nice display of server along with its alt_name in the list (#14727) This commit fixes a bug preventing correct selection of server when trying to update users. It improves the prompt's clarity by providing both server name and IP_subject_alt_name. It also ensures server selection from the list uses actual server names instead of list descriptions strings that caused the initial bug. Co-authored-by: Jack Ivanov <17044561+jackivanov@users.noreply.github.com> --- users.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/users.yml b/users.yml index 3595db116..77c81a90b 100644 --- a/users.yml +++ b/users.yml @@ -25,19 +25,17 @@ set_fact: server_list: >- [{% for i in _configs_list.files %} - {% set config = lookup('file', i.path)|from_yaml %} - '{{ config.server }}' - '{{ config.IP_subject_alt_name }}' - {{ ',' if not loop.last else '' }} + {% set config = lookup('file', i.path) | from_yaml %} + {{ {'server': config.server, 'IP_subject_alt_name': config.IP_subject_alt_name} }} {% endfor %}] - name: Server address prompt pause: prompt: | - Select the server to update user list below: + Select the server to update user list below: {% for r in server_list %} - {{ loop.index }}. {{ r }} - {% endfor %} + {{ loop.index }}. {{ r.server }} ({{ r.IP_subject_alt_name }}) + {% endfor %} register: _server when: server is undefined @@ -46,7 +44,7 @@ set_fact: algo_server: >- {% if server is defined %}{{ server }} - {%- elif _server.user_input %}{{ server_list[_server.user_input | int -1 ] }} + {%- elif _server.user_input %}{{ server_list[_server.user_input | int -1 ].server }} {%- else %}omit{% endif %} - name: Import host specific variables