add ntp s2

Signed-off-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
This commit is contained in:
Frank Villaro-Dixon 2024-06-17 18:46:12 +02:00
parent 70f8d73bd3
commit 7edbb191da
6 changed files with 139 additions and 0 deletions

View file

@ -1,4 +1,7 @@
pi:
hosts:
192.168.10.155: #chronos.k3s.fr:
vms:
hosts:
192.168.43.15: #ntp-s2.lan.k3s.fr

25
tf/.terraform.lock.hcl Normal file
View file

@ -0,0 +1,25 @@
# This file is maintained automatically by "tofu init".
# Manual edits may be lost in future updates.
provider "registry.opentofu.org/bpg/proxmox" {
version = "0.58.1"
constraints = "0.58.1"
hashes = [
"h1:jxrdhJ0SzIFzQlRFQfjifgFj0tqiQKqk+Nmst7hZ9C8=",
"zh:0c2b3ca3fd2e4eb6a6c4ad075070e4ba6bda74cafb66fb6d455c9496bdf45a46",
"zh:105dbec8e113d38d96fdb675435feb72742c10c9a74d60f065a2be9fd30b0968",
"zh:4156dd5d6bb556cc38dbe9ff901aa142782e1ca6986174286cc9d0ad0048084b",
"zh:4686d9282594b8f1bb431324711e920aa52040570284850b12421bbd94997f99",
"zh:6722fe648db670f91436d125cddd95607b32d2c99c20bfd4d5246e6aaac7cd0f",
"zh:71f86709b0b9b6b0113267c577175418d2171e661d9d0550833db771b260faae",
"zh:998ae52b8914d8d96f6d62015e8437402ccab49b8a41e16fdfec2fdb69b18be8",
"zh:a2568b155494ae908d134cf5673eddcb816337705585e3689391334828514a8b",
"zh:a3d16ccbd8997aaca938bdc2ef389439d8cb2046457dfc2a413958d6cba4f161",
"zh:c50737b963f3db6544c993e2b589f15e1259ff62373302647a829ca7b92a9c9b",
"zh:c9296aab2d0459317fd7c7d779b820cd9dd5241000bab22027c8cea83a683bfe",
"zh:cd57945822c97e1037c9256eb0a314b99c3b93a996fb234a85a78e52dc09e0cc",
"zh:e18024ac0bcc3a618c3c3f7f3ebe1376c0c0eae9defa06367d9ed7c5f984b391",
"zh:e33c5fd3940c0c64fde79b5b67a46a1f681266294ead074e94a581ecd6008ddb",
"zh:f26e0763dbe6a6b2195c94b44696f2110f7f55433dc142839be16b9697fa5597",
]
}

30
tf/cloud-init.tpl.cfg Normal file
View file

@ -0,0 +1,30 @@
#cloud-config
hostname: ${hostname}
disable_root: false
ssh_pwauth: true
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQChSPXfIMvZHaK6c1mDNubZCNuR+908kzJGqQhhZ0kzjL3Gh/rdLVLBSEael2pEJeuSSA6ADHz/AneQnXqLLod1wHtirq9yspyjTRmEWNXiWI5giZ0Mz/twe4wMpBDZ8YX8XM0zxWhyzoidLI/yomA63s30v0UyzmUesSfRwHQJ3Md56pA0ZEomdMH97sNdgMOjlUlyAFdwuK8zVkbeCdbT/eCHM28PCT366KOOJfoaGQpVagIkrUBXjEvOIjnMAxy3gqfJ8kS/iFxDgws3m5o93Pm+WdWdcPLf/ir9NUwPt8l2GV2lCapWFnMC8ZqgdvTxlFikBZaTss8rO8SKB5QkG6eoypsbIaK9GGnRgOM/zGdX7e5rVW1N1Y6O8qoykuY9EQykN4Y48h1q/aGD6HGuxqeP9cqD4HUJyL9K62D3k8At6KO2BLCKbp5hPZ5tvHgfQK2ARa0rR5L/m08Hxac6qI2JDdWTa4XJnJj9+F/D7pYRZ/tzrYwMy+nTXarC5/JDsuC9sv5MR1vcjSuzjLB0iPjZnp7Tm6hszHy7D8qOZiHJdPh7s4/I3+Zj7mCaG3bRREvIgqAW1ZP+E2ZFuAM4lUL8e2Xu3LmyLOk+hrvovDc+SAplS6FJxLGJDfpFAcCgaGY6WPi8ETCClfxcdQxnejs2SNAmcRIUHw70keKHgQ== cardno:000606708696
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDDEEf2vpLMXa2o9tA3xeoPWMZ0Dk1MjIV9AOPyKT4Gi8jSovEnN+Hu1FQhODLkRx+CGkD5dV9rirbL6yD4BC9vNXoO2FeQpgRPAl1WkMpmg+AvVmroOUlsiNYCQL/F/yIAGwXiIo4mWTcsYDNngnlFkmqWzjaUG1VltmVOJtN+YVYvMj5ak/NYnFQIF7UsUZ/TRmQ9pvej2Yw001crhqe7SUfCYinJL/ynBmT/pXnd2hKJR5JSQl9uqBpsOFhPBUuShKjOMH+zc/6aM/MNEPNBnstvykztht6t4u8umu7LujcfWotwccz8rBhDSU6sIii0hbzxIeNWcM2pvNp/YtqmpEXpDJ8Yz8ffQY92lreR6picfvkqkoR+RA2uhMGP0VzajWCLPYQAHFmWOZIba6PpvJ5bkTSM+IA8U5dtBJ7l9D4vCKhUeybZUHTKL3hwxpaumu75giszKtZ15SA76QhZ5fLz+AuG2LdQwgnEgcdgLmrXXGi3/SOhvj5O9JGkrt5dIJHNo1sADulqhCLXjurlE2I55j2SloLmpduVKTUSD+OC0iTqIwzn8Sk6VVgSYfrUoZs7ySmFKG4SH+2iAcatj3z6r45y6eGqGaLdkeSFRlA6PJPuI85p6Fc44NxOEFae5wXV/G9nWHsnfZYv8cr73gaIo4duUg7fqmdjJ8BeDw== frank-key-rsa
network:
{config: disabled}
write_files:
- path: /etc/netplan/config.yaml
permissions: '0644'
content: |
network:
version: 2
ethernets:
ens18:
addresses: [ ${ipv4_addr_cidr} ]
gateway4: ${ipv4_gw}
nameservers:
addresses: [ 192.168.21.254, 192.168.43.254 ]
dhcp4: false
runcmd:
# cradofix pour l'interface qui ne monte pas
- netplan apply
- apt update
- apt install -y qemu-guest-agent
- systemctl start qemu-guest-agent.service

52
tf/ntp.tf Normal file
View file

@ -0,0 +1,52 @@
resource "proxmox_virtual_environment_file" "this" {
content_type = "snippets"
datastore_id = "local"
node_name = var.proxmox_node_name
source_raw {
data = templatefile("${path.module}/cloud-init.tpl.cfg", {
hostname = "ntp-s2",
ipv4_addr_cidr = "192.168.43.15/24"
ipv4_gw = "192.168.43.254"
})
file_name = "ntp-s2.cloud-config.yaml"
}
}
resource "proxmox_virtual_environment_vm" "this" {
name = "ntp-s2"
description = "Managed by Terraform"
started = true
on_boot = true
node_name = var.proxmox_node_name
vm_id = var.proxmox_vmid
cpu {
cores = 1
}
memory {
dedicated = 512
}
agent {
enabled = true
}
disk {
datastore_id = "local-lvm"
file_format = "qcow2"
interface = "scsi0"
file_id = "local:iso/noble-server-cloudimg-amd64.img"
size = "20"
}
initialization {
user_data_file_id = proxmox_virtual_environment_file.this.id
datastore_id = "local-lvm"
}
network_device {
bridge = "vmbr0"
}
}

19
tf/providers.tf Normal file
View file

@ -0,0 +1,19 @@
terraform {
required_providers {
proxmox = {
source = "bpg/proxmox"
version = "0.58.1"
}
}
}
provider "proxmox" {
insecure = true
endpoint = "https://proxmox-cessy.lan.k3s.fr:8006/"
ssh {
agent = true
}
}

10
tf/vars.tf Normal file
View file

@ -0,0 +1,10 @@
variable "proxmox_node_name" {
type = string
default = "n00"
}
variable "proxmox_vmid" {
type = number
default = 150
}