diff --git a/main.tf b/compute.tf similarity index 93% rename from main.tf rename to compute.tf index 33f66ef..ed42ca4 100644 --- a/main.tf +++ b/compute.tf @@ -1,6 +1,6 @@ -# ------------------------------------------------------------------------------ -# Setup Bastion Host -# ------------------------------------------------------------------------------ +## Copyright © 2020, Oracle and/or its affiliates. +## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl + resource "oci_core_instance" "JenkinsBastion" { availability_domain = var.availablity_domain_name compartment_id = var.compartment_ocid diff --git a/datasources.tf b/datasources.tf index fb72eab..4921277 100644 --- a/datasources.tf +++ b/datasources.tf @@ -1,6 +1,5 @@ -############################################ -# Datasource -############################################ +## Copyright © 2020, Oracle and/or its affiliates. +## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl # Gets a list of Availability Domains data "oci_identity_availability_domains" "ad" { @@ -63,9 +62,11 @@ data "oci_core_images" "bastion_image" { } } -# Gets the Id of a specific OS Images -#data "oci_core_images" "InstanceImageOCID" { -# #Required -# compartment_id = var.compartment_ocid -# display_name = var.OsImage -#} \ No newline at end of file +data "oci_identity_region_subscriptions" "home_region_subscriptions" { + tenancy_id = var.tenancy_ocid + + filter { + name = "is_home_region" + values = [true] + } +} diff --git a/loadbalancer.tf b/lb.tf similarity index 85% rename from loadbalancer.tf rename to lb.tf index f65c423..7b42ad5 100644 --- a/loadbalancer.tf +++ b/lb.tf @@ -1,9 +1,21 @@ -############################################ -# Create Load Balancer -############################################ +## Copyright © 2020, Oracle and/or its affiliates. +## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl + +locals { + is_flexible_lb_shape = var.lb_shape == "flexible" ? true : false +} resource "oci_load_balancer" "JenkinsLB" { - shape = "100Mbps" + shape = var.lb_shape + + dynamic "shape_details" { + for_each = local.is_flexible_lb_shape ? [1] : [] + content { + minimum_bandwidth_in_mbps = var.flex_lb_min_shape + maximum_bandwidth_in_mbps = var.flex_lb_max_shape + } + } + compartment_id = var.compartment_ocid subnet_ids = [ diff --git a/locals.tf b/locals.tf index 14c6ec2..08d0b45 100644 --- a/locals.tf +++ b/locals.tf @@ -1,3 +1,6 @@ +## Copyright © 2020, Oracle and/or its affiliates. +## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl + locals { # Network Locals # diff --git a/network.tf b/network.tf index 83663de..e238b27 100644 --- a/network.tf +++ b/network.tf @@ -1,3 +1,6 @@ +## Copyright © 2020, Oracle and/or its affiliates. +## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl + ############################################ # Create VCN ############################################ diff --git a/outputs.tf b/outputs.tf index 82bca7d..444c05b 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,3 +1,6 @@ +## Copyright © 2020, Oracle and/or its affiliates. +## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl + output "master_private_ip" { value = module.jenkins.master_private_ip } diff --git a/provider.tf b/provider.tf index 0eadd21..4769613 100644 --- a/provider.tf +++ b/provider.tf @@ -1,5 +1,5 @@ -## This file declare Provider block and variables required to run the template using Terraform CLI with standard user based authentication. -## Remove this file from your OCI ORM Stack as ORM will pick up these variables from the authenticated user running the ORM Stack. +## Copyright © 2020, Oracle and/or its affiliates. +## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl ############################################ # Provider @@ -12,11 +12,12 @@ provider "oci" { region = var.region } -variable "user_ocid" { -} - -variable "fingerprint" { +provider "oci" { + alias = "homeregion" + tenancy_ocid = var.tenancy_ocid + user_ocid = var.user_ocid + fingerprint = var.fingerprint + private_key_path = var.private_key_path + region = data.oci_identity_region_subscriptions.home_region_subscriptions.region_subscriptions[0].region_name + disable_auto_retries = "true" } - -variable "private_key_path" { -} \ No newline at end of file diff --git a/schema.yaml b/schema.yaml index b51faa4..2b86abf 100644 --- a/schema.yaml +++ b/schema.yaml @@ -15,6 +15,8 @@ variableGroups: variables: - tenancy_ocid - region + - release + - bastion_user - title: "Required Configuration" visible: true @@ -22,19 +24,36 @@ variableGroups: - compartment_ocid - availablity_domain_name - jenkins_password + - show_advanced -- title: "Optional Configuration" - visible: true +- title: Networking Optional Configuration + visible: + and: + - show_advanced variables: - - plugins - vcn_cidr - - label_prefix - - lb_http_port - - lb_https_port - http_port - jnlp_port - - jenkins_version - - agent_count + +- title: Load Balancer Optional Configuration + visible: + and: + - show_advanced + variables: + - lb_shape + - flex_lb_min_shape + - flex_lb_max_shape + - lb_http_port + - lb_https_port + - listener_ca_certificate + - listener_private_key + - listener_public_certificate + +- title: Compute Optional Configuration + visible: + and: + - show_advanced + variables: - instance_os - linux_os_version - bastion_display_name @@ -47,13 +66,27 @@ variableGroups: - agent_shape - agent_flex_shape_ocpus - agent_flex_shape_memory - - bastion_user - - listener_ca_certificate - - listener_private_key - - listener_public_certificate - - release + +- title: Jenkins Optional Configuration + visible: + and: + - show_advanced + variables: + - jenkins_version + - agent_count + - plugins + - label_prefix + variables: + + show_advanced: + type: boolean + title: "Show advanced options?" + description: "Shows advanced options." + visible: true + default: false + # General Configuration tenancy_ocid: title: "Tenancy ID" @@ -141,6 +174,56 @@ variables: type: number required: false + lb_shape: + type: enum + title: "Load Balancer Shape" + description: "Load Balancer Shape" + default: "flexible" + required: false + enum: + - "flexible" + - "100Mbps" + - "10Mbps" + - "10Mbps-Micro" + - "400Mbps" + - "8000Mbps" + + flex_lb_min_shape: + type: enum + required: false + default: "10" + title: "LB Flex Min Shape" + description: "Choose Minimum Shape for Flex Load Balancer." + enum: + - "10" + - "100" + - "1000" + - "400" + - "8000" + visible: + and: + - eq: + - lb_shape + - "flexible" + + flex_lb_max_shape: + type: enum + required: false + default: "100" + title: "LB Flex Max Shape" + description: "Choose Maximum Shape for Flex Load Balancer." + enum: + - "10" + - "100" + - "1000" + - "400" + - "8000" + visible: + and: + - eq: + - lb_shape + - "flexible" + http_port: title: "HTTP Port" description: "HTTP Port for Jenkins Server" @@ -211,7 +294,7 @@ variables: type: oci:core:instanceshape:name title: "Bastion Server Shape" description: "Bastion Server Shape" - default: "VM.Standard2.1" + default: "VM.Standard.E3.Flex" required: false dependsOn: compartmentId: ${compartment_ocid} @@ -225,9 +308,6 @@ variables: - eq: - bastion_shape - "VM.Standard.E4.Flex" - - eq: - - bastion_shape - - "VM.Standard.A1.Flex" type: integer default: 1 title: Bastion Server Flex Shape OCPUs @@ -245,9 +325,6 @@ variables: - eq: - bastion_shape - "VM.Standard.E4.Flex" - - eq: - - bastion_shape - - "VM.Standard.A1.Flex" type: integer default: 6 title: Bastion Server Flex Shape Memory @@ -260,7 +337,7 @@ variables: type: oci:core:instanceshape:name title: "Jenkins Master Server Shape" description: "Jenkins Master Server Shape" - default: "VM.Standard2.4" + default: "VM.Standard.E3.Flex" required: false dependsOn: compartmentId: ${compartment_ocid} @@ -274,9 +351,6 @@ variables: - eq: - master_shape - "VM.Standard.E4.Flex" - - eq: - - master_shape - - "VM.Standard.A1.Flex" type: integer default: 1 title: Jenkins Master Server Flex Shape OCPUs @@ -295,9 +369,6 @@ variables: - eq: - master_shape - "VM.Standard.E4.Flex" - - eq: - - master_shape - - "VM.Standard.A1.Flex" type: integer default: 6 title: Jenkins Master Server Flex Shape Memory @@ -310,7 +381,7 @@ variables: type: oci:core:instanceshape:name title: "Jenkins Agent Server Shape" description: "Jenkins Agent Server Shape" - default: "VM.Standard2.4" + default: "VM.Standard.E3.Flex" required: false dependsOn: compartmentId: ${compartment_ocid} @@ -324,9 +395,6 @@ variables: - eq: - agent_shape - "VM.Standard.E4.Flex" - - eq: - - agent_shape - - "VM.Standard.A1.Flex" type: integer default: 1 title: Jenkins Agent Server Flex Shape OCPUs @@ -345,9 +413,6 @@ variables: - eq: - agent_shape - "VM.Standard.E4.Flex" - - eq: - - agent_shape - - "VM.Standard.A1.Flex" type: integer default: 6 title: Jenkins Agent Server Flex Shape Memory diff --git a/tags.tf b/tags.tf index b5beba0..220273a 100644 --- a/tags.tf +++ b/tags.tf @@ -1,10 +1,15 @@ ## Copyright © 2020, Oracle and/or its affiliates. ## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl +resource "random_id" "tag" { + byte_length = 2 +} + resource "oci_identity_tag_namespace" "ArchitectureCenterTagNamespace" { + provider = oci.homeregion compartment_id = var.compartment_ocid description = "ArchitectureCenterTagNamespace" - name = "ArchitectureCenter\\jenkins-master-agent-mode" + name = "ArchitectureCenter\\jenkins-master-agent-mode-${random_id.tag.hex}" provisioner "local-exec" { command = "sleep 10" @@ -13,16 +18,17 @@ resource "oci_identity_tag_namespace" "ArchitectureCenterTagNamespace" { } resource "oci_identity_tag" "ArchitectureCenterTag" { + provider = oci.homeregion description = "ArchitectureCenterTag" name = "release" tag_namespace_id = oci_identity_tag_namespace.ArchitectureCenterTagNamespace.id validator { validator_type = "ENUM" - values = ["release", "1.1"] + values = ["release", "1.2"] } provisioner "local-exec" { - command = "sleep 20" + command = "sleep 120" } } \ No newline at end of file diff --git a/tls.tf b/tls.tf index 3d8aced..6c7ae34 100644 --- a/tls.tf +++ b/tls.tf @@ -1,3 +1,6 @@ +## Copyright © 2020, Oracle and/or its affiliates. +## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl + resource "tls_private_key" "public_private_key_pair" { algorithm = "RSA" } \ No newline at end of file diff --git a/variables.tf b/variables.tf index 16e3973..2571950 100644 --- a/variables.tf +++ b/variables.tf @@ -1,11 +1,17 @@ +## Copyright © 2020, Oracle and/or its affiliates. +## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl + variable "tenancy_ocid" {} variable "region" {} variable "compartment_ocid" {} +variable "user_ocid" {} +variable "fingerprint" {} +variable "private_key_path" {} variable "availablity_domain_name" {} variable "release" { description = "Reference Architecture Release (OCI Architecture Center)" - default = "1.1" + default = "1.2" } variable "vcn_cidr" { @@ -32,6 +38,18 @@ variable "jnlp_port" { default = 49187 } +variable "lb_shape" { + default = "flexible" +} + +variable "flex_lb_min_shape" { + default = "10" +} + +variable "flex_lb_max_shape" { + default = "100" +} + #variable "plugins" { # type = list(string) # description = "A list of Jenkins plugins to install, use short names. " @@ -59,39 +77,39 @@ variable "bastion_display_name" { } variable "bastion_shape" { - default = "VM.Standard2.1" + default = "VM.Standard.E3.Flex" } variable "bastion_flex_shape_ocpus" { - default = "" + default = 1 } variable "bastion_flex_shape_memory" { - default = "" + default = 1 } variable "master_shape" { - default = "VM.Standard2.4" + default = "VM.Standard.E3.Flex" } variable "master_flex_shape_ocpus" { - default = "" + default = 1 } variable "master_flex_shape_memory" { - default = "" + default = 15 } variable "agent_shape" { - default = "VM.Standard2.4" + default = "VM.Standard.E3.Flex" } variable "agent_flex_shape_ocpus" { - default = "" + default = 1 } variable "agent_flex_shape_memory" { - default = "" + default = 20 } variable "bastion_user" { diff --git a/versions.tf b/versions.tf index fdc51e2..7a5d7ca 100644 --- a/versions.tf +++ b/versions.tf @@ -1,3 +1,5 @@ +## Copyright © 2020, Oracle and/or its affiliates. +## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl terraform { required_version = ">= 0.14"