Skip to content

Commit

Permalink
feat(OCTOPUS-737): add terraform to add powervm workers
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Bastide <[email protected]>
  • Loading branch information
prb112 committed May 17, 2024
1 parent 299f509 commit a1aec9d
Show file tree
Hide file tree
Showing 8 changed files with 398 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ _deps

# Terraform automation
automation
.terraform
terraform.tfstate
*.tfstate*

# Binaries
ibmcloud
Expand Down
36 changes: 36 additions & 0 deletions tf/add-powervm-workers/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
temp.state*
*state
# Local .terraform directories
**/.terraform/*
_scratch
data/
*.tfstate*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log

# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
#
# example.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
*tfplan*

**/.DS_Store
98 changes: 98 additions & 0 deletions tf/add-powervm-workers/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions tf/add-powervm-workers/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
################################################################
# Copyright 2024 - IBM Corporation. All rights reserved
# SPDX-License-Identifier: Apache-2.0
################################################################

output "add_these_to_dhcp" {
value = "Add these values to your dhcpd.conf and update the worker-p number \n host worker-p-0 { hardware ethernet 1:1:1:1; fixed-address 192.168.200.1; }"
}

output "mac_ip_combo" {
value = [for s in openstack_networking_port_v2.worker_port : "host worker-p { hardware ethernet ${s.mac_address}; fixed-address ${s.fixed_ip[0].ip_address}; }"]
}

output "add_these_to_chrony_allow" {
description = "Add these values to your chrony.conf"
value = "Add an allow rule for your Power worker subnet"
}
53 changes: 53 additions & 0 deletions tf/add-powervm-workers/templates/worker.ign
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"ignition": {
"version": "3.4.0",
"config": {
"merge": [
{
"source": "http://${ignition_ip}:8080/ignition/worker.ign"
}
]
},
"timeouts": {
"httpTotal": 30
}
},
"storage": {
"files": [
{
"group": {},
"path": "/etc/hostname",
"user": {},
"contents": {
"source": "data:text/plain;base64,${name}",
"verification": {}
},
"mode": 420
},
{
"group": {},
"path": "/etc/resolv.conf",
"user": {},
"contents": {
"source": "data:text/plain;base64,${resolver_ip}",
"verification": {}
},
"mode": 420
},
{
"group": {},
"path": "/etc/NetworkManager/dispatcher.d/20-ethtool",
"user": {},
"contents": {
"source": "data:text/plain;base64,aWYgWyAiJDEiID0gImVudjIiIF0gJiYgWyAiJDIiID0gInVwIiBdCnRoZW4KICBlY2hvICJUdXJuaW5nIG9mZiB0eC1jaGVja3N1bW1pbmciCiAgL3NiaW4vZXRodG9vbCAtLW9mZmxvYWQgZW52MiB0eC1jaGVja3N1bW1pbmcgb2ZmCmVsc2UgCiAgZWNobyAibm90IHJ1bm5pbmcgdHgtY2hlY2tzdW1taW5nIG9mZiIKZmkKaWYgc3lzdGVtY3RsIGlzLWZhaWxlZCBOZXR3b3JrTWFuYWdlci13YWl0LW9ubGluZQp0aGVuCnN5c3RlbWN0bCByZXN0YXJ0IE5ldHdvcmtNYW5hZ2VyLXdhaXQtb25saW5lCmZpCg==",
"verification": {}
},
"mode": 420
}
]
},
"passwd": {
"users": [
]
}
}
89 changes: 89 additions & 0 deletions tf/add-powervm-workers/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
################################################################
# Copyright 2024 - IBM Corporation. All rights reserved
# SPDX-License-Identifier: Apache-2.0
################################################################

variable "user_name" {
description = "The user name used to connect to OpenStack/PowerVC"
default = "my_user_name"
}

variable "password" {
description = "The password for the user"
default = "my_password"
}

variable "tenant_name" {
description = "The name of the project (a.k.a. tenant) used"
default = "ibm-default"
}

variable "domain_name" {
description = "The domain to be used"
default = "Default"
}

variable "auth_url" {
description = "The endpoint URL used to connect to OpenStack/PowerVC"
default = "https://<HOSTNAME>:5000/v3/"
}

variable "insecure" {
default = "true" # OS_INSECURE
}

variable "openstack_availability_zone" {
description = "The name of Availability Zone for deploy operation"
default = ""
}

################################################################
#

variable "network_name" {
type = string
description = "The Network Name in OpenStack"
default = ""
}

variable "ignition_ip" {
type = string
description = "The IP to retrieve the ignition file"
default = ""
}

variable "resolver_ip" {
type = string
description = "The DNS resolver"
default = ""
}

variable "resolver_domain" {
type = string
description = "The DNS Domain"
default = ""
}

variable "power_worker_prefix" {
type = string
description = "The power worker prefixes"
default = ""
}

variable "flavor_id" {
type = string
description = "flavor id from the PowerVC console"
default = ""
}

variable "image_id" {
type = string
description = "image id from the PowerVC console"
default = ""
}

variable "worker_count" {
type = number
description = "the number of workers to create"
default = 1
}
33 changes: 33 additions & 0 deletions tf/add-powervm-workers/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
################################################################
# Copyright 2023 - IBM Corporation. All rights reserved
# SPDX-License-Identifier: Apache-2.0
################################################################

terraform {
required_providers {
null = {
source = "hashicorp/null"
version = "~> 3.2.1"
}
time = {
source = "hashicorp/time"
version = "0.9.1"
}
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.32"
}
ibm = {
source = "IBM-Cloud/ibm"
version = "~> 1.62.0"
configuration_aliases = [ibm]
}
http = {
source = "hashicorp/http"
version = "3.4.0"
}
}
required_version = ">= 1.5.0"
}


Loading

0 comments on commit a1aec9d

Please sign in to comment.