From 6649426ca7120e876957f74f304bc622ef8ed0ef Mon Sep 17 00:00:00 2001 From: Maxim Vershinin Date: Tue, 15 Sep 2026 17:53:18 +0400 Subject: [PATCH] feat(pb): makes human admin user optional --- .../deploy_and_set_up_lxc_on_proxmox.yaml | 26 +++++++++++++++---- playbooks/deploy_vm_from_cloud_init.yaml | 23 +++++++++++++--- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/playbooks/deploy_and_set_up_lxc_on_proxmox.yaml b/playbooks/deploy_and_set_up_lxc_on_proxmox.yaml index 4216f21..afe11d9 100644 --- a/playbooks/deploy_and_set_up_lxc_on_proxmox.yaml +++ b/playbooks/deploy_and_set_up_lxc_on_proxmox.yaml @@ -33,6 +33,11 @@ default: true private: false + - name: lxc_create_human_admin_user + prompt: "Create human admin user? (true/false)?" + default: true + private: false + pre_tasks: - name: Validate hostname ansible.builtin.fail: @@ -57,12 +62,15 @@ - name: Make the prompted hostname available to the whole playbook ansible.builtin.set_fact: fact_lxc_hostname: "{{ lxc_hostname }}" - + - name: Make the prompted IP available to the whole playbook ansible.builtin.set_fact: - #fact_lxc_ip_address: "{{ lxc_ip_address | ansible.utils.ipaddr('address') }}" 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 }}" @@ -85,7 +93,15 @@ - ../roles/configure_ansible_user - ../roles/harden_ssh - ../roles/base_system - - ../roles/human_admin_user - # Update configs - omz, nvim, ranger and so on. Distribute the last version of those configs - - ../roles/update_configs + + tasks: + - 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" + + - name: Include update configs role + ansible.builtin.include_role: + name: ../roles/update_configs + when: "hostvars['localhost']['fact_lxc_create_human_admin_user'] | bool" diff --git a/playbooks/deploy_vm_from_cloud_init.yaml b/playbooks/deploy_vm_from_cloud_init.yaml index 1449859..2ce67d7 100644 --- a/playbooks/deploy_vm_from_cloud_init.yaml +++ b/playbooks/deploy_vm_from_cloud_init.yaml @@ -26,6 +26,11 @@ default: "sudo" private: false + - name: vm_create_human_admin_user + prompt: "Create human admin user? (true/false)?" + default: true + private: false + - name: vm_ip_address prompt: "IP address for the VM (in x.x.x.x/x formant)" default: "192.168.0.89/24" @@ -80,6 +85,10 @@ ansible.builtin.set_fact: fact_vm_ip_address: "{{ vm_ip_address.split('/') | first }}" + - name: Make the "human admin user" selection available to the whole playbook + ansible.builtin.set_fact: + fact_vm_create_human_admin_user: "{{ vm_create_human_admin_user }}" + - name: Add the target host to the inventory ansible.builtin.add_host: name: "{{ fact_vm_ip_address }}" @@ -103,7 +112,15 @@ - ../roles/configure_ansible_user - ../roles/harden_ssh - ../roles/base_system - - ../roles/human_admin_user - # Update configs - omz, nvim, ranger and so on. Distribute the last version of those configs - - ../roles/update_configs + + tasks: + - name: Include human admin user role + ansible.builtin.include_role: + name: ../roles/human_admin_user + when: "hostvars['localhost']['fact_vm_create_human_admin_user'] | bool" + + - name: Include update configs role + ansible.builtin.include_role: + name: ../roles/update_configs + when: "hostvars['localhost']['fact_vm_create_human_admin_user'] | bool"