feat(pb,role,task): completes the LXC deployment workflow using new validation tasks
This commit is contained in:
@@ -31,17 +31,9 @@
|
||||
- ../roles/deploy_lxc_on_proxmox
|
||||
|
||||
tasks:
|
||||
- name: Make the prompted IP available to the whole playbook
|
||||
ansible.builtin.set_fact:
|
||||
fact_lxc_ip_address: "{{ lxc_ip_address.split('/') | first }}"
|
||||
|
||||
- name: Make the "human admin user" selection available to the whole playbook
|
||||
ansible.builtin.set_fact:
|
||||
fact_lxc_create_human_admin_user: "{{ lxc_create_human_admin_user }}"
|
||||
|
||||
- name: Add the target host to the inventory
|
||||
ansible.builtin.add_host:
|
||||
name: "{{ fact_lxc_ip_address }}"
|
||||
name: "{{ lxc_ip_address }}"
|
||||
groups: new_host
|
||||
ansible_user: ansible
|
||||
ansible_become_password: "{{ ansible_become_passwd }}"
|
||||
@@ -66,10 +58,10 @@
|
||||
- name: Include human admin user role
|
||||
ansible.builtin.include_role:
|
||||
name: ../roles/human_admin_user
|
||||
when: "hostvars['localhost']['fact_lxc_create_human_admin_user'] | bool"
|
||||
when: "hostvars['localhost']['lxc_human_admin_user'] | bool"
|
||||
|
||||
- name: Include update configs role
|
||||
ansible.builtin.include_role:
|
||||
name: ../roles/update_configs
|
||||
when: "hostvars['localhost']['fact_lxc_create_human_admin_user'] | bool"
|
||||
when: "hostvars['localhost']['lxc_human_admin_user'] | bool"
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
password: "{{ lxc_root_password }}"
|
||||
hostname: "{{ lxc_hostname }}"
|
||||
ostemplate: 'main:vztmpl/debian-13-golden-image.tar.gz'
|
||||
unprivileged: "{{ lxc_is_privileged }}"
|
||||
unprivileged: "{{ lxc_privileged }}"
|
||||
memory: 2048
|
||||
cores: 2
|
||||
state: present
|
||||
@@ -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 }},bridge=vmbr0"
|
||||
net0: "name=eth0,gw=192.168.0.1,ip={{ lxc_ip_address }}/{{ lxc_netmask }},bridge=vmbr0"
|
||||
|
||||
- name: Make sure the container has started
|
||||
become: false
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
|
||||
- name: Set default ip
|
||||
ansible.builtin.set_fact:
|
||||
lxc_ip_address: "192.168.0.90/24"
|
||||
lxc_ip_address: "192.168.0.90"
|
||||
|
||||
- name: Set default network mask
|
||||
ansible.builtin.set_fact:
|
||||
lxc_netmask: "24"
|
||||
|
||||
- name: Prompt for IP with immediate validation
|
||||
ansible.builtin.pause:
|
||||
@@ -14,7 +18,12 @@
|
||||
retries: 2
|
||||
delay: 0
|
||||
|
||||
- name: Use user input only if provided, otherwise keep the default
|
||||
- name: Use user input only if provided, otherwise keep the default (IP)
|
||||
ansible.builtin.set_fact:
|
||||
lxc_ip_address: "{{ ip_result.user_input }}"
|
||||
lxc_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 }}"
|
||||
when: ip_result.user_input | length > 0
|
||||
|
||||
Reference in New Issue
Block a user