Skip to content

Commit ffdac40

Browse files
authored
CentOS 8 Support and Ubuntu 18.04 tested (#20)
1 parent de59b6e commit ffdac40

File tree

4 files changed

+68
-22
lines changed

4 files changed

+68
-22
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,15 @@ Worker_Public_IPs = [
142142
| Name | Api Slug |
143143
| :-----------------------: | :----------: |
144144
| CentOS 8 | centos_8 |
145-
| RedHat Enterprise Linux 8 | rhel_8 |
146145
| Ubuntu 18.04 | ubuntu_18_04 |
147146
| Ubutnu 20.04 | ubuntu_20_04 |
148147

148+
## Operating Systems that need fixing
149+
| Name | Api Slug |
150+
| :-----------------------: | :----------: |
151+
| Red Hat Enterprise Linux 8 | rhel_8 |
152+
153+
149154
## Variables
150155

151156
| Variable Name | Type | Default Value | Description |

main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,10 @@ resource "null_resource" "write_ssh_private_key" {
133133
}
134134

135135
data "template_file" "deploy_anthos_cluster" {
136-
template = file("templates/deploy_cluster.sh")
136+
template = file("templates/pre_reqs.sh")
137137
vars = {
138-
cluster_name = local.cluster_name
138+
cluster_name = local.cluster_name
139+
operating_system = var.operating_system
139140
}
140141
}
141142

@@ -168,7 +169,7 @@ resource "null_resource" "prep_anthos_cluster" {
168169

169170
provisioner "file" {
170171
content = data.template_file.deploy_anthos_cluster.rendered
171-
destination = "/root/baremetal/deploy_cluster.sh"
172+
destination = "/root/baremetal/pre_reqs.sh"
172173
}
173174

174175
provisioner "file" {
@@ -177,7 +178,7 @@ resource "null_resource" "prep_anthos_cluster" {
177178
}
178179

179180
provisioner "remote-exec" {
180-
inline = ["bash /root/baremetal/deploy_cluster.sh"]
181+
inline = ["bash /root/baremetal/pre_reqs.sh"]
181182
}
182183
}
183184

output.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ output "Worker_Node_Tags" {
2828
description = "Worker Node Tags"
2929
}
3030

31-
output "ssh_key_lcation" {
31+
output "ssh_key_location" {
3232
value = local_file.cluster_private_key_pem.filename
3333
description = "The SSH Private Key File Location"
3434
}
Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,60 @@
11
#!/bin/bash
2-
# Install Docker
3-
sudo apt update -y
4-
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg -y
5-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
6-
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" -y
7-
sudo apt update -y
8-
sudo apt install docker-ce -y
9-
sudo usermod -aG docker $USER
10-
11-
# Install Google Cloud SDK
12-
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
13-
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
14-
sudo apt-get update -y
15-
sudo apt-get install google-cloud-sdk -y
2+
CLUSTER_NAME='${cluster_name}'
3+
OS='${operating_system}'
4+
5+
function ubuntu_pre_reqs {
6+
# Install Docker
7+
sudo apt update -y
8+
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg -y
9+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
10+
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" -y
11+
sudo apt update -y
12+
sudo apt install docker-ce -y
13+
sudo usermod -aG docker $USER
14+
15+
# Install Google Cloud SDK
16+
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
17+
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
18+
sudo apt-get update -y
19+
sudo apt-get install google-cloud-sdk -y
20+
}
21+
22+
23+
function rhel_pre_reqs {
24+
# Disable Firewalld
25+
sudo systemctl disable firewalld
26+
sudo systemctl stop firewalld
27+
# Disable SELinux
28+
sudo setenforce 0
29+
sudo curl -Lo /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
30+
31+
sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo << EOM
32+
[google-cloud-sdk]
33+
name=Google Cloud SDK
34+
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
35+
enabled=1
36+
gpgcheck=1
37+
repo_gpgcheck=1
38+
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
39+
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
40+
EOM
41+
42+
sudo dnf install docker-ce iptables google-cloud-sdk python3 -y
43+
sudo systemctl enable --now docker
44+
}
45+
46+
47+
function unknown_os {
48+
echo "I don't konw who I am" > /root/who_am_i.txt
49+
}
50+
51+
if [ "$${OS:0:6}" = "centos" ] || [ "$${OS:0:4}" = "rhel" ]; then
52+
rhel_pre_reqs
53+
elif [ "$${OS:0:6}" = "ubuntu" ]; then
54+
ubuntu_pre_reqs
55+
else
56+
unknown_os
57+
fi
1658

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

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

3272
# Replace variables in cluster config

0 commit comments

Comments
 (0)