fix: Fix server selection in update-user while preserving nice display of server along with its alt_name in the list

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.
This commit is contained in:
Roch Moreau 2024-06-11 14:11:40 +02:00
parent 5a275cd0cd
commit a66dbbf03e
No known key found for this signature in database
GPG key ID: 9EC088DB6CB6AF43

View file

@ -25,10 +25,8 @@
set_fact: set_fact:
server_list: >- server_list: >-
[{% for i in _configs_list.files %} [{% for i in _configs_list.files %}
{% set config = lookup('file', i.path)|from_yaml %} {% set config = lookup('file', i.path) | from_yaml %}
'{{ config.server }}' {{ {'server': config.server, 'IP_subject_alt_name': config.IP_subject_alt_name} }}
'{{ config.IP_subject_alt_name }}'
{{ ',' if not loop.last else '' }}
{% endfor %}] {% endfor %}]
- name: Server address prompt - name: Server address prompt
@ -36,8 +34,8 @@
prompt: | prompt: |
Select the server to update user list below: Select the server to update user list below:
{% for r in server_list %} {% for r in server_list %}
{{ loop.index }}. {{ r }} {{ loop.index }}. {{ r.server }} ({{ r.IP_subject_alt_name }})
{% endfor %} {% endfor %}
register: _server register: _server
when: server is undefined when: server is undefined
@ -46,7 +44,7 @@
set_fact: set_fact:
algo_server: >- algo_server: >-
{% if server is defined %}{{ 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 %} {%- else %}omit{% endif %}
- name: Import host specific variables - name: Import host specific variables