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

Feature# 1: Update the terraform version to v0.12 #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
74 changes: 37 additions & 37 deletions deployment/gcp_compute.tf
Original file line number Diff line number Diff line change
@@ -14,57 +14,57 @@
* limitations under the License.
*/


/*
* Terraform compute resources for GCP.
* Acquire all zones and choose one randomly.
*/

data "google_compute_zones" "available" {
region = "${var.gcp_region}"
region = var.gcp_region
}

resource "google_compute_instance" "panos" {
count = 1
name = "panos"
machine_type = "n1-standard-4"
zone = "${data.google_compute_zones.available.names[0]}"
can_ip_forward = true
allow_stopping_for_update = true
metadata {
serial-port-enable = true
ssh-keys = "admin:${file("${var.gcp_ssh_key}")}"
}
service_account {
scopes = [
"https://www.googleapis.com/auth/cloud.useraccounts.readonly",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring.write",
]
}
network_interface {
network = "default"
access_config = {}
count = 1
name = "panos"
machine_type = "n1-standard-4"
zone = data.google_compute_zones.available.names[0]
can_ip_forward = true
allow_stopping_for_update = true
metadata = {
serial-port-enable = true
ssh-keys = "admin:${file(var.gcp_ssh_key)}"
}
service_account {
scopes = [
"https://www.googleapis.com/auth/cloud.useraccounts.readonly",
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring.write",
]
}
network_interface {
network = "default"
access_config {
}
}

boot_disk {
initialize_params {
image = "https://www.googleapis.com/compute/v1/projects/paloaltonetworksgcp-public/global/images/vmseries-byol-810"
}
boot_disk {
initialize_params {
image = "https://www.googleapis.com/compute/v1/projects/paloaltonetworksgcp-public/global/images/vmseries-byol-810"
}
}
}

resource "google_compute_firewall" "mgt" {
name = "allow-traffic"
network = "default"
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["22", "443"]
}
source_ranges = ["0.0.0.0/0"]
name = "allow-traffic"
network = "default"
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["22", "443"]
}
source_ranges = ["0.0.0.0/0"]
}

14 changes: 7 additions & 7 deletions deployment/gcp_outputs.tf
Original file line number Diff line number Diff line change
@@ -14,23 +14,23 @@
* limitations under the License.
*/


/*
* Terraform output variables for GCP.
*/

output "Hostname" {
value = "${google_compute_instance.panos.instance_id}"
output "Hostname" {
value = google_compute_instance.panos[0].instance_id
}

output "External IP" {
value = "${google_compute_instance.panos.network_interface.0.access_config.0.nat_ip}"
output "ExternalIP" {
value = google_compute_instance.panos[0].network_interface[0].access_config[0].nat_ip
}

output "Zone" {
value = "${google_compute_instance.panos.zone}"
value = google_compute_instance.panos[0].zone
}

output "Project" {
value = "${var.gcp_project_id}"
value = var.gcp_project_id
}

8 changes: 4 additions & 4 deletions deployment/gcp_provider.tf
Original file line number Diff line number Diff line change
@@ -14,13 +14,13 @@
* limitations under the License.
*/


/*
* Terraform main configuration file (with provider definitions).
*/

provider "google" {
project = "${var.gcp_project_id}"
region = "${var.gcp_region}"
credentials = "${file("${var.gcp_credentials_file}")}"
project = var.gcp_project_id
region = var.gcp_region
credentials = file(var.gcp_credentials_file)
}

20 changes: 10 additions & 10 deletions deployment/gcp_variables.tf
Original file line number Diff line number Diff line change
@@ -14,31 +14,31 @@
* limitations under the License.
*/


/*
* Terraform variable declarations for GCP.
*/

variable "gcp_project_id" {
description = "GCP Project ID"
type = "string"
default = ""
type = string
default = ""
}

variable "gcp_region" {
description = ""
type = "string"
default = ""
type = string
default = ""
}

variable "gcp_credentials_file" {
description = "Full path to the JSON credentials file"
type = "string"
default = "../gcp_compute_key.json"
type = string
default = "../gcp_compute_key.json"
}

variable "gcp_ssh_key" {
description = "Full path to the SSH public key file"
type = "string"
default = "../../.ssh/lab_ssh_key.pub"
description = "Full path to the SSH public key file"
type = string
default = "../../.ssh/lab_ssh_key.pub"
}

30 changes: 1 addition & 29 deletions setup
Original file line number Diff line number Diff line change
@@ -14,34 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.


# Download and extract Terraform utility in the deployment directory.
function getTerraform() {
# Places terraform in /usr/local/bin dir.
local T_VERSION='0.11.7/terraform_0.11.7_linux_amd64'
local T_URL="https://releases.hashicorp.com/terraform/${T_VERSION}.zip"
local T_DIR=/usr/local/bin
local T_ZIP="${T_DIR}/terraform.zip"
local T_EXE="${T_DIR}/terraform"

if [ -e ${T_EXE} ]; then
echo "${T_EXE} already exists. Exiting."
return 0
fi
echo -n "Installing Terraform ..."
pushd ${T_DIR} > /dev/null
sudo curl -s -o "${T_ZIP}" "${T_URL}"
sudo unzip -q "${T_ZIP}"
sudo rm "${T_ZIP}"
popd > /dev/null

if [ -e ${T_EXE} ]; then
echo " Done"
else
echo " Could not retrieve ${T_EXE}."
fi
}

# Install Ansible package from apt repository.
function getAnsible() {
local A_EXE="/usr/bin/ansible"
@@ -73,6 +45,6 @@ function getPyLibs() {
}

# Main program
getTerraform
getAnsible
getPyLibs

14 changes: 7 additions & 7 deletions terraform/panos_variables.tf
Original file line number Diff line number Diff line change
@@ -14,26 +14,26 @@
* limitations under the License.
*/


/*
* Terraform variable declarations for the VM-Series instance.
*/

variable "panos_hostname" {
description = "The external IP address of the VM-Series instance"
type = "string"
default = ""
type = string
default = ""
}

variable "panos_username" {
description = "Username of the VM-Series administrator"
type = "string"
default = ""
type = string
default = ""
}

variable "panos_password" {
description = "Password of the VM-Series administrator"
type = "string"
default = ""
type = string
default = ""
}