# Packer 1.7 template for the Rundeck controller image.
variable "upstream_version" {
type = string
description = "Tag of the upstream rundeck image used to build this image."
default = "3.4.0"
}
variable "cli_version" {
type = string
description = "Version of the rundeck CLI to install"
default = "1.3.4"
}
variable "version" {
type = string
default = "${env("VERSION")}"
}
source "docker" "rundeck" {
exec_user = "rundeck"
changes = ["ENTRYPOINT /tini -- docker-lib/entry.sh"]
commit = true
image = "rundeck/rundeck:${var.upstream_version}"
}
build {
sources = ["source.docker.rundeck"]
# Add basic tools needed to set up repos
provisioner "shell" {
inline = [
"sudo apt-get update -qqq", "sudo apt-get install -qqq apt-utils software-properties-common"
]
}
# Set Timezone
provisioner "shell" {
environment_vars = [ "TZ=Europe/Rome", "DEBIAN_FRONTEND=noninteractive" ]
inline = [
"sudo ln -s /usr/share/zoneinfo/$TZ /etc/localtime",
"sudo bash -c 'echo $TZ > /etc/timezone'",
"sudo apt-get install tzdata"
]
}
# Configure tool repositories for HashiCorp, Microsoft and Rundeck.
provisioner "shell" {
inline = [
# Add Hashicorp GPG key
# Add Hashicorp repository # Add microsoft repo
"sudo dpkg -i packages-microsoft-prod.deb",
"sudo add-apt-repository universe",
"sudo dpkg -i /home/rundeck/rundeck-cli.deb"
]
}
# Add tools
provisioner "shell" {
# install packages
inline = [
"sudo apt-get update -qqq",
"sudo apt-get -qqq install bash tree unzip vim python3 git python3-pip python3-setuptools python3-virtualenv virtualenv coreutils binutils bind9-host apt-transport-https inetutils-ping inetutils-traceroute jq telnet bind9utils dnsutils ldap-utils lsb-core lsb-security lsb-base lsb powershell vault terraform",
"virtualenv --python=python3 $HOME/tools/virtualenv",
"source $HOME/tools/virtualenv/bin/activate ; pip install --upgrade ansible==2.9.8 kubernetes boto3 awscli boto"
]
}
# Add rundeck plugins
provisioner "shell" {
inline = [
"curl -sSL https://github.com/rundeck-plugins/slack-incoming-webhook-plugin/releases/download/v1.2.5/slack-incoming-webhook-plugin-1.2.5.jar > $HOME/libext/slack-incoming-webhook-plugin-1.2.5.jar", ]
}
# Add our custom realm properties adding users to groups
provisioner "file" {
source = "realm.properties"
destination = "/home/rundeck/server/config/realm.properties"
}
# Custom remco templates
provisioner "file" {
source = "remco/templates/"
destination = "/etc/remco/templates"
}
# Add our custom startup file
provisioner "file" {
source = "entry.sh"
destination = "/home/rundeck/docker-lib/entry.sh"
}
You can see the last few steps are adding the custom realm properties, remco templates and Docker entrypoint script. There are a few internal modifications there such as adding APM to rundeck at startup.