Skip to content

Commit 2802531

Browse files
authored
added private ssh key as variable (#378)
* added private ssh key as variable Signed-off-by: Ali Mukadam <[email protected]> * typo in terraform.tfvars.example Signed-off-by: Ali Mukadam <[email protected]> * updated changelog Signed-off-by: Ali Mukadam <[email protected]> * duplicate entry for api_key in terraform.tfvars.example Signed-off-by: Ali Mukadam <[email protected]>
1 parent 3a407d5 commit 2802531

26 files changed

+67
-290
lines changed

CHANGELOG.adoc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ The format is based on {uri-changelog}[Keep a Changelog].
99

1010
=== Unreleased
1111
# Breaking changes
12+
* Set minimum version to Terraform 1.0.0
1213
* Removed base module and use vcn, bastion and operator modules directly
1314
* Renamed and standardized all control variables
1415
* Removed deprecated template provider dependencies
1516
* Made bastion and operator modules conditional
16-
* Added LPGs for hub and spoke deployment model
17-
* Set minimum version to Terraform 1.0.0
18-
* Removed identity parameters in between modules
17+
* Removed identity parameters in between modules to improve reusability
1918
* Renamed okenetwork submodule to network
2019
* Created a new submodule (extensions) and moved all scripts and extra things there
2120
* Moved dynamic group and policy for kms into oke module
@@ -24,20 +23,22 @@ The format is based on {uri-changelog}[Keep a Changelog].
2423

2524
# Changes
2625
* Changed default Kubernetes version to v1.20.8 and removed v1.16.8, v1.17.9 from docs.
27-
* Added support for reserved public IP address for NAT gateway
2826
* Bug fix: Use correct calico file to install calico for networking policy only (#307)
2927
* Added support for GPU and ARM shapes (#302)
30-
* VCN module upgraded to VCN 3.0.0. This allows supporting multiple cidr blocks (#360 )
31-
* kubeconfig on operator always uses PRIVATE_ENDPOINT (#358 )
32-
* Documented providers in quickstart (#355 )
33-
* Renamed tags to freeform_tags in line with other modules
34-
* Added validation on some variables
28+
* VCN module upgraded to VCN 3.0.0. This allows supporting multiple cidr blocks (#360)
29+
* kubeconfig on operator always uses PRIVATE_ENDPOINT (#358)
30+
* Documented providers in quickstart (#355)
31+
* Renamed tags to freeform_tags in line with other modules (#364)
32+
* Added validation on some variables (#370)
3533

3634
# New Features
37-
35+
* Added OCI Bastion Service as option to access operator or control plane
36+
* Added support for reserved public IP address for NAT gateway (#311)
37+
* Added LPGs for hub and spoke deployment model (#295)
3838
* Allow access to operator via OCI Bastion service (#352)
3939
* Added support for using NSGs for cluster endpoint (#343 )
40-
* Added option to disable worker node access to Internet. Users can only pull images from OCIR (#331 )
40+
* Added option to disable worker node access to Internet. Users can only pull images from OCIR (#331)
41+
* Added ability to specify api and private ssh keys using heredoc format with a variable (#375)
4142

4243
# Bug fixes
4344
* Added home region to update dynamic group script for cases when actual region is different from tenancy home region (#347)

docs/terraformoptions.adoc

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ Ensure you review the {uri-terraform-dependencies}[dependencies].
4343
|none
4444

4545
|api_private_key
46-
|The contents of the private key file to use with OCI API. This takes precedence over private_key_path if both are specified in the provider. *Maybe required depending on your authentication method.*
47-
|
46+
|The contents of the private key file to use with OCI API. This takes precedence over private_key_path if both are specified in the provider. *Maybe required depending on your authentication method.* Use the heredoc format if you are specifying the key with this variable.
47+
|<<EOT
48+
-----BEGIN RSA PRIVATE KEY-----
49+
content+of+api+key
50+
-----END RSA PRIVATE KEY-----
51+
EOT
4852
|none
4953

5054
|api_private_key_password
@@ -104,6 +108,16 @@ Ensure you review the {uri-terraform-dependencies}[dependencies].
104108
|Values
105109
|Default
106110

111+
|ssh_private_key
112+
|The contents of the private ssh key file. Use the heredoc format if you are specifying the private key.
113+
|
114+
<<EOT
115+
-----BEGIN RSA PRIVATE KEY-----
116+
content+of+api+key
117+
-----END RSA PRIVATE KEY-----
118+
EOT
119+
|
120+
107121
|ssh_private_key_path
108122
|path to ssh private key. The same key will be used to access worker nodes using SSH. *Required* if bastion is enabled.
109123

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ module "extensions" {
254254
region = var.region
255255

256256
# ssh keys
257+
ssh_private_key = var.ssh_private_key
257258
ssh_private_key_path = var.ssh_private_key_path
258259
ssh_public_key = var.ssh_public_key
259260
ssh_public_key_path = var.ssh_public_key_path

modules/extensions/activeworker.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ resource "null_resource" "check_worker_active" {
88

99
connection {
1010
host = var.operator_private_ip
11-
private_key = file(var.ssh_private_key_path)
11+
private_key = local.ssh_private_key
1212
timeout = "40m"
1313
type = "ssh"
1414
user = "opc"
1515

1616
bastion_host = var.bastion_public_ip
1717
bastion_user = "opc"
18-
bastion_private_key = file(var.ssh_private_key_path)
18+
bastion_private_key = local.ssh_private_key
1919
}
2020

2121
depends_on = [null_resource.write_kubeconfig_on_operator]

modules/extensions/calico.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
resource "null_resource" "install_calico" {
55
connection {
66
host = var.operator_private_ip
7-
private_key = file(var.ssh_private_key_path)
7+
private_key = local.ssh_private_key
88
timeout = "40m"
99
type = "ssh"
1010
user = "opc"
1111

1212
bastion_host = var.bastion_public_ip
1313
bastion_user = "opc"
14-
bastion_private_key = file(var.ssh_private_key_path)
14+
bastion_private_key = local.ssh_private_key
1515
}
1616

1717
depends_on = [null_resource.install_kubectl_operator, null_resource.write_kubeconfig_on_operator]

modules/extensions/drain.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
resource "null_resource" "drain_nodes" {
55
connection {
66
host = var.operator_private_ip
7-
private_key = file(var.ssh_private_key_path)
7+
private_key = local.ssh_private_key
88
timeout = "40m"
99
type = "ssh"
1010
user = "opc"
1111

1212
bastion_host = var.bastion_public_ip
1313
bastion_user = "opc"
14-
bastion_private_key = file(var.ssh_private_key_path)
14+
bastion_private_key = local.ssh_private_key
1515
}
1616

1717
provisioner "file" {

modules/extensions/iam.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ resource "null_resource" "update_dynamic_group" {
3232

3333
connection {
3434
host = var.operator_private_ip
35-
private_key = file(var.ssh_private_key_path)
35+
private_key = local.ssh_private_key
3636
timeout = "40m"
3737
type = "ssh"
3838
user = "opc"
3939

4040
bastion_host = var.bastion_public_ip
4141
bastion_user = "opc"
42-
bastion_private_key = file(var.ssh_private_key_path)
42+
bastion_private_key = local.ssh_private_key
4343
}
4444

4545
depends_on = [time_sleep.wait_30_seconds]

modules/extensions/k8stools.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
resource "null_resource" "install_kubectl_operator" {
55
connection {
66
host = var.operator_private_ip
7-
private_key = file(var.ssh_private_key_path)
7+
private_key = local.ssh_private_key
88
timeout = "40m"
99
type = "ssh"
1010
user = "opc"
1111

1212
bastion_host = var.bastion_public_ip
1313
bastion_user = "opc"
14-
bastion_private_key = file(var.ssh_private_key_path)
14+
bastion_private_key = local.ssh_private_key
1515
}
1616

1717
provisioner "file" {
@@ -34,14 +34,14 @@ resource "null_resource" "install_kubectl_operator" {
3434
resource "null_resource" "install_helm_operator" {
3535
connection {
3636
host = var.operator_private_ip
37-
private_key = file(var.ssh_private_key_path)
37+
private_key = local.ssh_private_key
3838
timeout = "40m"
3939
type = "ssh"
4040
user = "opc"
4141

4242
bastion_host = var.bastion_public_ip
4343
bastion_user = "opc"
44-
bastion_private_key = file(var.ssh_private_key_path)
44+
bastion_private_key = local.ssh_private_key
4545
}
4646

4747
depends_on = [null_resource.install_kubectl_operator, null_resource.write_kubeconfig_on_operator]

modules/extensions/kubeconfig.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ resource "local_file" "kube_config_file" {
5353
resource "null_resource" "write_kubeconfig_on_operator" {
5454
connection {
5555
host = var.operator_private_ip
56-
private_key = file(var.ssh_private_key_path)
56+
private_key = local.ssh_private_key
5757
timeout = "40m"
5858
type = "ssh"
5959
user = "opc"
6060

6161
bastion_host = var.bastion_public_ip
6262
bastion_user = "opc"
63-
bastion_private_key = file(var.ssh_private_key_path)
63+
bastion_private_key = local.ssh_private_key
6464
}
6565

6666
depends_on = [null_resource.install_kubectl_operator]

modules/extensions/locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
33

44
locals {
5-
5+
ssh_private_key = var.ssh_private_key != "" ? var.ssh_private_key : var.ssh_private_key_path != "none" ? file(var.ssh_private_key_path) : null
66
node_pools_size_list = [
77
for node_pool in data.oci_containerengine_node_pools.all_node_pools.node_pools :
88
node_pool.node_config_details[0].size

0 commit comments

Comments
 (0)