REFACTOR: VM creation and setup

This commit is contained in:
2026-08-09 14:10:53 +04:00
parent 84af7b011b
commit d0c272ff83
3 changed files with 19 additions and 30 deletions
@@ -12,17 +12,17 @@
vars_prompt: vars_prompt:
- name: lxc_hostname - name: lxc_hostname
prompt: "Hostname for the container:" prompt: "Hostname for the container"
private: false private: false
- name: lxc_root_password - name: lxc_root_password
prompt: "Root password:" prompt: "Root password"
private: true private: true
confirm: true confirm: true
encrypt: sha512_crypt encrypt: sha512_crypt
- name: lxc_ip_address - name: lxc_ip_address
prompt: "IP address for the container (in x.x.x.x/x formant):" prompt: "IP address for the container (in x.x.x.x/x formant)"
private: false private: false
+6 -17
View File
@@ -2,27 +2,16 @@
- name: Deploy a virtual machine from a cloud init image - name: Deploy a virtual machine from a cloud init image
hosts: localhost hosts: localhost
gather_facts: false gather_facts: false
roles:
- ../roles/basic_proxmox_vm
- name: Basic Proxmox guest deployment
hosts: all
remote_user: ansible
roles:
- ../roles/basic_postinstall
vars_files: vars_files:
../inventory/group_vars/all/secrets.yaml ../inventory/group_vars/all/secrets.yaml
vars: vars:
ansible_user_passwd_hash: "{{ ansible_password | password_hash('sha512', 's3edscrj45e6r') }}" ansible_user_passwd_hash: "{{ ansible_password | password_hash('sha512', 's3edscrj45e6r') }}"
user_passwd_hash: "{{ user_password | password_hash('sha512', 's3ed6123jhgcr') }}" user_passwd_hash: "{{ user_password | password_hash('sha512', 's3ed6123jhgcr') }}"
vars_prompt:
- name: vm_hostname
prompt: "Hostname for the VM"
private: false
handlers: roles:
- name: restart ssh-server - ../roles/deploy_vm_on_proxmox
service:
name: ssh
state: restarted
- name: restart sshd-server
service:
name: sshd
state: restarted
@@ -10,13 +10,19 @@
api_token_secret: "{{ proxmox_token_secret }}" api_token_secret: "{{ proxmox_token_secret }}"
clone: debian-13-cloud-init-template clone: debian-13-cloud-init-template
newid: 1041 name: "{{ vm_hostname }}"
name: ansible-ci-test
storage: main storage: main
format: qcow2 format: qcow2
full: true full: true
timeout: 500 timeout: 500
- name: Sleep for 20 seconds to ensure that Proxmox has cloned the VM
become: false
ansible.builtin.wait_for:
timeout: 20
delegate_to: localhost
changed_when: false
- name: Tweak the hardware settings - name: Tweak the hardware settings
become: false become: false
community.proxmox.proxmox_kvm: community.proxmox.proxmox_kvm:
@@ -27,7 +33,7 @@
api_token_id: ansible api_token_id: ansible
api_token_secret: "{{ proxmox_token_secret }}" api_token_secret: "{{ proxmox_token_secret }}"
vmid: 1041 name: "{{ vm_hostname }}"
cores: 4 cores: 4
memory: 4096 # Minimal value for debian based OS for smooth workflow memory: 4096 # Minimal value for debian based OS for smooth workflow
update: true update: true
@@ -42,12 +48,6 @@
api_token_id: ansible api_token_id: ansible
api_token_secret: "{{ proxmox_token_secret }}" api_token_secret: "{{ proxmox_token_secret }}"
vmid: 1041 name: "{{ vm_hostname }}"
state: started state: started
- name: Sleep for 3 minutes to ensure that cloud-init's done its thing
become: false
ansible.builtin.wait_for:
timeout: 180
delegate_to: localhost
changed_when: false