-
Notifications
You must be signed in to change notification settings - Fork 0
How to launch centos jenkins using terraform
Hemanth B edited this page Aug 17, 2020
·
4 revisions
Pre-requisite
- Install latest version of terraform - v0.13.0
- docker
Copy paste below terraform code in the filename: main.tf
terraform {
required_providers {
docker = {
source = "terraform-providers/docker"
}
}
}
provider "docker" {}
resource "docker_network" "jenkinsx" {
name = "jenkinsx"
}
resource "docker_volume" "data_jenkinsx" {}
resource "docker_container" "jenkinsx" {
name = "jenkinsx"
image = "bitroid/centosjenkins:release-3.2.0"
privileged = true
memory = "3072"
network_mode = docker_network.jenkinsx.name
mounts {
target = "/var/lib/jenkins"
source = "data_jenkinsx"
type = "volume"
}
ports {
external = 8080
internal = 8080
protocol = "tcp"
}
}
output "docker_port" {
value = docker_container.jenkinsx.ports[0].external
}
output "ip_address" {
value = docker_container.jenkinsx.ports[0].ip
}
Commands to execute:
Command to download the docker plugin
terraform init
Command to check the plan
terraform plan
Command to execute the terraform code, this command will download the docker image, if it not available in the local system.
terraform apply --auto-approve
Customized CentOS Jenkins