Skip to content

Commit

Permalink
Fix for Terraform provisioning #103
Browse files Browse the repository at this point in the history
Signed-off-by: cbkhare <[email protected]>

Fix for Terraform provisioning #103

Fix for Terraform provisioning #103

Fix for Terraform provisioning #103

Signed-off-by: cbkhare <[email protected]>

Fix for Terraform provisioning #103

Signed-off-by: cbkhare <[email protected]>

Fix for Terraform provisioning #103

Removal of Packet references

This removes the `_packet` from the health end point and renames it to the standard `healthz`. It also renames environment variables to TINKERBELL inline with the project

Signed-off-by: thebsdbox <[email protected]>

Revert of env variables

Signed-off-by: thebsdbox <[email protected]>
  • Loading branch information
Cbkhare committed Aug 19, 2020
1 parent 2e9b5f6 commit 7272445
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
66 changes: 66 additions & 0 deletions deploy/terraform/install_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash

YUM="yum"
APT="apt"
PIP3="pip3"
YUM_CONFIG_MGR="yum-config-manager"
WHICH_YUM=$(command -v $YUM)
WHICH_APT=$(command -v $APT)
YUM_INSTALL="$YUM install"
APT_INSTALL="$APT install"
PIP3_INSTALL="$PIP3 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
DEBIAN_FRONTEND=noninteractive $APT --yes --force-yes -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
)

restart_docker_service() (
service docker restart
)

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 [[ -n $WHICH_YUM ]]; then
update_yum
install_yum_packages
install_pip3_packages
restart_docker_service
elif [[ -n $WHICH_APT ]]; then
update_apt
install_apt_packages
restart_docker_service
else
echo "Unknown platform. Error while installing the required packages"
exit 1
fi
)

main
3 changes: 3 additions & 0 deletions deploy/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ resource "packet_device" "tink-provisioner" {
billing_cycle = "hourly"
project_id = var.project_id
network_type = "hybrid"
user_data = "${file("install_package.sh")}"
}

}

# Create a device and add it to tf_project_1
Expand Down
2 changes: 1 addition & 1 deletion http-server/http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func SetupHTTP(ctx context.Context, lg log.Logger, certPEM []byte, modTime time.
http.Handle("/metrics", promhttp.Handler())
setupGitRevJSON()
http.HandleFunc("/version", versionHandler)
http.HandleFunc("/_packet/healthcheck", healthCheckHandler)
http.HandleFunc("/healthz", healthCheckHandler)
http.Handle("/", BasicAuth(mux))

if httpListenAddr == "" {
Expand Down
2 changes: 1 addition & 1 deletion test/_vagrant/vagrant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestVagrantSetupGuide(t *testing.T) {
}

for ii := 0; ii < 5; ii++ {
resp, err := http.Get("http://localhost:42114/_packet/healthcheck")
resp, err := http.Get("http://localhost:42114/healthz")
if err != nil || resp.StatusCode != http.StatusOK {
if err != nil {
t.Logf("err tinkerbell healthcheck... retrying: %s", err)
Expand Down

0 comments on commit 7272445

Please sign in to comment.