refactor(playbook): rename prompt variables with backwards-compatible fallbacks

This commit is contained in:
2026-02-11 07:43:22 +01:00
parent fc8f43a25a
commit d8fcc6033d

View File

@@ -5,22 +5,22 @@
gather_facts: false gather_facts: false
become: true become: true
vars_prompt: vars_prompt:
- name: system_user_name - name: user_name
prompt: | prompt: |
What is your username? What is your username?
private: false private: false
- name: system_user_key - name: user_public_key
prompt: | prompt: |
What is your ssh key? What is your ssh key?
private: false private: false
- name: system_user_password - name: user_password
prompt: | prompt: |
What is your password? What is your password?
confirm: true confirm: true
- name: system_root_password - name: root_password
prompt: | prompt: |
What is your root password? What is your root password?
confirm: true confirm: true
@@ -30,6 +30,10 @@
system_input: "{{ system | default({}) }}" system_input: "{{ system | default({}) }}"
system_user_input: "{{ (system_input.user | default({})) if (system_input.user is mapping) else {} }}" system_user_input: "{{ (system_input.user | default({})) if (system_input.user is mapping) else {} }}"
system_root_input: "{{ (system_input.root | default({})) if (system_input.root is mapping) else {} }}" system_root_input: "{{ (system_input.root | default({})) if (system_input.root is mapping) else {} }}"
prompt_user_name: "{{ user_name | default(system_user_name | default(''), true) | string }}"
prompt_user_key: "{{ user_public_key | default(user_key | default(system_user_key | default(''), true), true) | string }}"
prompt_user_password: "{{ user_password | default(system_user_password | default(''), true) | string }}"
prompt_root_password: "{{ root_password | default(system_root_password | default(''), true) | string }}"
ansible.builtin.set_fact: ansible.builtin.set_fact:
system: >- system: >-
{{ {{
@@ -39,18 +43,18 @@
'user': { 'user': {
'name': ( 'name': (
(system_user_input.name | default('') | string | length) > 0 (system_user_input.name | default('') | string | length) > 0
) | ternary(system_user_input.name | string, system_user_name | default('') | string), ) | ternary(system_user_input.name | string, prompt_user_name),
'key': ( 'key': (
(system_user_input.key | default('') | string | length) > 0 (system_user_input.key | default('') | string | length) > 0
) | ternary(system_user_input.key | string, system_user_key | default('') | string), ) | ternary(system_user_input.key | string, prompt_user_key),
'password': ( 'password': (
(system_user_input.password | default('') | string | length) > 0 (system_user_input.password | default('') | string | length) > 0
) | ternary(system_user_input.password | string, system_user_password | default('') | string) ) | ternary(system_user_input.password | string, prompt_user_password)
}, },
'root': { 'root': {
'password': ( 'password': (
(system_root_input.password | default('') | string | length) > 0 (system_root_input.password | default('') | string | length) > 0
) | ternary(system_root_input.password | string, system_root_password | default('') | string) ) | ternary(system_root_input.password | string, prompt_root_password)
} }
}, },
recursive=True recursive=True