Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOPS-102 Generate Ansible Inventory #61

Merged
merged 87 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
f7063a2
feat: Added module example
aaronsaderholm Jul 1, 2021
2c5184e
fix: renamed modules
aaronsaderholm Jul 1, 2021
8a7323d
fix: moved provider location?
aaronsaderholm Jul 1, 2021
463a78e
fix: init --migrate
aaronsaderholm Jul 1, 2021
d50ee69
fix: how did this get rolled back?
aaronsaderholm Jul 1, 2021
225e0a3
fix: aaaaa
aaronsaderholm Jul 1, 2021
ec80db5
fix: blocks ?
aaronsaderholm Jul 1, 2021
d7ea911
fix: blocks ?
aaronsaderholm Jul 1, 2021
ec6f1ad
fix: blocks ?
aaronsaderholm Jul 1, 2021
9dfed10
fix: remove dhcp.tf for now
aaronsaderholm Jul 1, 2021
6bf1829
fix: testing changes
aaronsaderholm Jul 1, 2021
2c5e7c2
feat: qemu-kvm module
aaronsaderholm Jul 1, 2021
5c367b0
fix: rip forgot provisioner block
aaronsaderholm Jul 1, 2021
5011d59
fix: type in node config
aaronsaderholm Jul 1, 2021
967d530
fix: type in node config
aaronsaderholm Jul 1, 2021
79c1ed6
fix: type in node config
aaronsaderholm Jul 1, 2021
baf4397
feat: more vm params set now
aaronsaderholm Jul 1, 2021
eb0131b
fix: int -> number
aaronsaderholm Jul 1, 2021
ab00d8f
fix: Added 'G' to disk, 4096 ram for example VM.
aaronsaderholm Jul 1, 2021
bd52608
fix: disable qemu for now
aaronsaderholm Jul 1, 2021
8aaedb0
merge: main into dev branch
aaronsaderholm Jul 5, 2021
81df9c4
Introduce the common config (#40)
claughinghouse Jul 3, 2021
191f968
Merge branch 'terraform-module-refactor' into aaron-dev
aaronsaderholm Jul 5, 2021
8e6785d
Use forked Proxmox API and Terraform provider with HA container suppo…
yesrod Jul 6, 2021
c36b11c
Switch to upstream repos (#45)
yesrod Jul 8, 2021
f9250c1
Possibly fix builds? (#46)
yesrod Jul 10, 2021
1e02e6e
Only run create, Ansible, destroy on main branch
yesrod Jul 17, 2021
51c780a
Be more specific regarding rules
yesrod Jul 17, 2021
e53fba6
Rsyslog-server base playbook (#41)
claughinghouse Jul 31, 2021
498a1a4
Remove terraform provider script (#51)
claughinghouse Aug 1, 2021
1851795
feat: setup timesyncd (#54)
claughinghouse Aug 7, 2021
5b6e83d
feat: add ufw rule for ssh and enable (#53)
claughinghouse Aug 7, 2021
3632c8a
Add rsyslog to common ubuntu role for all clients (#49)
claughinghouse Aug 7, 2021
44e4c3c
feat: add cups server buildout (#56)
claughinghouse Aug 11, 2021
6d09eb7
Remove remnants of Terraform plugin hack (#58)
yesrod Aug 11, 2021
a4be91c
TOPS-100 First pass at subnet / domain logic
aaronsaderholm Aug 20, 2021
23d02f7
TOPS-100 First pass at subnet / domain logic
aaronsaderholm Aug 20, 2021
45ab57c
TOPS-100 not
aaronsaderholm Aug 20, 2021
2372a24
TOPS-100 rebase fluke
aaronsaderholm Aug 20, 2021
e2147cd
TOPS-100 Updated Telemate/proxmox var in a few places
aaronsaderholm Aug 20, 2021
7fc2671
TOPS-100 simplify python subnet file
aaronsaderholm Aug 20, 2021
6cd4d72
TOPS-100 ??? CIDR math
aaronsaderholm Aug 20, 2021
c4efad4
TOPS-100 Maybe?
aaronsaderholm Aug 20, 2021
41a247f
TOPS-100 Maybe?
aaronsaderholm Aug 20, 2021
ea6e78b
TOPS-100 cleanup
aaronsaderholm Aug 20, 2021
1aae4f2
TOPS-100 Add domain local
aaronsaderholm Aug 20, 2021
fb181e5
TOPS-100 Scratch stackstorm
aaronsaderholm Aug 20, 2021
2bde176
TOPS-100 missing $
aaronsaderholm Aug 20, 2021
fe1d9a5
Merge branch 'main' into aaron-dev
aaronsaderholm Aug 31, 2021
2e80b2e
test: Make count dynamic
aaronsaderholm Aug 31, 2021
ab09d98
Testing instance increments
aaronsaderholm Aug 31, 2021
a750392
Add labels to module
aaronsaderholm Aug 31, 2021
830702d
Testing
aaronsaderholm Aug 31, 2021
6154b27
IP off by 1
aaronsaderholm Aug 31, 2021
9a446a5
Multiple branch support ?
aaronsaderholm Aug 31, 2021
19de27c
Template round 1
aaronsaderholm Aug 31, 2021
1674760
DEPLOY_BRANCHES var
aaronsaderholm Aug 31, 2021
8b081c9
Inventory template path issue
aaronsaderholm Aug 31, 2021
e787a17
Remove stackstorm
aaronsaderholm Aug 31, 2021
0f5c019
Refactor IP+CIDR into two seperate variables
aaronsaderholm Aug 31, 2021
d72bae5
More testing
aaronsaderholm Aug 31, 2021
6a96c21
Whoops
aaronsaderholm Aug 31, 2021
3784685
Deploy branch fixes
aaronsaderholm Aug 31, 2021
4bdacd3
Deploy branch fixes
aaronsaderholm Aug 31, 2021
0f7e6c7
Messing with deploy branches
aaronsaderholm Aug 31, 2021
18e483d
Messing with deploy branches
aaronsaderholm Aug 31, 2021
18fb916
Messing with deploy branches
aaronsaderholm Aug 31, 2021
b8af2a6
Messing with deploy branches
aaronsaderholm Aug 31, 2021
673d51f
Messing with deploy branches
aaronsaderholm Aug 31, 2021
16929b4
Messing with deploy branches
aaronsaderholm Aug 31, 2021
a2dd956
Messing with deploy branches
aaronsaderholm Aug 31, 2021
55807d2
Messing with deploy branches
aaronsaderholm Aug 31, 2021
8b58b96
Messing with deploy branches
aaronsaderholm Aug 31, 2021
c6a8967
Add hosts.ini as artifact
aaronsaderholm Aug 31, 2021
068e030
This one weird trick, everyone will hate it.
aaronsaderholm Aug 31, 2021
c540b08
This one weird trick, everyone will hate it.
aaronsaderholm Aug 31, 2021
744c692
Stub out DNS, NTP, TFTP
aaronsaderholm Aug 31, 2021
36c379f
Stub out DNS, NTP, TFTP
aaronsaderholm Aug 31, 2021
6259bbf
Expand inventory
aaronsaderholm Aug 31, 2021
92309f1
Fix lxc-tftp
aaronsaderholm Aug 31, 2021
797e6cd
Fix bugs
aaronsaderholm Aug 31, 2021
08539cc
terraform fmt
aaronsaderholm Aug 31, 2021
a240d9c
TOPS-102 Removed spurious comment.
aaronsaderholm Aug 31, 2021
e8e6ee6
Spacing fix
aaronsaderholm Aug 31, 2021
9795f9a
TOPS-102 Add Zabbix TF entry
aaronsaderholm Aug 31, 2021
fa7919d
TOPS-102 Memory allocations are now a optional parameter for LXC cont…
aaronsaderholm Aug 31, 2021
1d1bbd1
TOPS-95 Add Graylog LCX TF entry
aaronsaderholm Aug 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,13 @@ create:
script:
- terraform apply -auto-approve
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "aaron-dev"'
claughinghouse marked this conversation as resolved.
Show resolved Hide resolved
when: on_success
- when: never
artifacts:
paths:
- ${TF_ROOT}/.terraform
- ${TF_ROOT}/hosts.ini

# Ansible section here
run-playbooks:
Expand All @@ -95,7 +96,7 @@ run-playbooks:
script:
- echo $(/bin/true)
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "aaron-dev"'
claughinghouse marked this conversation as resolved.
Show resolved Hide resolved
when: on_success
- when: never

Expand All @@ -109,7 +110,7 @@ destroy:
script:
- terraform destroy -auto-approve
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "aaron-dev"'
claughinghouse marked this conversation as resolved.
Show resolved Hide resolved
when: manual
- when: never
artifacts:
Expand Down
20 changes: 8 additions & 12 deletions terraform/lxc-dhcp.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
module "dhcp1" {
source = "./modules/lxc"
cluster_name = "pve1"
ip_address = "${cidrhost(var.subnet, 253)}/${local.cidr_suffix}"
hostname = "dhcp1.${local.domain}"
}

module "dhcp2" {
source = "./modules/lxc"
cluster_name = "pve2"
ip_address = "${cidrhost(var.subnet, 254)}/${local.cidr_suffix}"
hostname = "dhcp2.${local.domain}"
module "dhcp" {
source = "./modules/lxc"
count = 2
# This one weird trick. Everyone will hate it.
claughinghouse marked this conversation as resolved.
Show resolved Hide resolved
cluster_name = "pve${count.index % 2 + 1}"
ip_address = cidrhost(var.subnet, 253 + count.index)
cidr_mask = local.cidr_suffix
hostname = "dhcp${floor(count.index + 1)}.${local.domain}"
}
9 changes: 9 additions & 0 deletions terraform/lxc-dns.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module "dns" {
source = "./modules/lxc"
count = 2
# This one weird trick. Everyone will hate it.
claughinghouse marked this conversation as resolved.
Show resolved Hide resolved
cluster_name = "pve${count.index % 2 + 1}"
ip_address = cidrhost(var.subnet, 110 + (count.index * 10))
cidr_mask = local.cidr_suffix
hostname = "dns${floor(count.index + 1)}.${local.domain}"
}
8 changes: 8 additions & 0 deletions terraform/lxc-graylog.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module "graylog" {
source = "./modules/lxc"
cluster_name = "pve1"
ip_address = cidrhost(var.subnet, 129)
cidr_mask = local.cidr_suffix
hostname = "graylog.${local.domain}"
memory = 4096
}
9 changes: 9 additions & 0 deletions terraform/lxc-ntp.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module "ntp" {
source = "./modules/lxc"
count = 2
# This one weird trick. Everyone will hate it.
cluster_name = "pve${count.index % 2 + 1}"
ip_address = cidrhost(var.subnet, 6 + count.index)
cidr_mask = local.cidr_suffix
hostname = "ntp${floor(count.index + 1)}.${local.domain}"
}
12 changes: 0 additions & 12 deletions terraform/lxc-stackstorm.tf

This file was deleted.

7 changes: 7 additions & 0 deletions terraform/lxc-tftp.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module "tftp" {
source = "./modules/lxc"
cluster_name = "pve2"
ip_address = cidrhost(var.subnet, 9)
cidr_mask = local.cidr_suffix
hostname = "tftp.${local.domain}"
}
7 changes: 7 additions & 0 deletions terraform/lxc-zabbix.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module "zabbix" {
source = "./modules/lxc"
cluster_name = "pve1"
ip_address = cidrhost(var.subnet, 200)
cidr_mask = local.cidr_suffix
hostname = "zabbix.${local.domain}"
}
20 changes: 20 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,23 @@ locals {
cidr_suffix = element(split("/", var.subnet), 1)
domain = "${var.branch}.magevent.net"
}

resource "local_file" "inventory" {
filename = "./hosts.ini"
content = <<-EOF
[dhcp]
${module.dhcp[0].ip_address}
${module.dhcp[1].ip_address}

[dns]
${module.dns[0].ip_address}
${module.dns[1].ip_address}

[ntp]
${module.ntp[0].ip_address}
${module.ntp[1].ip_address}

[tftp]
${module.tftp.ip_address}
EOF
}
19 changes: 18 additions & 1 deletion terraform/modules/lxc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ resource "proxmox_lxc" "lxc-container" {
ostemplate = "wowza:vztmpl/ubuntu-20.04-standard_20.04-1_amd64.tar.gz"
unprivileged = true
hostname = var.hostname
memory = var.memory
cores = "1"
swap = "512"
start = true
Expand All @@ -31,8 +32,9 @@ EOT
name = "eth0"
bridge = "vmbr999"
tag = "22"
ip = var.ip_address
ip = "${var.ip_address}/${var.cidr_mask}"
}

}

variable "hostname" {
Expand All @@ -52,8 +54,23 @@ variable "ip_address" {
type = string
}

variable "cidr_mask" {
description = "CIDR for IP subnet"
type = string
}

variable "size" {
description = "Size of fs in gigabytes"
type = string
default = "8G"
}

variable "memory" {
description = "Size of memory in megabytes"
type = string
default = "512"
}

output "ip_address" {
value = var.ip_address
}