Skip to content

Commit

Permalink
cleanup terraform files and added samples
Browse files Browse the repository at this point in the history
  • Loading branch information
NatiSayada committed Oct 2, 2021
1 parent 2cd777e commit 7a83705
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 69 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
testw
terraform/terraform.tfstate
terraform/terraform.tfstate.backup
terraform/.terraform.lock.hcl
inventory/my-cluster/group_vars/all.yml
terraform/vars.tf
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Build a Kubernetes cluster using k3s via Ansible
# Build a Kubernetes cluster using k3s via Ansible and Terraform

Author: <https://github.com/itwars>
Author: <https://github.com/itwars> and <https://github.com/NatiSayada>

## K3s Ansible Playbook

Expand All @@ -20,9 +20,11 @@ on processor architecture:

Deployment environment must have Ansible 2.4.0+
Master and nodes must have passwordless SSH access
Terraform installed
Proxmox server

## Usage

Rename the file `terraform/vars.sample` to `terraform/vars.tf` and update the user and password.
First create a new directory based on the `sample` directory within the `inventory` directory:

```bash
Expand Down
54 changes: 0 additions & 54 deletions terraform/appch-install.yml

This file was deleted.

18 changes: 7 additions & 11 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,18 @@ terraform {
}

provider "proxmox" {
pm_api_url = "https://192.168.3.102:8006/api2/json"
pm_api_url = "https://${var.proxmox-host}:8006/api2/json"
pm_user = "root@pam"
pm_password = "Xx7437338"
pm_password = var.password
pm_tls_insecure = "true"
pm_parallel = 10
}

variable "pvt_key" {
default = "~/.ssh/proxk3s"
}

resource "proxmox_vm_qemu" "proxmox_vm_master" {
count = 1
count = "${var.num_k3s_masters}"
name = "k3s-master-${count.index}"
target_node = "pve"
clone = "ubuntu-2004-cloudinit-template"
clone = "${var.tamplate_vm_name}"
os_type = "cloud-init"
agent = 1
memory = "2048"
Expand All @@ -42,10 +38,10 @@ resource "proxmox_vm_qemu" "proxmox_vm_master" {
}

resource "proxmox_vm_qemu" "proxmox_vm_workers" {
count = 4
count = "${var.num_k3s_nodes}"
name = "k3s-worker-${count.index}"
target_node = "pve"
clone = "ubuntu-2004-cloudinit-template"
clone = "${var.tamplate_vm_name}"
os_type = "cloud-init"
agent = 1
memory = "4096"
Expand All @@ -57,7 +53,7 @@ resource "proxmox_vm_qemu" "proxmox_vm_workers" {
connection {
host = self.default_ipv4_address
type = "ssh"
user = "nsayada"
user = "${var.username}"
private_key = file(var.pvt_key)
}
}
Expand Down
11 changes: 11 additions & 0 deletions terraform/vars.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable "username" {
description = "The username for the DB master user"
type = string
sensitive = false

}
variable "password" {
description = "The password for the DB master user"
type = string
sensitive = true
}

0 comments on commit 7a83705

Please sign in to comment.