|
| 1 | +packer { |
| 2 | + required_plugins { |
| 3 | + docker = { |
| 4 | + version = ">= 0.0.7" |
| 5 | + source = "github.com/hashicorp/docker" |
| 6 | + } |
| 7 | + } |
| 8 | +} |
| 9 | + |
| 10 | +variable "docker_username" { |
| 11 | + type = string |
| 12 | + description = "The username to access Docker HUB to push images." |
| 13 | +} |
| 14 | +variable "docker_password" { |
| 15 | + type = string |
| 16 | + description = "The password to access Docker HUB to push images." |
| 17 | +} |
| 18 | + |
| 19 | +source "docker" "ubuntu2204" { |
| 20 | + image = "ubuntu:22.04" |
| 21 | + commit = true |
| 22 | +} |
| 23 | +source "docker" "ubuntu2004" { |
| 24 | + image = "ubuntu:20.04" |
| 25 | + commit = true |
| 26 | +} |
| 27 | +source "docker" "ubuntu1804" { |
| 28 | + image = "ubuntu:18.04" |
| 29 | + commit = true |
| 30 | +} |
| 31 | +source "docker" "debian11" { |
| 32 | + image = "debian:11" |
| 33 | + commit = true |
| 34 | +} |
| 35 | +source "docker" "debian10" { |
| 36 | + image = "debian:10" |
| 37 | + commit = true |
| 38 | +} |
| 39 | +source "docker" "debian9" { |
| 40 | + image = "debian:9" |
| 41 | + commit = true |
| 42 | +} |
| 43 | +source "docker" "debian8" { |
| 44 | + image = "debian:8" |
| 45 | + commit = true |
| 46 | +} |
| 47 | +source "docker" "redhat9" { |
| 48 | + image = "redhat/ubi9-minimal" |
| 49 | + commit = true |
| 50 | +} |
| 51 | +source "docker" "redhat8" { |
| 52 | + image = "redhat/ubi8-minimal" |
| 53 | + commit = true |
| 54 | +} |
| 55 | +source "docker" "redhat7" { |
| 56 | + image = "lijinguo/redhat7.4" |
| 57 | + commit = true |
| 58 | +} |
| 59 | +source "docker" "almalinux9" { |
| 60 | + image = "almalinux:9-minimal" |
| 61 | + commit = true |
| 62 | +} |
| 63 | +source "docker" "almalinux8" { |
| 64 | + image = "almalinux:8-minimal" |
| 65 | + commit = true |
| 66 | +} |
| 67 | +source "docker" "rockylinux9" { |
| 68 | + image = "rockylinux:9-minimal" |
| 69 | + commit = true |
| 70 | +} |
| 71 | +source "docker" "rockylinux8" { |
| 72 | + image = "rockylinux:8-minimal" |
| 73 | + commit = true |
| 74 | +} |
| 75 | +source "docker" "centos8" { |
| 76 | + image = "centos:8" |
| 77 | + commit = true |
| 78 | +} |
| 79 | +source "docker" "centos7" { |
| 80 | + image = "centos:7" |
| 81 | + commit = true |
| 82 | +} |
| 83 | +source "docker" "centos6" { |
| 84 | + image = "centos:6" |
| 85 | + commit = true |
| 86 | +} |
| 87 | +source "docker" "opensuse15" { |
| 88 | + image = "opensuse/leap:15" |
| 89 | + commit = true |
| 90 | +} |
| 91 | + |
| 92 | +build { |
| 93 | + name = "docker-tinypuppet" |
| 94 | + sources = [ |
| 95 | + "source.docker.ubuntu2204", |
| 96 | + "source.docker.ubuntu2004", |
| 97 | + "source.docker.ubuntu1804", |
| 98 | + "source.docker.debian11", |
| 99 | + "source.docker.debian10", |
| 100 | + "source.docker.debian9", |
| 101 | + "source.docker.debian8", |
| 102 | + "source.docker.redhat9", |
| 103 | + "source.docker.redhat8", |
| 104 | + "source.docker.redhat7", |
| 105 | + "source.docker.almalinux9", |
| 106 | + "source.docker.almalinux8", |
| 107 | + "source.docker.rockylinux9", |
| 108 | + "source.docker.rockylinux8", |
| 109 | + "source.docker.centos8", |
| 110 | + "source.docker.centos7", |
| 111 | + "source.docker.centos6", |
| 112 | + "source.docker.opensuse15", |
| 113 | + ] |
| 114 | + provisioner "shell" { |
| 115 | + inline = [ |
| 116 | + "apt-get update && apt-get install -y wget" |
| 117 | + ] |
| 118 | + only = [ |
| 119 | + "docker.ubuntu2204", |
| 120 | + "docker.ubuntu2004", |
| 121 | + "docker.ubuntu1804", |
| 122 | + "docker.debian11", |
| 123 | + "docker.debian10", |
| 124 | + "docker.debian9", |
| 125 | + "docker.debian8", |
| 126 | + ] |
| 127 | + } |
| 128 | + provisioner "shell" { |
| 129 | + inline = [ |
| 130 | + "microdnf install -y wget yum hostname", |
| 131 | + ] |
| 132 | + only = [ |
| 133 | + "docker.almalinux9", |
| 134 | + "docker.almalinux8", |
| 135 | + "docker.rockylinux9", |
| 136 | + "docker.rockylinux8", |
| 137 | + "docker.redhat9", |
| 138 | + "docker.redhat8", |
| 139 | + ] |
| 140 | + } |
| 141 | + |
| 142 | + # Brutal patch of yum repos for EOL CentOS 6 |
| 143 | + provisioner "shell" { |
| 144 | + inline = [ |
| 145 | + "curl https://www.getpagespeed.com/files/centos6-eol.repo --output /etc/yum.repos.d/CentOS-Base.repo", |
| 146 | + ] |
| 147 | + only = [ |
| 148 | + "docker.centos6", |
| 149 | + ] |
| 150 | + } |
| 151 | + |
| 152 | + provisioner "shell" { |
| 153 | + inline = [ |
| 154 | + "yum install -y wget" |
| 155 | + ] |
| 156 | + only = [ |
| 157 | + "docker.centos8", |
| 158 | + "docker.redhat7", |
| 159 | + "docker.centos7", |
| 160 | + "docker.centos6", |
| 161 | + ] |
| 162 | + } |
| 163 | + |
| 164 | + provisioner "shell" { |
| 165 | + inline = [ |
| 166 | + "zypper install -y wget" |
| 167 | + ] |
| 168 | + only = [ |
| 169 | + "docker.opensuse15", |
| 170 | + ] |
| 171 | + } |
| 172 | + |
| 173 | + provisioner "shell" { |
| 174 | + scripts = [ |
| 175 | + "bin/puppet_install.sh", |
| 176 | + "bin/tp_setup.sh" |
| 177 | + ] |
| 178 | + valid_exit_codes = [0, 2] |
| 179 | + } |
| 180 | + provisioner "shell" { |
| 181 | + inline = [ |
| 182 | + "tp install git" |
| 183 | + ] |
| 184 | + valid_exit_codes = [0, 2] |
| 185 | + } |
| 186 | + |
| 187 | + post-processors { |
| 188 | + post-processor "docker-tag" { |
| 189 | + repository = "example42/tiny-puppet-${source.name}" |
| 190 | + tag = ["latest"] |
| 191 | + } |
| 192 | + post-processor "docker-push" { |
| 193 | + login = true |
| 194 | + login_username = "${var.docker_username}" |
| 195 | + login_password = "${var.docker_password}" |
| 196 | + } |
| 197 | + } |
| 198 | + |
| 199 | +} |
0 commit comments