Skip to content

Commit

Permalink
CentOS 8 Support and Ubuntu 18.04 tested (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
c0dyhi11 authored Nov 26, 2020
1 parent de59b6e commit ffdac40
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 22 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,15 @@ Worker_Public_IPs = [
| Name | Api Slug |
| :-----------------------: | :----------: |
| CentOS 8 | centos_8 |
| RedHat Enterprise Linux 8 | rhel_8 |
| Ubuntu 18.04 | ubuntu_18_04 |
| Ubutnu 20.04 | ubuntu_20_04 |

## Operating Systems that need fixing
| Name | Api Slug |
| :-----------------------: | :----------: |
| Red Hat Enterprise Linux 8 | rhel_8 |


## Variables

| Variable Name | Type | Default Value | Description |
Expand Down
9 changes: 5 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ resource "null_resource" "write_ssh_private_key" {
}

data "template_file" "deploy_anthos_cluster" {
template = file("templates/deploy_cluster.sh")
template = file("templates/pre_reqs.sh")
vars = {
cluster_name = local.cluster_name
cluster_name = local.cluster_name
operating_system = var.operating_system
}
}

Expand Down Expand Up @@ -168,7 +169,7 @@ resource "null_resource" "prep_anthos_cluster" {

provisioner "file" {
content = data.template_file.deploy_anthos_cluster.rendered
destination = "/root/baremetal/deploy_cluster.sh"
destination = "/root/baremetal/pre_reqs.sh"
}

provisioner "file" {
Expand All @@ -177,7 +178,7 @@ resource "null_resource" "prep_anthos_cluster" {
}

provisioner "remote-exec" {
inline = ["bash /root/baremetal/deploy_cluster.sh"]
inline = ["bash /root/baremetal/pre_reqs.sh"]
}
}

Expand Down
2 changes: 1 addition & 1 deletion output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ output "Worker_Node_Tags" {
description = "Worker Node Tags"
}

output "ssh_key_lcation" {
output "ssh_key_location" {
value = local_file.cluster_private_key_pem.filename
description = "The SSH Private Key File Location"
}
Expand Down
72 changes: 56 additions & 16 deletions templates/deploy_cluster.sh → templates/pre_reqs.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,60 @@
#!/bin/bash
# Install Docker
sudo apt update -y
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" -y
sudo apt update -y
sudo apt install docker-ce -y
sudo usermod -aG docker $USER

# Install Google Cloud SDK
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update -y
sudo apt-get install google-cloud-sdk -y
CLUSTER_NAME='${cluster_name}'
OS='${operating_system}'

function ubuntu_pre_reqs {
# Install Docker
sudo apt update -y
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" -y
sudo apt update -y
sudo apt install docker-ce -y
sudo usermod -aG docker $USER

# Install Google Cloud SDK
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update -y
sudo apt-get install google-cloud-sdk -y
}


function rhel_pre_reqs {
# Disable Firewalld
sudo systemctl disable firewalld
sudo systemctl stop firewalld
# Disable SELinux
sudo setenforce 0
sudo curl -Lo /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo

sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOM
[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOM

sudo dnf install docker-ce iptables google-cloud-sdk python3 -y
sudo systemctl enable --now docker
}


function unknown_os {
echo "I don't konw who I am" > /root/who_am_i.txt
}

if [ "$${OS:0:6}" = "centos" ] || [ "$${OS:0:4}" = "rhel" ]; then
rhel_pre_reqs
elif [ "$${OS:0:6}" = "ubuntu" ]; then
ubuntu_pre_reqs
else
unknown_os
fi

# Install kubectl
curl -LO "https://storage.googleapis.com/kubernetes-release/release/v1.18.6/bin/linux/amd64/kubectl"
Expand All @@ -25,8 +67,6 @@ gcloud auth activate-service-account --key-file=keys/gcr.json
gsutil cp gs://anthos-baremetal-release/bmctl/0.7.0-gke.6/linux/bmctl .
chmod a+x bmctl

# Generate boilerplate cluster config
CLUSTER_NAME="${cluster_name}"
./bmctl create config -c $CLUSTER_NAME

# Replace variables in cluster config
Expand Down

0 comments on commit ffdac40

Please sign in to comment.