-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Deployment with Terraform | ||
|
||
If you are using Terraform as part of your DevOps stack, you might utilise it to deploy your Kerberos Agents. Within this deployment folder we have added an example Terraform file `docker.tf`, which installs the Kerberos Agent `docker` container on a remote system over `SSH`. We might create our own provider in the future, or add additional examples for example `snap`, `kubernetes`, etc. | ||
|
||
For this example we will install Kerberos Agent using `docker` on a remote `linux` machine. Therefore we'll make sure we have the `TelkomIndonesia/linux` provider initialised. | ||
|
||
terraform init | ||
|
||
Once initialised you should see similar output: | ||
|
||
Initializing the backend... | ||
|
||
Initializing provider plugins... | ||
- Reusing previous version of telkomindonesia/linux from the dependency lock file | ||
- Using previously-installed telkomindonesia/linux v0.7.0 | ||
|
||
Go and open the `docker.tf` file and locate the `linux` provider, modify following credentials accordingly. Make sure they match for creating an `SSH` connection. | ||
|
||
provider "linux" { | ||
host = "x.y.z.u" | ||
port = 22 | ||
user = "root" | ||
password = "password" | ||
} | ||
|
||
Apply the `docker.tf` file, to install `docker` and the `kerberos/agent` docker container. | ||
|
||
terraform apply | ||
|
||
Once done you should see following output, and you should be able to reach the remote machine on port `80` or if configured differently the specified port you've defined. | ||
|
||
Do you want to perform these actions? | ||
Terraform will perform the actions described above. | ||
Only 'yes' will be accepted to approve. | ||
|
||
Enter a value: yes | ||
|
||
linux_script.install_docker_kerberos_agent: Modifying... [id=a56cf7b0-db66-4f9b-beec-8a4dcef2a0c7] | ||
linux_script.install_docker_kerberos_agent: Modifications complete after 3s [id=a56cf7b0-db66-4f9b-beec-8a4dcef2a0c7] | ||
|
||
Apply complete! Resources: 0 added, 1 changed, 0 destroyed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
terraform { | ||
required_providers { | ||
linux = { | ||
source = "TelkomIndonesia/linux" | ||
version = "0.7.0" | ||
} | ||
} | ||
} | ||
|
||
provider "linux" { | ||
host = "x.y.z.u" | ||
port = 22 | ||
user = "root" | ||
password = "password" | ||
} | ||
|
||
locals { | ||
image = "kerberos/agent" | ||
version = "latest" | ||
port = 80 | ||
} | ||
|
||
resource "linux_script" "install_docker" { | ||
lifecycle_commands { | ||
create = "apt update && apt install -y $PACKAGE_NAME" | ||
read = "apt-cache policy $PACKAGE_NAME | grep 'Installed:' | grep -v '(none)' | awk '{ print $2 }' | xargs | tr -d '\n'" | ||
update = "apt update && apt install -y $PACKAGE_NAME" | ||
delete = "apt remove -y $PACKAGE_NAME" | ||
} | ||
environment = { | ||
PACKAGE_NAME = "docker" | ||
} | ||
} | ||
|
||
resource "linux_script" "install_docker_kerberos_agent" { | ||
lifecycle_commands { | ||
create = "docker pull $IMAGE:$VERSION && docker run -d -p $PORT:80 --name agent $IMAGE:$VERSION" | ||
read = "docker inspect agent" | ||
update = "docker pull $IMAGE:$VERSION && docker rm agent --force && docker run -d -p $PORT:80 --name agent $IMAGE:$VERSION" | ||
delete = "docker rm agent --force" | ||
} | ||
environment = { | ||
IMAGE = local.image | ||
VERSION = local.version | ||
PORT = local.port | ||
} | ||
} |