configure cloud-init to setup dns and install lvm2 at startup
also fix terminfo konsole-color-256
This commit is contained in:
parent
5c964ae09d
commit
e2d7f0c7ab
0
base/images/.gitkeep
Normal file
0
base/images/.gitkeep
Normal file
3
env.sh
Executable file
3
env.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
export LIBVIRT_DEFAULT_URI="qemu+tcp://dx30.localdomain/system"
|
@ -1,25 +0,0 @@
|
||||
#cloud-config
|
||||
# vim: syntax=yaml
|
||||
|
||||
# ***********************
|
||||
# ---- documentation :
|
||||
# ---> https://cloudinit.readthedocs.io/en/latest/topics/examples.html
|
||||
# ******************************
|
||||
|
||||
ssh_pwauth: False
|
||||
chpasswd:
|
||||
expire: False
|
||||
|
||||
groups:
|
||||
- whell: [antoine]
|
||||
|
||||
users:
|
||||
# - name: root
|
||||
# lock_passwd: false
|
||||
# password: $1$SaltSalt$.SBI7klTdiInUnDK0/40g.
|
||||
- name: antoine
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCuLVDINxqYow17v9oovyqG3Ok5mOa36U3f+D7CtY8cS7jZavx7A6h2DAtlNzzJl3AxRtk3JY1rmV2fhwB+lVA1S8WT61/qHZH+smjbt6YCp6/ICMKPR8tKtbFUnXn+o9tAhqa7cryWs2LerJasXaSUUguIb6Lr0teSM6enzmtNShjiUta+6HlN+M91n/tp4pjn+tvNUSFETg1JVX1DIG/6U43N8V+fu6xsN5ceoPNGpBpikP0ZYmKYdcPMqqcWJkkaLGwh/u4R98BUVSPor/OFaMw3IZ6Nr7yCdWPCe/8SvEkbd2iMQm5dQjqEFEJUyPwoE18lfM2VnVwlaKsFN9Cmu2J5H4w9qlkZCSGkLa6eckJ3dOHDf6PZO409jbU7sV5rEspuo4gWqEzx5l2YKnASxhy+hylCj+sYrgMcEo9XMVSSYgj5ynykr3LyxyaFklZEuVxXJUYrOVcVIRdkJu9cVnhj6LvaUHY1JqdbhOAjPpSIVqKLPUYJIMU5nVKOh53Dd/rXdOx6BQXiA44DGuvYvHMohK7rXA92Sau0Hbb30DDMkPSPDXknIB+anELGCCx6j8HC38FzJyqtvtrDsG6sc/D3UQGApAS0+O6FXeH+v2OiPhJjdQMwNl5YMrJt6AUBVZZAZtFgUlhhZXRbyhuUuhmWYmzsNbWX7N5pzgYPyQ== antoine@archlinux
|
||||
sudo: ['ALL=(ALL) NOPASSWD:ALL']
|
||||
shell: /bin/bash
|
||||
groups: wheel
|
22
stack/cloud_init.tf
Normal file
22
stack/cloud_init.tf
Normal file
@ -0,0 +1,22 @@
|
||||
data "template_file" "user_data" {
|
||||
template = "${file("${path.module}/cloud_init_user_data.yml")}"
|
||||
vars = {
|
||||
hostname = var.hostname
|
||||
}
|
||||
}
|
||||
|
||||
data "template_file" "meta_data" {
|
||||
template = "${file("${path.module}/cloud_init_meta_data.yml")}"
|
||||
vars = {
|
||||
dns_address = var.dns_address
|
||||
dns_domain = var.dns_domain
|
||||
}
|
||||
}
|
||||
|
||||
# Use CloudInit to add the instance
|
||||
resource "libvirt_cloudinit_disk" "commoninit" {
|
||||
name = "commoninit.iso"
|
||||
pool = var.pool_1
|
||||
user_data = data.template_file.user_data.rendered
|
||||
meta_data = data.template_file.meta_data.rendered
|
||||
}
|
8
stack/cloud_init_meta_data.yml
Normal file
8
stack/cloud_init_meta_data.yml
Normal file
@ -0,0 +1,8 @@
|
||||
#cloud-config
|
||||
# vim: syntax=yaml
|
||||
|
||||
network-interfaces: |
|
||||
auto eth0
|
||||
iface eth0 inet dhcp
|
||||
dns-nameservers ${dns_address}
|
||||
dns-search ${dns_domain}
|
109
stack/cloud_init_user_data.yml
Normal file
109
stack/cloud_init_user_data.yml
Normal file
@ -0,0 +1,109 @@
|
||||
#cloud-config
|
||||
# vim: syntax=yaml
|
||||
|
||||
# ***********************
|
||||
# ---- documentation :
|
||||
# ---> https://cloudinit.readthedocs.io/en/latest/topics/examples.html
|
||||
# ---> https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html#datasource-nocloud
|
||||
# ******************************
|
||||
|
||||
hostname: ${hostname}
|
||||
fqdn: ${hostname}.localdomain
|
||||
manage_etc_hosts: True
|
||||
ssh_pwauth: False
|
||||
|
||||
chpasswd:
|
||||
expire: False
|
||||
list: |
|
||||
antoine:$6$cBJRa6ajXZAg4q0b$vvNhFRkk9vizUj1b/KYO.wG3BxWH779BJOBzSWsmBTp6XHTZd9.NrdYEYuqBrAw.QIxY32gtLxuxwmPTZfLDb/
|
||||
# password is generated with : mkpasswd --method=SHA-512 --rounds=4096
|
||||
|
||||
users:
|
||||
- name: antoine
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCuLVDINxqYow17v9oovyqG3Ok5mOa36U3f+D7CtY8cS7jZavx7A6h2DAtlNzzJl3AxRtk3JY1rmV2fhwB+lVA1S8WT61/qHZH+smjbt6YCp6/ICMKPR8tKtbFUnXn+o9tAhqa7cryWs2LerJasXaSUUguIb6Lr0teSM6enzmtNShjiUta+6HlN+M91n/tp4pjn+tvNUSFETg1JVX1DIG/6U43N8V+fu6xsN5ceoPNGpBpikP0ZYmKYdcPMqqcWJkkaLGwh/u4R98BUVSPor/OFaMw3IZ6Nr7yCdWPCe/8SvEkbd2iMQm5dQjqEFEJUyPwoE18lfM2VnVwlaKsFN9Cmu2J5H4w9qlkZCSGkLa6eckJ3dOHDf6PZO409jbU7sV5rEspuo4gWqEzx5l2YKnASxhy+hylCj+sYrgMcEo9XMVSSYgj5ynykr3LyxyaFklZEuVxXJUYrOVcVIRdkJu9cVnhj6LvaUHY1JqdbhOAjPpSIVqKLPUYJIMU5nVKOh53Dd/rXdOx6BQXiA44DGuvYvHMohK7rXA92Sau0Hbb30DDMkPSPDXknIB+anELGCCx6j8HC38FzJyqtvtrDsG6sc/D3UQGApAS0+O6FXeH+v2OiPhJjdQMwNl5YMrJt6AUBVZZAZtFgUlhhZXRbyhuUuhmWYmzsNbWX7N5pzgYPyQ== antoine@archlinux
|
||||
sudo: ["ALL=(ALL) NOPASSWD:ALL"]
|
||||
shell: /bin/bash
|
||||
groups: wheel
|
||||
write_files:
|
||||
- path: /dumb.info
|
||||
owner: root:root
|
||||
permissions: "0755"
|
||||
content: |
|
||||
konsole-256color|KDE console window with xterm 256-colors,
|
||||
OTbs, am, bce, mir, msgr, npc, xenl, AX, XT,
|
||||
colors#0x100, cols#80, it#8, lines#24, pairs#0x10000,
|
||||
acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
|
||||
blink=\E[5m, bold=\E[1m, civis=\E[?25l, clear=\E[H\E[2J,
|
||||
cnorm=\E[?25h, cr=\r, csr=\E[%i%p1%d;%p2%dr,
|
||||
cub=\E[%p1%dD, cub1=^H, cud=\E[%p1%dB, cud1=\n,
|
||||
cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
|
||||
cuu=\E[%p1%dA, cuu1=\E[A, dch=\E[%p1%dP, dch1=\E[P,
|
||||
dim=\E[2m, dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J,
|
||||
el=\E[K, enacs=\E)0, flash=\E[?5h$<100/>\E[?5l,
|
||||
home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, il=\E[%p1%dL,
|
||||
il1=\E[L, ind=\n, indn=\E[%p1%dS, invis=\E[8m,
|
||||
is2=\E[m\E[?7h\E[4l\E>\E7\E[r\E[?1;3;4;6l\E8,
|
||||
kDC=\E[3;2~, kEND=\E[1;2F, kHOM=\E[1;2H, kIC=\E[2;2~,
|
||||
kLFT=\E[1;2D, kNXT=\E[6;2~, kPRV=\E[5;2~, kRIT=\E[1;2C,
|
||||
kbs=^?, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC,
|
||||
kcuu1=\EOA, kdch1=\E[3~, kend=\EOF, kf1=\EOP, kf10=\E[21~,
|
||||
kf11=\E[23~, kf12=\E[24~, kf13=\EO2P, kf14=\EO2Q,
|
||||
kf15=\EO2R, kf16=\EO2S, kf17=\E[15;2~, kf18=\E[17;2~,
|
||||
kf19=\E[18;2~, kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~,
|
||||
kf22=\E[21;2~, kf23=\E[23;2~, kf24=\E[24;2~, kf25=\EO5P,
|
||||
kf26=\EO5Q, kf27=\EO5R, kf28=\EO5S, kf29=\E[15;5~,
|
||||
kf3=\EOR, kf30=\E[17;5~, kf31=\E[18;5~, kf32=\E[19;5~,
|
||||
kf33=\E[20;5~, kf34=\E[21;5~, kf35=\E[23;5~,
|
||||
kf36=\E[24;5~, kf37=\EO6P, kf38=\EO6Q, kf39=\EO6R,
|
||||
kf4=\EOS, kf40=\EO6S, kf41=\E[15;6~, kf42=\E[17;6~,
|
||||
kf43=\E[18;6~, kf44=\E[19;6~, kf45=\E[20;6~,
|
||||
kf46=\E[21;6~, kf47=\E[23;6~, kf48=\E[24;6~, kf49=\EO3P,
|
||||
kf5=\E[15~, kf50=\EO3Q, kf51=\EO3R, kf52=\EO3S,
|
||||
kf53=\E[15;3~, kf54=\E[17;3~, kf55=\E[18;3~,
|
||||
kf56=\E[19;3~, kf57=\E[20;3~, kf58=\E[21;3~,
|
||||
kf59=\E[23;3~, kf6=\E[17~, kf60=\E[24;3~, kf61=\EO4P,
|
||||
kf62=\EO4Q, kf63=\EO4R, kf7=\E[18~, kf8=\E[19~, kf9=\E[20~,
|
||||
khome=\EOH, kich1=\E[2~, kind=\E[1;2B, kmous=\E[<,
|
||||
knp=\E[6~, kpp=\E[5~, kri=\E[1;2A, meml=\El, memu=\Em,
|
||||
op=\E[39;49m, rc=\E8, rev=\E[7m, ri=\EM, rin=\E[%p1%dT,
|
||||
ritm=\E[23m, rmacs=^O, rmam=\E[?7l,
|
||||
rmcup=\E[2J\E[?47l\E8, rmir=\E[4l, rmkx=\E[?1l\E>,
|
||||
rmso=\E[27m, rmul=\E[24m, rs1=\Ec,
|
||||
rs2=\E7\E[r\E8\E[m\E[?7h\E[?1;3;4;6l\E[4l\E>\E[?1000l\E[?25h,
|
||||
sc=\E7,
|
||||
setab=\E[%?%p1%%{8}%<%t4%p1%d%e%p1%%{16}%<%t10%p1%%{8}%-%d%e48;5;%p1%d%;m,
|
||||
setaf=\E[%?%p1%%{8}%<%t3%p1%d%e%p1%%{16}%<%t9%p1%%{8}%-%d%e38;5;%p1%d%;m,
|
||||
sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p5%t;2%;%?%p7%t;8%;m%?%p9%t\016%e\017%;,
|
||||
sgr0=\E[0m\017, sitm=\E[3m, smacs=^N, smam=\E[?7h,
|
||||
smcup=\E7\E[?47h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m,
|
||||
smul=\E[4m, tbc=\E[3g, u6=\E[%i%d;%dR, u7=\E[6n,
|
||||
u8=\E[?1;2c, u9=\E[c, vpa=\E[%i%p1%dd,
|
||||
XM=\E[?1006;1000%?%p1%%{1}%=%th%el%;, kDC3=\E[3;3~,
|
||||
kDC4=\E[3;4~, kDC5=\E[3;5~, kDC6=\E[3;6~, kDC7=\E[3;7~,
|
||||
kDN=\E[1;2B, kDN3=\E[1;3B, kDN4=\E[1;4B, kDN5=\E[1;5B,
|
||||
kDN6=\E[1;6B, kDN7=\E[1;7B, kEND3=\E[1;3F, kEND4=\E[1;4F,
|
||||
kEND5=\E[1;5F, kEND6=\E[1;6F, kEND7=\E[1;7F,
|
||||
kHOM3=\E[1;3H, kHOM4=\E[1;4H, kHOM5=\E[1;5H,
|
||||
kHOM6=\E[1;6H, kHOM7=\E[1;7H, kIC3=\E[2;3~, kIC4=\E[2;4~,
|
||||
kIC5=\E[2;5~, kIC6=\E[2;6~, kIC7=\E[2;7~, kLFT3=\E[1;3D,
|
||||
kLFT4=\E[1;4D, kLFT5=\E[1;5D, kLFT6=\E[1;6D,
|
||||
kLFT7=\E[1;7D, kNXT3=\E[6;3~, kNXT4=\E[6;4~,
|
||||
kNXT5=\E[6;5~, kNXT6=\E[6;6~, kNXT7=\E[6;7~,
|
||||
kPRV3=\E[5;3~, kPRV4=\E[5;4~, kPRV5=\E[5;5~,
|
||||
kPRV6=\E[5;6~, kPRV7=\E[5;7~, kRIT3=\E[1;3C,
|
||||
kRIT4=\E[1;4C, kRIT5=\E[1;5C, kRIT6=\E[1;6C,
|
||||
kRIT7=\E[1;7C, kUP=\E[1;2A, kUP3=\E[1;3A, kUP4=\E[1;4A,
|
||||
kUP5=\E[1;5A, kUP6=\E[1;6A, kUP7=\E[1;7A, rmxx=\E[29m,
|
||||
smxx=\E[9m, xm=\E[<%i%p3%d;%p1%d;%p2%d;%?%p4%tM%em%;,
|
||||
runcmd:
|
||||
- sudo -u root tic -x /dumb.info
|
||||
- sudo -u antoine tic -x /dumb.info
|
||||
- sudo apt -y install lvm2
|
||||
|
||||
# take too long and block vm startup
|
||||
# alias for apt update upgrade
|
||||
# package_update: true
|
||||
# package_upgrade: true
|
||||
# packages:
|
||||
# - lvm2
|
@ -21,9 +21,9 @@ resource "libvirt_domain" "db1" {
|
||||
volume_id = libvirt_volume.my_root_debian.id
|
||||
}
|
||||
|
||||
# disk {
|
||||
# volume_id = libvirt_volume.external_disk_1.id
|
||||
# }
|
||||
disk {
|
||||
volume_id = libvirt_volume.external_disk_1.id
|
||||
}
|
||||
|
||||
cloudinit = libvirt_cloudinit_disk.commoninit.id
|
||||
|
||||
|
@ -24,35 +24,6 @@ provider "libvirt" {
|
||||
uri = "qemu+tcp://dx30.localdomain/system"
|
||||
}
|
||||
|
||||
data "template_file" "user_data" {
|
||||
template = "${file("${path.module}/cloud_init.cfg")}"
|
||||
}
|
||||
|
||||
variable "pool_1" {
|
||||
type = string
|
||||
default = "pool_1"
|
||||
description = "already created pool name, set with variable because libvirt provider dont' wotk with data resource"
|
||||
}
|
||||
|
||||
variable "debian_buster_qcow2" {
|
||||
type = string
|
||||
default = "debian-buster.qcow2"
|
||||
description = "already created debian vol, set with variable because libvirt provider dont' wotk with data resource"
|
||||
}
|
||||
|
||||
variable "centos7_qcow2" {
|
||||
type = string
|
||||
default = "centos7.qcow2"
|
||||
description = "already created centos vol, set with variable because libvirt provider dont' wotk with data resource"
|
||||
}
|
||||
|
||||
# Use CloudInit to add the instance
|
||||
resource "libvirt_cloudinit_disk" "commoninit" {
|
||||
name = "commoninit.iso"
|
||||
pool = var.pool_1
|
||||
user_data = data.template_file.user_data.rendered
|
||||
}
|
||||
|
||||
resource "null_resource" "delay_10s" {
|
||||
provisioner "local-exec" {
|
||||
command = "sleep 10"
|
||||
|
41
stack/variable.tf
Normal file
41
stack/variable.tf
Normal file
@ -0,0 +1,41 @@
|
||||
variable "ip" {
|
||||
type = string
|
||||
default = "10.17.3.35/"
|
||||
description = "fixed ip address for compute"
|
||||
}
|
||||
|
||||
variable "hostname" {
|
||||
type = string
|
||||
default = "compute-1"
|
||||
description = "compute hostname"
|
||||
}
|
||||
|
||||
variable "dns_domain" {
|
||||
type = string
|
||||
default = "localdomain"
|
||||
description = "dns domain name"
|
||||
}
|
||||
|
||||
variable "dns_address" {
|
||||
type = string
|
||||
default = "100.64.0.17"
|
||||
description = "dns ip address"
|
||||
}
|
||||
|
||||
variable "pool_1" {
|
||||
type = string
|
||||
default = "pool_1"
|
||||
description = "already created pool name, set with variable because libvirt provider dont' wotk with data resource"
|
||||
}
|
||||
|
||||
variable "debian_buster_qcow2" {
|
||||
type = string
|
||||
default = "debian-buster.qcow2"
|
||||
description = "already created debian vol, set with variable because libvirt provider dont' wotk with data resource"
|
||||
}
|
||||
|
||||
variable "centos7_qcow2" {
|
||||
type = string
|
||||
default = "centos7.qcow2"
|
||||
description = "already created centos vol, set with variable because libvirt provider dont' wotk with data resource"
|
||||
}
|
Loading…
Reference in New Issue
Block a user