Skip to content

Commit c35cf31

Browse files
committed
updated with terraform and ansible installations scripts
1 parent b7197e0 commit c35cf31

1 file changed

Lines changed: 71 additions & 13 deletions

File tree

bootstrap.sh

Lines changed: 71 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ install_docker() {
3434
log "Installing Docker CE..."
3535
sudo apt-get remove -y docker docker-engine docker.io containerd runc || true
3636

37-
# Add Dockers official GPG key
37+
# Add Docker's official GPG key
3838
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg
3939

4040
# Set up stable repository
@@ -49,22 +49,55 @@ install_docker() {
4949
sudo usermod -aG docker vagrant || true
5050
}
5151

52-
install_kubernetes_tools() {
53-
log "Installing Kubernetes tools (kubectl, minikube)..."
54-
55-
# Install kubectl
56-
curl -LO "https://dl.k8s.io/release/$(curl -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
57-
chmod +x kubectl
58-
sudo mv kubectl /usr/local/bin/
52+
install_terraform() {
53+
log "Installing Terraform..."
54+
55+
# Install prerequisites
56+
sudo apt-get install -y gnupg software-properties-common curl
57+
58+
# Add HashiCorp GPG key
59+
wget -O- https://apt.releases.hashicorp.com/gpg | \
60+
sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
61+
62+
# Add HashiCorp repository
63+
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
64+
https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
65+
sudo tee /etc/apt/sources.list.d/hashicorp.list
66+
67+
# Install Terraform
68+
sudo apt-get update -y
69+
sudo apt-get install -y terraform
70+
71+
# Verify installation
72+
terraform --version
73+
}
5974

60-
# Install minikube
61-
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
62-
sudo install minikube-linux-amd64 /usr/local/bin/minikube
63-
rm -f minikube-linux-amd64
75+
install_ansible() {
76+
log "Installing Ansible..."
77+
78+
# Update package index and install dependencies
79+
sudo apt-get update -y
80+
sudo apt-get install -y python3-pip
81+
82+
# Install Ansible via pip (more up-to-date version)
83+
pip3 install --user ansible
84+
85+
# Add user bin directory to PATH if not already there
86+
if ! grep -q ".local/bin" ~/.bashrc; then
87+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
88+
fi
89+
export PATH="$HOME/.local/bin:$PATH"
90+
91+
# Install common Ansible collections
92+
ansible-galaxy collection install community.general
93+
94+
# Verify installation
95+
ansible --version
6496
}
6597

6698
install_kubernetes_tools() {
6799
log "Installing Kubernetes tools (kubectl, minikube, kind)..."
100+
68101
# Install kubectl
69102
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
70103
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
@@ -75,14 +108,38 @@ install_kubernetes_tools() {
75108
sudo install minikube-linux-amd64 /usr/local/bin/minikube
76109
rm minikube-linux-amd64
77110

111+
# Install kind
112+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
113+
chmod +x ./kind
114+
sudo mv ./kind /usr/local/bin/kind
115+
}
116+
117+
install_helm() {
118+
log "Installing Helm..."
119+
120+
# Download and install Helm
121+
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
122+
chmod 700 get_helm.sh
123+
./get_helm.sh
124+
rm get_helm.sh
125+
126+
# Add Helm repository
127+
helm repo add stable https://charts.helm.sh/stable
128+
helm repo update
129+
130+
# Verify installation
131+
helm version
78132
}
79133

80134
main() {
81135
update_system
82136
install_basic_tools
83137
install_postgres_client
84138
install_docker
139+
install_terraform
140+
install_ansible
85141
install_kubernetes_tools
142+
install_helm
86143

87144
log "Bootstrap completed!"
88145
log "Please log out and log back in (or run 'newgrp docker') to use Docker without sudo."
@@ -91,6 +148,7 @@ main() {
91148
echo "kubectl label node minikube type=application"
92149
echo "kubectl label node minikube-m02 type=database"
93150
echo "kubectl label node minikube-m03 type=dependent_services"
151+
log "Terraform, Ansible, and Helm are now available for infrastructure automation and package management."
94152
}
95153

96-
main "$@"
154+
main "$@"

0 commit comments

Comments
 (0)