feat(pb,role,task): generalize names of common pre_tasks and their variables, specifies LXC-specific ones
This commit is contained in:
@@ -14,8 +14,8 @@
|
||||
- name: Include input and validation for hostname
|
||||
ansible.builtin.include_tasks: ../tasks/hostname_validation.yaml
|
||||
|
||||
- name: Include input and validation for password
|
||||
ansible.builtin.include_tasks: ../tasks/password_validation.yaml
|
||||
- name: Include input and validation for LXC root password
|
||||
ansible.builtin.include_tasks: ../tasks/lxc_root_password_validation.yaml
|
||||
|
||||
- name: Include input and validation for IP
|
||||
ansible.builtin.include_tasks: ../tasks/ip_validation.yaml
|
||||
@@ -33,7 +33,7 @@
|
||||
tasks:
|
||||
- name: Add the target host to the inventory
|
||||
ansible.builtin.add_host:
|
||||
name: "{{ lxc_ip_address }}"
|
||||
name: "{{ guest_ip_address }}"
|
||||
groups: new_host
|
||||
ansible_user: ansible
|
||||
ansible_become_password: "{{ ansible_become_passwd }}"
|
||||
@@ -58,10 +58,10 @@
|
||||
- name: Include human admin user role
|
||||
ansible.builtin.include_role:
|
||||
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
|
||||
ansible.builtin.include_role:
|
||||
name: ../roles/update_configs
|
||||
when: "hostvars['localhost']['lxc_human_admin_user'] | bool"
|
||||
when: "hostvars['localhost']['create_human_admin_user'] | bool"
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
cmode: "shell"
|
||||
password: "{{ lxc_root_password }}"
|
||||
hostname: "{{ lxc_hostname }}"
|
||||
hostname: "{{ guest_hostname }}"
|
||||
ostemplate: 'main:vztmpl/debian-13-golden-image.tar.gz'
|
||||
unprivileged: "{{ lxc_privileged }}"
|
||||
memory: 2048
|
||||
@@ -26,7 +26,7 @@
|
||||
storage: local
|
||||
pubkey: "{{ lookup('file', lookup('env', 'HOME') + '/.ssh/ansible_key.pub') }}"
|
||||
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
|
||||
become: false
|
||||
@@ -38,7 +38,7 @@
|
||||
api_token_id: ansible
|
||||
api_token_secret: "{{ proxmox_token_secret }}"
|
||||
|
||||
hostname: "{{ lxc_hostname }}"
|
||||
hostname: "{{ guest_hostname }}"
|
||||
state: started
|
||||
retries: 3
|
||||
delay: 15
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
- name: Set default hostname
|
||||
ansible.builtin.set_fact:
|
||||
lxc_hostname: "new-lxc-test"
|
||||
guest_hostname: "new-lxc-test"
|
||||
|
||||
- name: Prompt for hostname with immediate validation
|
||||
ansible.builtin.pause:
|
||||
@@ -19,5 +19,5 @@
|
||||
|
||||
- name: Use user input only if provided, otherwise keep the default
|
||||
ansible.builtin.set_fact:
|
||||
lxc_hostname: "{{ hostname_result.user_input }}"
|
||||
guest_hostname: "{{ hostname_result.user_input }}"
|
||||
when: hostname_result.user_input | length > 0
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
- name: Set default human admin user
|
||||
ansible.builtin.set_fact:
|
||||
lxc_human_admin_user: true
|
||||
create_human_admin_user: true
|
||||
|
||||
- name: Prompt for human admin user creation with immediate validation
|
||||
ansible.builtin.pause:
|
||||
@@ -18,5 +18,5 @@
|
||||
|
||||
- name: Use user input only if provided, otherwise keep the default
|
||||
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
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
- name: Set default ip
|
||||
ansible.builtin.set_fact:
|
||||
lxc_ip_address: "192.168.0.90"
|
||||
guest_ip_address: "192.168.0.90"
|
||||
|
||||
- name: Set default network mask
|
||||
ansible.builtin.set_fact:
|
||||
lxc_netmask: "24"
|
||||
guest_netmask: "24"
|
||||
|
||||
- name: Prompt for IP with immediate validation
|
||||
ansible.builtin.pause:
|
||||
@@ -20,10 +20,10 @@
|
||||
|
||||
- name: Use user input only if provided, otherwise keep the default (IP)
|
||||
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
|
||||
|
||||
- name: Use user input only if provided, otherwise keep the default (netmask)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user