feat(pb,role,task): generalize names of common pre_tasks and their variables, specifies LXC-specific ones

This commit is contained in:
2026-09-17 11:16:18 +04:00
parent daa5826573
commit f29de42397
6 changed files with 16 additions and 16 deletions
@@ -14,8 +14,8 @@
- name: Include input and validation for hostname - name: Include input and validation for hostname
ansible.builtin.include_tasks: ../tasks/hostname_validation.yaml ansible.builtin.include_tasks: ../tasks/hostname_validation.yaml
- name: Include input and validation for password - name: Include input and validation for LXC root password
ansible.builtin.include_tasks: ../tasks/password_validation.yaml ansible.builtin.include_tasks: ../tasks/lxc_root_password_validation.yaml
- name: Include input and validation for IP - name: Include input and validation for IP
ansible.builtin.include_tasks: ../tasks/ip_validation.yaml ansible.builtin.include_tasks: ../tasks/ip_validation.yaml
@@ -33,7 +33,7 @@
tasks: tasks:
- name: Add the target host to the inventory - name: Add the target host to the inventory
ansible.builtin.add_host: ansible.builtin.add_host:
name: "{{ lxc_ip_address }}" name: "{{ guest_ip_address }}"
groups: new_host groups: new_host
ansible_user: ansible ansible_user: ansible
ansible_become_password: "{{ ansible_become_passwd }}" ansible_become_password: "{{ ansible_become_passwd }}"
@@ -58,10 +58,10 @@
- name: Include human admin user role - name: Include human admin user role
ansible.builtin.include_role: ansible.builtin.include_role:
name: ../roles/human_admin_user name: ../roles/human_admin_user
when: "hostvars['localhost']['lxc_human_admin_user'] | bool" when: "hostvars['localhost']['create_human_admin_user'] | bool"
- name: Include update configs role - name: Include update configs role
ansible.builtin.include_role: ansible.builtin.include_role:
name: ../roles/update_configs name: ../roles/update_configs
when: "hostvars['localhost']['lxc_human_admin_user'] | bool" when: "hostvars['localhost']['create_human_admin_user'] | bool"
+3 -3
View File
@@ -12,7 +12,7 @@
cmode: "shell" cmode: "shell"
password: "{{ lxc_root_password }}" password: "{{ lxc_root_password }}"
hostname: "{{ lxc_hostname }}" hostname: "{{ guest_hostname }}"
ostemplate: 'main:vztmpl/debian-13-golden-image.tar.gz' ostemplate: 'main:vztmpl/debian-13-golden-image.tar.gz'
unprivileged: "{{ lxc_privileged }}" unprivileged: "{{ lxc_privileged }}"
memory: 2048 memory: 2048
@@ -26,7 +26,7 @@
storage: local storage: local
pubkey: "{{ lookup('file', lookup('env', 'HOME') + '/.ssh/ansible_key.pub') }}" pubkey: "{{ lookup('file', lookup('env', 'HOME') + '/.ssh/ansible_key.pub') }}"
netif: netif:
net0: "name=eth0,gw=192.168.0.1,ip={{ lxc_ip_address }}/{{ lxc_netmask }},bridge=vmbr0" net0: "name=eth0,gw=192.168.0.1,ip={{ guest_ip_address }}/{{ guest_netmask }},bridge=vmbr0"
- name: Make sure the container has started - name: Make sure the container has started
become: false become: false
@@ -38,7 +38,7 @@
api_token_id: ansible api_token_id: ansible
api_token_secret: "{{ proxmox_token_secret }}" api_token_secret: "{{ proxmox_token_secret }}"
hostname: "{{ lxc_hostname }}" hostname: "{{ guest_hostname }}"
state: started state: started
retries: 3 retries: 3
delay: 15 delay: 15
+2 -2
View File
@@ -2,7 +2,7 @@
- name: Set default hostname - name: Set default hostname
ansible.builtin.set_fact: ansible.builtin.set_fact:
lxc_hostname: "new-lxc-test" guest_hostname: "new-lxc-test"
- name: Prompt for hostname with immediate validation - name: Prompt for hostname with immediate validation
ansible.builtin.pause: ansible.builtin.pause:
@@ -19,5 +19,5 @@
- name: Use user input only if provided, otherwise keep the default - name: Use user input only if provided, otherwise keep the default
ansible.builtin.set_fact: ansible.builtin.set_fact:
lxc_hostname: "{{ hostname_result.user_input }}" guest_hostname: "{{ hostname_result.user_input }}"
when: hostname_result.user_input | length > 0 when: hostname_result.user_input | length > 0
+2 -2
View File
@@ -2,7 +2,7 @@
- name: Set default human admin user - name: Set default human admin user
ansible.builtin.set_fact: ansible.builtin.set_fact:
lxc_human_admin_user: true create_human_admin_user: true
- name: Prompt for human admin user creation with immediate validation - name: Prompt for human admin user creation with immediate validation
ansible.builtin.pause: ansible.builtin.pause:
@@ -18,5 +18,5 @@
- name: Use user input only if provided, otherwise keep the default - name: Use user input only if provided, otherwise keep the default
ansible.builtin.set_fact: ansible.builtin.set_fact:
lxc_human_admin_user: "{{ human_admin_user_result.user_input }}" create_human_admin_user: "{{ human_admin_user_result.user_input }}"
when: human_admin_user_result.user_input | length > 0 when: human_admin_user_result.user_input | length > 0
+4 -4
View File
@@ -2,11 +2,11 @@
- name: Set default ip - name: Set default ip
ansible.builtin.set_fact: ansible.builtin.set_fact:
lxc_ip_address: "192.168.0.90" guest_ip_address: "192.168.0.90"
- name: Set default network mask - name: Set default network mask
ansible.builtin.set_fact: ansible.builtin.set_fact:
lxc_netmask: "24" guest_netmask: "24"
- name: Prompt for IP with immediate validation - name: Prompt for IP with immediate validation
ansible.builtin.pause: ansible.builtin.pause:
@@ -20,10 +20,10 @@
- name: Use user input only if provided, otherwise keep the default (IP) - name: Use user input only if provided, otherwise keep the default (IP)
ansible.builtin.set_fact: ansible.builtin.set_fact:
lxc_ip_address: "{{ ip_result.user_input.split('/') | first }}" guest_ip_address: "{{ ip_result.user_input.split('/') | first }}"
when: ip_result.user_input | length > 0 when: ip_result.user_input | length > 0
- name: Use user input only if provided, otherwise keep the default (netmask) - name: Use user input only if provided, otherwise keep the default (netmask)
ansible.builtin.set_fact: ansible.builtin.set_fact:
lxc_netmask: "{{ ip_result.user_input.split('/') | second }}" guest_netmask: "{{ ip_result.user_input.split('/') | second }}"
when: ip_result.user_input | length > 0 when: ip_result.user_input | length > 0