Skip to content

Commit

Permalink
Fix for Terraform provisioning #103
Browse files Browse the repository at this point in the history
  • Loading branch information
Cbkhare committed Aug 17, 2020
1 parent 74ef27e commit 1027103
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
60 changes: 60 additions & 0 deletions deploy/terraform/install_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#! /bin/bash

YUM="yum"
APT="apt"
PIP3="pip3"
YUM_CONFIG_MGR="yum-config-manager"
WHICH_YUM=$(which $YUM)
WHICH_APT=$(which $APT)
YUM_INSTALL="$YUM install"
APT_INSTALL="$APT install"
PIP3_INSTALL="$PIP install"
declare -a YUM_LIST=("https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm"
"docker-ce"
"docker-ce-cli"
"epel-release"
"python3")
declare -a APT_LIST=("docker"
"docker-compose")

add_yum_repo() (
$YUM_CONFIG_MGR --add-repo https://download.docker.com/linux/centos/docker-ce.repo
)

update_yum() (
$YUM_INSTALL -y yum-utils
add_yum_repo
)

update_apt() (
$APT update
$APT upgrade -y
)

install_yum_packages() (
$YUM_INSTALL ${YUM_LIST[@]} -y
)

install_pip3_packages() (
$PIP3_INSTALL docker-compose
)

install_apt_packages() (
$APT_INSTALL ${APT_LIST[@]} -y
)

main() (
if [[ ! -z $WHICH_YUM ]]; then
update_yum
install_yum_packages
install_pip3_packages
elif [[ ! -z $WHICH_APT ]]; then
update_apt
install_apt_packages
else
echo "Unknown platform. Error while installing the required packages"
exit 1;
fi
)

main
12 changes: 12 additions & 0 deletions deploy/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ resource "packet_device" "tink-provisioner" {
billing_cycle = "hourly"
project_id = var.project_id
network_type = "hybrid"

provisioner "file" {
source = "install_package.sh"
destination = "/tmp/install_package.sh"
}

provisioner "remote-exec" {
inline = [
"chmod +x /tmp/install_package.sh",
"sudo /tmp/install_package.sh",
]
}
}

# Create a device and add it to tf_project_1
Expand Down

0 comments on commit 1027103

Please sign in to comment.