Issue 38 stop on wrong value #40
@@ -31,17 +31,9 @@
|
|||||||
- ../roles/deploy_lxc_on_proxmox
|
- ../roles/deploy_lxc_on_proxmox
|
||||||
|
|
||||||
tasks:
|
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
|
- name: Add the target host to the inventory
|
||||||
ansible.builtin.add_host:
|
ansible.builtin.add_host:
|
||||||
name: "{{ fact_lxc_ip_address }}"
|
name: "{{ lxc_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 }}"
|
||||||
@@ -66,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']['fact_lxc_create_human_admin_user'] | bool"
|
when: "hostvars['localhost']['lxc_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']['fact_lxc_create_human_admin_user'] | bool"
|
when: "hostvars['localhost']['lxc_human_admin_user'] | bool"
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
password: "{{ lxc_root_password }}"
|
password: "{{ lxc_root_password }}"
|
||||||
hostname: "{{ lxc_hostname }}"
|
hostname: "{{ lxc_hostname }}"
|
||||||
ostemplate: 'main:vztmpl/debian-13-golden-image.tar.gz'
|
ostemplate: 'main:vztmpl/debian-13-golden-image.tar.gz'
|
||||||
unprivileged: "{{ lxc_is_privileged }}"
|
unprivileged: "{{ lxc_privileged }}"
|
||||||
memory: 2048
|
memory: 2048
|
||||||
cores: 2
|
cores: 2
|
||||||
state: present
|
state: present
|
||||||
@@ -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 }},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
|
- name: Make sure the container has started
|
||||||
become: false
|
become: false
|
||||||
|
|||||||
@@ -2,7 +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/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
|
- name: Prompt for IP with immediate validation
|
||||||
ansible.builtin.pause:
|
ansible.builtin.pause:
|
||||||
@@ -14,7 +18,12 @@
|
|||||||
retries: 2
|
retries: 2
|
||||||
delay: 0
|
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:
|
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
|
when: ip_result.user_input | length > 0
|
||||||
|
|||||||
Reference in New Issue
Block a user