Add cloud-init-config support
parent
20a72b0ce9
commit
4296543d12
|
|
@ -0,0 +1,9 @@
|
||||||
|
#cloud-config
|
||||||
|
users:
|
||||||
|
- default
|
||||||
|
- name: ansuser
|
||||||
|
ssh-authorized-keys:
|
||||||
|
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDeDXn6rKQ/E6ND36C9r+04DS78C3d9hpSzcvBbBvCZ7kPEUFVrV0MiLZbBCAaaunIFsQ9hfq2ZlrlDmYLWhaxdtS8VEckJiZarvQ32aLEwFBaW7NwF1i5qyHaz7pL1NPQKHbQ3s7pBrUKotD3yX1yZIXA9RyCCpru1sWxhDRROWgu20FGF6D6Mv3gw9qORdEnrmtqz4ovYVHj3MuzHRVGttDvhrAoXDa66dLrpYaYdLSAjQqtuW0TO+ZTH3YLE7thwmh/QdHuDSD1Bs1r5yYli/CiljyxD2H1Q+wcivYEuc4Pk/B06uKFo+9wLBWVHHTrzsforGY0FQiUO+dX5qZQMhPotL9BUDkJcUNBoUycyuuHnj+REtaMlJChLPXhXGY6l7uczNfOPXCj+AlbK9KTqeAdLH81pJgD0F2F+j+pBtHu5oxQzcAkD+k1t4c+ndWNMO+MADCUOmxFijDr+S3F1aIUL1ixovQ9w6+RxkuPzGCGKnPM/9z+yhZyvZplMk1Bd8oAOqMCZqAfTDzuVl1Te/xq6PoArJ5mtLBoATrFHRsg2J07tJf3USjFIzp20EZiEdePs/slQ8rqOuYqCDKlMXZY0YBObmtVOIMaWKHzqkmO59B+aFDbLgHvwdSaSoqvrTHD4E1F2G3Oz08bo+QK4//4zKdjn1TMKzzg/pQ/idQ== guppy@D11-TP
|
||||||
|
sudo: ['ALL=(ALL) NOPASSWD:ALL']
|
||||||
|
groups: sudo
|
||||||
|
shell: /bin/bash
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
- name: "create VM template"
|
- name: "create VM template"
|
||||||
hosts: pve
|
hosts: pve
|
||||||
remote_user: metal
|
remote_user: ansuser
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
vars:
|
vars:
|
||||||
vm:
|
vm:
|
||||||
|
|
@ -12,12 +12,24 @@
|
||||||
template_memory: 4096
|
template_memory: 4096
|
||||||
template_bridge: vmbr0
|
template_bridge: vmbr0
|
||||||
tasks:
|
tasks:
|
||||||
|
- name: destroy template
|
||||||
|
command: "qm destroy {{ vm.template_id }}"
|
||||||
|
become: yes
|
||||||
|
ignore_errors: true
|
||||||
|
|
||||||
- name : download cloud image
|
- name : download cloud image
|
||||||
get_url:
|
get_url:
|
||||||
url: "{{ vm.cloud_image_url }}"
|
url: "{{ vm.cloud_image_url }}"
|
||||||
dest: "{{ vm.cloud_image_path }}"
|
dest: "{{ vm.cloud_image_path }}"
|
||||||
mode: 0700
|
mode: 0700
|
||||||
|
|
||||||
|
- name : Copy cloud-init-config file
|
||||||
|
copy:
|
||||||
|
src: cloud-init-conf.yml
|
||||||
|
dest: /var/lib/vz/snippets/cloud-init-conf.yml
|
||||||
|
mode: '0700'
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: create a VM to use as a template
|
- name: create a VM to use as a template
|
||||||
command: "qm create {{ vm.template_id }} --name {{ vm.template_name }} --memory {{ vm.template_memory }} --net0 virtio,bridge={{ vm.template_bridge }}"
|
command: "qm create {{ vm.template_id }} --name {{ vm.template_name }} --memory {{ vm.template_memory }} --net0 virtio,bridge={{ vm.template_bridge }}"
|
||||||
become: yes
|
become: yes
|
||||||
|
|
@ -42,6 +54,10 @@
|
||||||
command: "qm set {{ vm.template_id }} --serial0 socket --vga serial0"
|
command: "qm set {{ vm.template_id }} --serial0 socket --vga serial0"
|
||||||
become: yes
|
become: yes
|
||||||
|
|
||||||
|
- name: add cloud-init-config
|
||||||
|
command: 'qm set {{ vm.template_id }} --cicustom "user=local:snippets/cloud-init-conf.yml"'
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: create template
|
- name: create template
|
||||||
command: "qm template {{ vm.template_id }}"
|
command: "qm template {{ vm.template_id }}"
|
||||||
become: yes
|
become: yes
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,7 @@ resource "proxmox_vm_qemu" "control_plane" {
|
||||||
|
|
||||||
# cloud-init settings
|
# cloud-init settings
|
||||||
# adjust the ip and gateway addresses as needed
|
# adjust the ip and gateway addresses as needed
|
||||||
ipconfig0 = "ip=192.168.0.11${count.index}/24,gw=192.168.0.1"
|
ipconfig0 = "ip=192.168.1.1${count.index}/24,gw=192.168.1.254"
|
||||||
sshkeys = file("${var.ssh_key_file}")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "proxmox_vm_qemu" "worker_nodes" {
|
resource "proxmox_vm_qemu" "worker_nodes" {
|
||||||
|
|
@ -60,6 +59,5 @@ resource "proxmox_vm_qemu" "worker_nodes" {
|
||||||
|
|
||||||
# cloud-init settings
|
# cloud-init settings
|
||||||
# adjust the ip and gateway addresses as needed
|
# adjust the ip and gateway addresses as needed
|
||||||
ipconfig0 = "ip=192.168.0.12${count.index}/24,gw=192.168.0.1"
|
ipconfig0 = "ip=192.168.1.2${count.index}/24,gw=192.168.1.254"
|
||||||
sshkeys = file("${var.ssh_key_file}")
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue