feat(pb,role): adds alpine as an option for VM deploying
This commit is contained in:
@@ -15,6 +15,16 @@
|
||||
prompt: "Hostname for the VM (may only contain letters (a-z, A-Z), numbers (0-9), and hyphens)"
|
||||
private: false
|
||||
|
||||
- name: vm_os_template
|
||||
prompt: "Select OS template. Available: debian-13 | alpine"
|
||||
default: "debian-13"
|
||||
private: false
|
||||
|
||||
- name: vm_become_method
|
||||
prompt: "Select become method. Available: sudo | su | pbrun | pfexec | doas | dzdo | ksu | runas | machinectl"
|
||||
default: "sudo"
|
||||
private: false
|
||||
|
||||
- name: vm_ip_address
|
||||
prompt: "IP address for the VM (in x.x.x.x/x formant)"
|
||||
private: false
|
||||
@@ -28,15 +38,35 @@
|
||||
when: not vm_hostname is regex('^[a-zA-Z0-9-]+$')
|
||||
run_once: true
|
||||
|
||||
- name: Validate OS template
|
||||
ansible.builtin.fail:
|
||||
msg: |
|
||||
Invalid OS template: "{{ vm_os_template }}"
|
||||
Select from available options: debian-13, alpine
|
||||
when: vm_os_template not in ['debian-13', 'alpine']
|
||||
run_once: true
|
||||
|
||||
- name: Validate become method
|
||||
ansible.builtin.fail:
|
||||
msg: |
|
||||
Invalid become method: "{{ vm_become_method }}"
|
||||
Select from available options: sudo | su | pbrun | pfexec | doas | dzdo | ksu | runas | machinectl
|
||||
when: vm_become_method not in ['sudo', 'su', 'pbrun', 'pfexec', 'doas', 'dzdo', 'ksu', 'runas', 'machinectl']
|
||||
run_once: true
|
||||
|
||||
roles:
|
||||
- ../roles/deploy_vm_on_proxmox
|
||||
|
||||
tasks:
|
||||
- name: Make the prompted hostname available to the whole playbook
|
||||
- name: Make the hostname available to the whole playbook
|
||||
ansible.builtin.set_fact:
|
||||
fact_vm_hostname: "{{ vm_hostname }}"
|
||||
|
||||
- name: Make the prompted IP available to the whole playbook
|
||||
- name: Make the OS template available to the whole playbook
|
||||
ansible.builtin.set_fact:
|
||||
fact_vm_os_template: "{{ vm_os_template }}"
|
||||
|
||||
- name: Make the IP available to the whole playbook
|
||||
ansible.builtin.set_fact:
|
||||
fact_vm_ip_address: "{{ vm_ip_address.split('/') | first }}"
|
||||
|
||||
@@ -46,6 +76,7 @@
|
||||
groups: new_host
|
||||
ansible_user: ansible
|
||||
ansible_become_password: "{{ ansible_become_passwd }}"
|
||||
ansible_become_method: "{{ vm_become_method }}"
|
||||
|
||||
|
||||
- name: Configure VM
|
||||
|
||||
@@ -8,6 +8,18 @@
|
||||
- sudo
|
||||
update-cache: true
|
||||
|
||||
- name: Ensure /etc/resolv.conf exists with DNS servers
|
||||
when: (ansible_facts['distribution'] == "Alpine")
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/resolv.conf
|
||||
content: |
|
||||
nameserver 192.168.0.1
|
||||
nameserver 8.8.8.8
|
||||
mode: '0644'
|
||||
owner: root
|
||||
group: root
|
||||
become: true
|
||||
|
||||
# The same commands for Alpine
|
||||
- name: Update and install packages on Alpine
|
||||
when: (ansible_facts['distribution'] == "Alpine")
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
api_token_id: ansible
|
||||
api_token_secret: "{{ proxmox_token_secret }}"
|
||||
|
||||
clone: debian-13-cloud-init-template
|
||||
clone: "{{ vm_os_template }}-cloud-init-template"
|
||||
name: "{{ vm_hostname }}"
|
||||
storage: main
|
||||
format: qcow2
|
||||
|
||||
Reference in New Issue
Block a user