Compare commits
17 Commits
628ca52fe8
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec2a7b5f7d | ||
|
|
8a785c8e19 | ||
|
|
ffe2bbd224 | ||
|
|
8e82c266e7 | ||
|
|
8f97afa26e | ||
|
|
67cf9ef1ae | ||
|
|
45d83d9d26 | ||
|
|
3d2d6a057f | ||
|
|
0ac3dc09c4 | ||
|
|
8d4cd6b3ad | ||
|
|
742878febe | ||
|
|
54c5f00370 | ||
|
|
86460b69f2 | ||
|
|
05dcf8ca20 | ||
|
|
32ac0221d1 | ||
|
|
6820ba29c3 | ||
|
|
6d479e5934 |
9
glusterfs/ansible/deploy_key.yml
Normal file
9
glusterfs/ansible/deploy_key.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
- hosts: bastion
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Set authorized key taken from file
|
||||
ansible.posix.authorized_key:
|
||||
user: clusteruser
|
||||
state: present
|
||||
key: "{{ lookup('file', './files/ansible_key.pub') }}"
|
||||
7
glusterfs/ansible/files/ansible_key
Normal file
7
glusterfs/ansible/files/ansible_key
Normal file
@@ -0,0 +1,7 @@
|
||||
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||
QyNTUxOQAAACCn14U5lXczU3gyBa7x7m1RRgVOHHphBwDQTxvFiZrd9AAAAJikswD/pLMA
|
||||
/wAAAAtzc2gtZWQyNTUxOQAAACCn14U5lXczU3gyBa7x7m1RRgVOHHphBwDQTxvFiZrd9A
|
||||
AAAECqUlHZcmQAUp9+iZH509A3euZ6fL0MME4CC3U91H2EK6fXhTmVdzNTeDIFrvHubVFG
|
||||
BU4cemEHANBPG8WJmt30AAAAEWR1bW15QGV4YW1wbGUuY29tAQIDBA==
|
||||
-----END OPENSSH PRIVATE KEY-----
|
||||
1
glusterfs/ansible/files/ansible_key.pub
Normal file
1
glusterfs/ansible/files/ansible_key.pub
Normal file
@@ -0,0 +1 @@
|
||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKfXhTmVdzNTeDIFrvHubVFGBU4cemEHANBPG8WJmt30 dummy@example.com
|
||||
13
glusterfs/ansible/setup_galery.yml
Normal file
13
glusterfs/ansible/setup_galery.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
|
||||
- hosts: test_server
|
||||
gather_facts: true
|
||||
become: false
|
||||
tasks:
|
||||
- name: Run hostname -a
|
||||
command: hostname -a
|
||||
register: hostname_out
|
||||
|
||||
- name: Show hostname output
|
||||
debug:
|
||||
var: hostname_out.stdout
|
||||
19
glusterfs/inventory/terraform_hosts.ini
Executable file
19
glusterfs/inventory/terraform_hosts.ini
Executable file
@@ -0,0 +1,19 @@
|
||||
# terraform/templates/inventory.yml.tftpl
|
||||
# Auto-generated by Terraform - DO NOT EDIT
|
||||
|
||||
[bastion]
|
||||
Jumphost ansible_host="192.168.178.59"
|
||||
|
||||
|
||||
[test_server]
|
||||
gluster1 ansible_host="10.100.0.3"
|
||||
gluster2 ansible_host="10.100.0.4"
|
||||
gluster3 ansible_host="10.100.0.5"
|
||||
|
||||
[all:vars]
|
||||
ansible_connection=ssh
|
||||
ansible_user=clusteruser
|
||||
ansible_ssh_pass=password
|
||||
|
||||
[test_server:vars]
|
||||
ansible_ssh_common_args='-o ProxyCommand="ssh -i /root/.ssh/ansible_key -W %h:%p -q clusteruser@192.168.178.59"'
|
||||
23
glusterfs/inventory/terraform_hosts.yml
Executable file
23
glusterfs/inventory/terraform_hosts.yml
Executable file
@@ -0,0 +1,23 @@
|
||||
# terraform/templates/inventory.yml.tftpl
|
||||
# Auto-generated by Terraform - DO NOT EDIT
|
||||
all:
|
||||
children:
|
||||
bastion:
|
||||
hosts:
|
||||
bastion:
|
||||
ansible_host: "192.168.178.52"
|
||||
ansible_user: clusteruser
|
||||
test_server:
|
||||
hosts:
|
||||
gluster1:
|
||||
ansible_host: "10.100.0.3"
|
||||
ansible_user: clusteruser
|
||||
ansible_ssh_common_args: "-o ProxyJump=clusteruser@192.168.178.52"
|
||||
gluster2:
|
||||
ansible_host: "10.100.0.5"
|
||||
ansible_user: clusteruser
|
||||
ansible_ssh_common_args: "-o ProxyJump=clusteruser@192.168.178.52"
|
||||
gluster3:
|
||||
ansible_host: "10.100.0.2"
|
||||
ansible_user: clusteruser
|
||||
ansible_ssh_common_args: "-o ProxyJump=clusteruser@192.168.178.52"
|
||||
@@ -1,4 +1,4 @@
|
||||
resource "proxmox_vm_qemu" "cloudinit-test1" {
|
||||
resource "proxmox_vm_qemu" "galera" {
|
||||
for_each = toset(var.hosts)
|
||||
name = "${each.value}"
|
||||
desc = "A test for using terraform and cloudinit"
|
||||
@@ -48,7 +48,7 @@ resource "proxmox_vm_qemu" "cloudinit-test1" {
|
||||
network {
|
||||
id = 0
|
||||
model = "e1000"
|
||||
bridge = var.nic_name
|
||||
bridge = var.nic_name_internal
|
||||
}
|
||||
|
||||
vga {
|
||||
@@ -71,4 +71,6 @@ resource "proxmox_vm_qemu" "cloudinit-test1" {
|
||||
ciuser = "clusteruser"
|
||||
cipassword = "password"
|
||||
ciupgrade = true
|
||||
cicustom = "vendor=oldnasisos:snippets/qemu-guest-agent.yml"
|
||||
|
||||
}
|
||||
7
glusterfs/terraform/inventory.tf
Normal file
7
glusterfs/terraform/inventory.tf
Normal file
@@ -0,0 +1,7 @@
|
||||
resource "local_file" "ansible_inventory" {
|
||||
content = templatefile("${path.module}/templates/inventory.yml.tftpl", {
|
||||
galera_servers = proxmox_vm_qemu.galera
|
||||
bastion = proxmox_vm_qemu.jumphost
|
||||
})
|
||||
filename = "${path.module}/../inventory/terraform_hosts.ini"
|
||||
}
|
||||
81
glusterfs/terraform/jumphost.tf
Normal file
81
glusterfs/terraform/jumphost.tf
Normal file
@@ -0,0 +1,81 @@
|
||||
resource "proxmox_vm_qemu" "jumphost" {
|
||||
name = "Jumphost"
|
||||
desc = "A test for using terraform and cloudinit"
|
||||
|
||||
# Node name has to be the same name as within the cluster
|
||||
# this might not include the FQDN
|
||||
target_node = var.proxmox_host
|
||||
|
||||
# The template name to clone this vm from
|
||||
clone = var.template_name
|
||||
|
||||
# Activate QEMU agent for this VM
|
||||
agent = 1
|
||||
|
||||
os_type = "cloud-init"
|
||||
cpu {
|
||||
cores = 4
|
||||
sockets = 2
|
||||
type = "host"
|
||||
}
|
||||
memory = 2048
|
||||
balloon = 1024
|
||||
scsihw = "virtio-scsi-single"
|
||||
|
||||
# Setup the disk
|
||||
disks {
|
||||
ide {
|
||||
ide3 {
|
||||
cloudinit {
|
||||
storage = "local-lvm"
|
||||
}
|
||||
}
|
||||
}
|
||||
scsi {
|
||||
scsi0 {
|
||||
disk {
|
||||
size = "10G"
|
||||
storage = var.storage_disks
|
||||
discard = true
|
||||
iothread = true
|
||||
# Can't emulate SSDs in virtio
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
network {
|
||||
id = 0
|
||||
model = "e1000"
|
||||
bridge = var.nic_name_external
|
||||
}
|
||||
|
||||
network {
|
||||
id = 1
|
||||
model = "e1000"
|
||||
bridge = var.nic_name_internal
|
||||
}
|
||||
|
||||
vga {
|
||||
type = "virtio"
|
||||
}
|
||||
|
||||
|
||||
startup_shutdown {
|
||||
order = -1
|
||||
shutdown_timeout = -1
|
||||
startup_delay = -1
|
||||
}
|
||||
|
||||
# Setup the ip address using cloud-init.
|
||||
boot = "order=scsi0"
|
||||
# Keep in mind to use the CIDR notation for the ip.
|
||||
ipconfig0 = "ip=dhcp,ip6=dhcp"
|
||||
ipconfig1 = "ip=dhcp,ip6=dhcp"
|
||||
skip_ipv6 = true
|
||||
|
||||
ciuser = "clusteruser"
|
||||
cipassword = "password"
|
||||
ciupgrade = true
|
||||
cicustom = "vendor=oldnasisos:snippets/qemu-guest-agent.yml"
|
||||
}
|
||||
@@ -5,6 +5,10 @@ terraform {
|
||||
source = "telmate/proxmox"
|
||||
version = "3.0.2-rc07"
|
||||
}
|
||||
local = {
|
||||
source = "hashicorp/local"
|
||||
version = "2.7.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
19
glusterfs/terraform/templates/inventory.yml.tftpl
Normal file
19
glusterfs/terraform/templates/inventory.yml.tftpl
Normal file
@@ -0,0 +1,19 @@
|
||||
# terraform/templates/inventory.yml.tftpl
|
||||
# Auto-generated by Terraform - DO NOT EDIT
|
||||
|
||||
[bastion]
|
||||
${bastion.name} ansible_host="${bastion.default_ipv4_address}"
|
||||
|
||||
|
||||
[test_server]
|
||||
%{ for idx, server in galera_servers ~}
|
||||
${server.name} ansible_host="${server.default_ipv4_address}"
|
||||
%{ endfor ~}
|
||||
|
||||
[all:vars]
|
||||
ansible_connection=ssh
|
||||
ansible_user=clusteruser
|
||||
ansible_ssh_pass=password
|
||||
|
||||
[test_server:vars]
|
||||
ansible_ssh_common_args='-o ProxyCommand="ssh -i ./glusterfs/ansible/files/ansible_key -W %h:%p -q clusteruser@${bastion.default_ipv4_address}"'
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"version": 4,
|
||||
"terraform_version": "1.14.6",
|
||||
"serial": 30,
|
||||
"lineage": "d836755f-ecfa-60b3-e3cf-b9c4ab78bfdc",
|
||||
"outputs": {},
|
||||
"resources": [],
|
||||
"check_results": null
|
||||
}
|
||||
@@ -1,283 +0,0 @@
|
||||
{
|
||||
"version": 4,
|
||||
"terraform_version": "1.14.6",
|
||||
"serial": 28,
|
||||
"lineage": "d836755f-ecfa-60b3-e3cf-b9c4ab78bfdc",
|
||||
"outputs": {},
|
||||
"resources": [
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "proxmox_vm_qemu",
|
||||
"name": "cloudinit-test1",
|
||||
"provider": "provider[\"registry.terraform.io/telmate/proxmox\"]",
|
||||
"instances": [
|
||||
{
|
||||
"schema_version": 0,
|
||||
"attributes": {
|
||||
"additional_wait": 5,
|
||||
"agent": 1,
|
||||
"agent_timeout": 90,
|
||||
"args": "",
|
||||
"automatic_reboot": true,
|
||||
"automatic_reboot_severity": "error",
|
||||
"balloon": 1024,
|
||||
"bios": "seabios",
|
||||
"boot": "order=scsi0",
|
||||
"bootdisk": "",
|
||||
"ci_wait": null,
|
||||
"cicustom": null,
|
||||
"cipassword": "password",
|
||||
"ciupgrade": true,
|
||||
"ciuser": "clusteruser",
|
||||
"clone": "ubuntu-cloud-init-template",
|
||||
"clone_id": null,
|
||||
"clone_wait": 10,
|
||||
"cores": 0,
|
||||
"cpu": [
|
||||
{
|
||||
"affinity": "",
|
||||
"cores": 2,
|
||||
"flags": [],
|
||||
"limit": 0,
|
||||
"numa": false,
|
||||
"sockets": 1,
|
||||
"type": "host",
|
||||
"units": 0,
|
||||
"vcores": 0
|
||||
}
|
||||
],
|
||||
"cpu_type": "",
|
||||
"current_node": "pve-testing",
|
||||
"default_ipv4_address": "",
|
||||
"default_ipv6_address": "",
|
||||
"define_connection_info": true,
|
||||
"desc": "A test for using terraform and cloudinit",
|
||||
"description": "Managed by Terraform.",
|
||||
"disk": [],
|
||||
"disks": [
|
||||
{
|
||||
"ide": [
|
||||
{
|
||||
"ide0": [],
|
||||
"ide1": [],
|
||||
"ide2": [],
|
||||
"ide3": [
|
||||
{
|
||||
"cdrom": [],
|
||||
"cloudinit": [
|
||||
{
|
||||
"storage": "local-lvm"
|
||||
}
|
||||
],
|
||||
"disk": [],
|
||||
"ignore": false,
|
||||
"passthrough": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"sata": [],
|
||||
"scsi": [
|
||||
{
|
||||
"scsi0": [
|
||||
{
|
||||
"cdrom": [],
|
||||
"cloudinit": [],
|
||||
"disk": [
|
||||
{
|
||||
"asyncio": "",
|
||||
"backup": true,
|
||||
"cache": "",
|
||||
"discard": true,
|
||||
"emulatessd": false,
|
||||
"format": "raw",
|
||||
"id": 0,
|
||||
"iops_r_burst": 0,
|
||||
"iops_r_burst_length": 0,
|
||||
"iops_r_concurrent": 0,
|
||||
"iops_wr_burst": 0,
|
||||
"iops_wr_burst_length": 0,
|
||||
"iops_wr_concurrent": 0,
|
||||
"iothread": true,
|
||||
"linked_disk_id": -1,
|
||||
"mbps_r_burst": 0,
|
||||
"mbps_r_concurrent": 0,
|
||||
"mbps_wr_burst": 0,
|
||||
"mbps_wr_concurrent": 0,
|
||||
"readonly": false,
|
||||
"replicate": false,
|
||||
"serial": "",
|
||||
"size": "32G",
|
||||
"storage": "local-lvm",
|
||||
"wwn": ""
|
||||
}
|
||||
],
|
||||
"ignore": false,
|
||||
"passthrough": []
|
||||
}
|
||||
],
|
||||
"scsi1": [],
|
||||
"scsi10": [],
|
||||
"scsi11": [],
|
||||
"scsi12": [],
|
||||
"scsi13": [],
|
||||
"scsi14": [],
|
||||
"scsi15": [],
|
||||
"scsi16": [],
|
||||
"scsi17": [],
|
||||
"scsi18": [],
|
||||
"scsi19": [],
|
||||
"scsi2": [],
|
||||
"scsi20": [],
|
||||
"scsi21": [],
|
||||
"scsi22": [],
|
||||
"scsi23": [],
|
||||
"scsi24": [],
|
||||
"scsi25": [],
|
||||
"scsi26": [],
|
||||
"scsi27": [],
|
||||
"scsi28": [],
|
||||
"scsi29": [],
|
||||
"scsi3": [],
|
||||
"scsi30": [],
|
||||
"scsi4": [],
|
||||
"scsi5": [],
|
||||
"scsi6": [],
|
||||
"scsi7": [],
|
||||
"scsi8": [],
|
||||
"scsi9": []
|
||||
}
|
||||
],
|
||||
"virtio": []
|
||||
}
|
||||
],
|
||||
"efidisk": [],
|
||||
"force_create": false,
|
||||
"force_recreate_on_change_of": null,
|
||||
"full_clone": true,
|
||||
"hagroup": "",
|
||||
"hastate": "",
|
||||
"hostpci": [],
|
||||
"hotplug": "network,disk,usb",
|
||||
"id": "pve-testing/qemu/101",
|
||||
"ipconfig0": "ip=dhcp,ip6=dhcp",
|
||||
"ipconfig1": null,
|
||||
"ipconfig10": null,
|
||||
"ipconfig11": null,
|
||||
"ipconfig12": null,
|
||||
"ipconfig13": null,
|
||||
"ipconfig14": null,
|
||||
"ipconfig15": null,
|
||||
"ipconfig2": null,
|
||||
"ipconfig3": null,
|
||||
"ipconfig4": null,
|
||||
"ipconfig5": null,
|
||||
"ipconfig6": null,
|
||||
"ipconfig7": null,
|
||||
"ipconfig8": null,
|
||||
"ipconfig9": null,
|
||||
"kvm": true,
|
||||
"linked_vmid": 0,
|
||||
"machine": "",
|
||||
"memory": 2048,
|
||||
"name": "terraform-test-vm",
|
||||
"nameserver": null,
|
||||
"network": [
|
||||
{
|
||||
"bridge": "vmbr0",
|
||||
"firewall": false,
|
||||
"id": 0,
|
||||
"link_down": false,
|
||||
"macaddr": "bc:24:11:42:9b:07",
|
||||
"model": "e1000",
|
||||
"mtu": 0,
|
||||
"queues": 0,
|
||||
"rate": 0,
|
||||
"tag": 0
|
||||
}
|
||||
],
|
||||
"numa": false,
|
||||
"onboot": null,
|
||||
"os_network_config": null,
|
||||
"os_type": "cloud-init",
|
||||
"pci": [],
|
||||
"pcis": [],
|
||||
"pool": "",
|
||||
"protection": false,
|
||||
"pxe": null,
|
||||
"qemu_os": "other",
|
||||
"reboot_required": false,
|
||||
"rng": [],
|
||||
"scsihw": "virtio-scsi-single",
|
||||
"searchdomain": null,
|
||||
"serial": [],
|
||||
"skip_ipv4": false,
|
||||
"skip_ipv6": true,
|
||||
"smbios": [
|
||||
{
|
||||
"family": "",
|
||||
"manufacturer": "",
|
||||
"product": "",
|
||||
"serial": "",
|
||||
"sku": "",
|
||||
"uuid": "4a4ba40e-3d3f-4b2e-9945-d6725bd771da",
|
||||
"version": ""
|
||||
}
|
||||
],
|
||||
"sockets": 0,
|
||||
"ssh_forward_ip": null,
|
||||
"ssh_host": "",
|
||||
"ssh_port": "22",
|
||||
"ssh_private_key": null,
|
||||
"ssh_user": null,
|
||||
"sshkeys": null,
|
||||
"start_at_node_boot": false,
|
||||
"startup": null,
|
||||
"startup_shutdown": [
|
||||
{
|
||||
"order": -1,
|
||||
"shutdown_timeout": -1,
|
||||
"startup_delay": -1
|
||||
}
|
||||
],
|
||||
"tablet": true,
|
||||
"tags": "",
|
||||
"target_node": "pve-testing",
|
||||
"target_nodes": null,
|
||||
"timeouts": null,
|
||||
"tpm_state": [],
|
||||
"unused_disk": [],
|
||||
"usb": [],
|
||||
"usbs": [],
|
||||
"vcpus": 0,
|
||||
"vga": [
|
||||
{
|
||||
"memory": null,
|
||||
"type": "virtio"
|
||||
}
|
||||
],
|
||||
"vm_state": "running",
|
||||
"vmid": 101
|
||||
},
|
||||
"sensitive_attributes": [
|
||||
[
|
||||
{
|
||||
"type": "get_attr",
|
||||
"value": "cipassword"
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"type": "get_attr",
|
||||
"value": "ssh_private_key"
|
||||
}
|
||||
]
|
||||
],
|
||||
"identity_schema_version": 0,
|
||||
"private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjoxMjAwMDAwMDAwMDAwLCJkZWZhdWx0IjoxMjAwMDAwMDAwMDAwLCJkZWxldGUiOjEyMDAwMDAwMDAwMDAsInJlYWQiOjEyMDAwMDAwMDAwMDAsInVwZGF0ZSI6MTIwMDAwMDAwMDAwMH19"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"check_results": null
|
||||
}
|
||||
@@ -10,10 +10,14 @@ variable "storage_disks" {
|
||||
default = "local-lvm"
|
||||
}
|
||||
|
||||
variable "nic_name" {
|
||||
variable "nic_name_external" {
|
||||
default = "vmbr0"
|
||||
}
|
||||
|
||||
variable "nic_name_internal" {
|
||||
default = "testNet"
|
||||
}
|
||||
|
||||
variable "hosts" {
|
||||
type = list(string)
|
||||
default = ["gluster1", "gluster2", "gluster3"]
|
||||
|
||||
Reference in New Issue
Block a user