Compare commits
2 Commits
628ca52fe8
...
6820ba29c3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6820ba29c3 | ||
|
|
6d479e5934 |
19
glusterfs/ansible/setup_galery.yml
Normal file
19
glusterfs/ansible/setup_galery.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- hosts: glusterfs
|
||||||
|
gather_facts: true
|
||||||
|
become: false
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: "Install GlusterFS on all nodes"
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: glusterfs-server
|
||||||
|
state: present
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: "Start and enable GlusterFS service"
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: glusterd
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
become: true
|
||||||
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)
|
for_each = toset(var.hosts)
|
||||||
name = "${each.value}"
|
name = "${each.value}"
|
||||||
desc = "A test for using terraform and cloudinit"
|
desc = "A test for using terraform and cloudinit"
|
||||||
@@ -48,7 +48,7 @@ resource "proxmox_vm_qemu" "cloudinit-test1" {
|
|||||||
network {
|
network {
|
||||||
id = 0
|
id = 0
|
||||||
model = "e1000"
|
model = "e1000"
|
||||||
bridge = var.nic_name
|
bridge = var.nic_name_internal
|
||||||
}
|
}
|
||||||
|
|
||||||
vga {
|
vga {
|
||||||
@@ -71,4 +71,6 @@ resource "proxmox_vm_qemu" "cloudinit-test1" {
|
|||||||
ciuser = "clusteruser"
|
ciuser = "clusteruser"
|
||||||
cipassword = "password"
|
cipassword = "password"
|
||||||
ciupgrade = true
|
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.yml"
|
||||||
|
}
|
||||||
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"
|
source = "telmate/proxmox"
|
||||||
version = "3.0.2-rc07"
|
version = "3.0.2-rc07"
|
||||||
}
|
}
|
||||||
|
local = {
|
||||||
|
source = "hashicorp/local"
|
||||||
|
version = "2.7.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
glusterfs/terraform/templates/inventory.yml.tftpl
Normal file
17
glusterfs/terraform/templates/inventory.yml.tftpl
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# terraform/templates/inventory.yml.tftpl
|
||||||
|
# Auto-generated by Terraform - DO NOT EDIT
|
||||||
|
all:
|
||||||
|
children:
|
||||||
|
bastion:
|
||||||
|
hosts:
|
||||||
|
bastion:
|
||||||
|
ansible_host: "${bastion.default_ipv4_address}"
|
||||||
|
ansible_user: clusteruser
|
||||||
|
test_server:
|
||||||
|
hosts:
|
||||||
|
%{ for idx, server in galera_servers ~}
|
||||||
|
${server.name}:
|
||||||
|
ansible_host: "${server.default_ipv4_address}"
|
||||||
|
ansible_user: clusteruser
|
||||||
|
ansible_ssh_common_args: "-o ProxyJump=clusteruser@${bastion.default_ipv4_address}"
|
||||||
|
%{ endfor ~}
|
||||||
@@ -10,10 +10,14 @@ variable "storage_disks" {
|
|||||||
default = "local-lvm"
|
default = "local-lvm"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "nic_name" {
|
variable "nic_name_external" {
|
||||||
default = "vmbr0"
|
default = "vmbr0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "nic_name_internal" {
|
||||||
|
default = "testNet"
|
||||||
|
}
|
||||||
|
|
||||||
variable "hosts" {
|
variable "hosts" {
|
||||||
type = list(string)
|
type = list(string)
|
||||||
default = ["gluster1", "gluster2", "gluster3"]
|
default = ["gluster1", "gluster2", "gluster3"]
|
||||||
|
|||||||
Reference in New Issue
Block a user