diff --git a/Makefile b/Makefile index a0aafde..08ede4e 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ endif PACKER ?= packer -# Possible values for CM: (nocm | chef | chefdk | salt | puppet) +# Possible values for CM: (nocm | chef | chefdk | salt | puppet | puppet_collections) CM ?= nocm # Possible values for CM_VERSION: (latest | x.y.z | x.y) CM_VERSION ?= @@ -32,6 +32,10 @@ PACKER_VARS_LIST = 'cm=$(CM)' 'headless=$(HEADLESS)' 'update=$(UPDATE)' 'version ifdef CM_VERSION PACKER_VARS_LIST += 'cm_version=$(CM_VERSION)' endif +ifdef CM_PC_VERSION + PACKER_VARS_LIST += 'cm_pc_version=$(CM_PC_VERSION)' +endif + PACKER_VARS := $(addprefix -var , $(PACKER_VARS_LIST)) ifdef PACKER_DEBUG diff --git a/README.md b/README.md index d0518b4..ac8e066 100644 --- a/README.md +++ b/README.md @@ -97,12 +97,15 @@ Possible values for the CM variable are: * `nocm` - No configuration management tool * `chef` - Install Chef * `puppet` - Install Puppet +* `puppet_collections` - Install a Puppet Collection * `salt` - Install Salt You can also specify a variable `CM_VERSION`, if supported by the configuration management tool, to override the default of `latest`. The value of `CM_VERSION` should have the form `x.y` or `x.y.z`, such as `CM_VERSION := 11.12.4` +Using Puppet Collections, you can specify the Puppet Collection version +via `CM_PC_VERSION`, such as `CM_PC_VERSION := pc1` The variable `HEADLESS` can be set to run Packer in headless mode. Set `HEADLESS := true`, the default is false. diff --git a/debian6010-i386.json b/debian6010-i386.json index e5dcc5c..0f6beee 100644 --- a/debian6010-i386.json +++ b/debian6010-i386.json @@ -134,6 +134,7 @@ "environment_vars": [ "CM={{user `cm`}}", "CM_VERSION={{user `cm_version`}}", + "CM_PC_VERSION={{user `cm_pc_version`}}", "CLEANUP_PAUSE={{user `cleanup_pause`}}", "UPDATE={{user `update`}}", "INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}", @@ -162,6 +163,7 @@ "cleanup_pause": "", "cm": "nocm", "cm_version": "", + "cm_pc_version": "", "disk_size": "40000", "ftp_proxy": "{{env `ftp_proxy`}}", "headless": "", diff --git a/debian6010.json b/debian6010.json index fe7c6c2..16cd535 100644 --- a/debian6010.json +++ b/debian6010.json @@ -134,6 +134,7 @@ "environment_vars": [ "CM={{user `cm`}}", "CM_VERSION={{user `cm_version`}}", + "CM_PC_VERSION={{user `cm_pc_version`}}", "CLEANUP_PATH={{user `cleanup_pause`}}", "UPDATE={{user `update`}}", "INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}", @@ -162,6 +163,7 @@ "cleanup_pause": "", "cm": "nocm", "cm_version": "", + "cm_pc_version": "", "disk_size": "40000", "ftp_proxy": "{{env `ftp_proxy`}}", "headless": "", diff --git a/debian75-i386.json b/debian75-i386.json index a1c5359..fd606b7 100644 --- a/debian75-i386.json +++ b/debian75-i386.json @@ -119,6 +119,7 @@ "environment_vars": [ "CM={{user `cm`}}", "CM_VERSION={{user `cm_version`}}", + "CM_PC_VERSION={{user `cm_pc_version`}}", "CLEANUP_PAUSE={{user `cleanup_pause`}}", "UPDATE={{user `update`}}", "INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}", @@ -147,6 +148,7 @@ "cleanup_pause": "", "cm": "nocm", "cm_version": "", + "cm_pc_version": "", "disk_size": "40000", "ftp_proxy": "{{env `ftp_proxy`}}", "headless": "", diff --git a/debian75.json b/debian75.json index 8bcb9d1..b3b3ece 100644 --- a/debian75.json +++ b/debian75.json @@ -119,6 +119,7 @@ "environment_vars": [ "CM={{user `cm`}}", "CM_VERSION={{user `cm_version`}}", + "CM_PC_VERSION={{user `cm_pc_version`}}", "CLEANUP_PAUSE={{user `cleanup_pause`}}", "UPDATE={{user `update`}}", "INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}", @@ -147,6 +148,7 @@ "cleanup_pause": "", "cm": "nocm", "cm_version": "", + "cm_pc_version": "", "disk_size": "40000", "ftp_proxy": "{{env `ftp_proxy`}}", "headless": "", diff --git a/debian76-i386.json b/debian76-i386.json index 5def210..ad32b1b 100644 --- a/debian76-i386.json +++ b/debian76-i386.json @@ -117,6 +117,7 @@ "environment_vars": [ "CM={{user `cm`}}", "CM_VERSION={{user `cm_version`}}", + "CM_PC_VERSION={{user `cm_pc_version`}}", "CLEANUP_PAUSE={{user `cleanup_pause`}}", "UPDATE={{user `update`}}", "INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}", @@ -145,6 +146,7 @@ "cleanup_pause": "", "cm": "nocm", "cm_version": "", + "cm_pc_version": "", "disk_size": "40000", "ftp_proxy": "{{env `ftp_proxy`}}", "headless": "", diff --git a/debian76.json b/debian76.json index c8a9412..d88d6fe 100644 --- a/debian76.json +++ b/debian76.json @@ -119,6 +119,7 @@ "environment_vars": [ "CM={{user `cm`}}", "CM_VERSION={{user `cm_version`}}", + "CM_PC_VERSION={{user `cm_pc_version`}}", "CLEANUP_PAUSE={{user `cleanup_pause`}}", "UPDATE={{user `update`}}", "INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}", @@ -147,6 +148,7 @@ "cleanup_pause": "", "cm": "nocm", "cm_version": "", + "cm_pc_version": "", "disk_size": "40000", "ftp_proxy": "{{env `ftp_proxy`}}", "headless": "", diff --git a/debian77-i386.json b/debian77-i386.json index 4b83ebf..2d875a0 100644 --- a/debian77-i386.json +++ b/debian77-i386.json @@ -117,6 +117,7 @@ "environment_vars": [ "CM={{user `cm`}}", "CM_VERSION={{user `cm_version`}}", + "CM_PC_VERSION={{user `cm_pc_version`}}", "CLEANUP_PAUSE={{user `cleanup_pause`}}", "UPDATE={{user `update`}}", "INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}", @@ -145,6 +146,7 @@ "cleanup_pause": "", "cm": "nocm", "cm_version": "", + "cm_pc_version": "", "disk_size": "40000", "ftp_proxy": "{{env `ftp_proxy`}}", "headless": "", diff --git a/debian77.json b/debian77.json index 58b79eb..31befab 100644 --- a/debian77.json +++ b/debian77.json @@ -119,6 +119,7 @@ "environment_vars": [ "CM={{user `cm`}}", "CM_VERSION={{user `cm_version`}}", + "CM_PC_VERSION={{user `cm_pc_version`}}", "CLEANUP_PAUSE={{user `cleanup_pause`}}", "UPDATE={{user `update`}}", "INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}", @@ -147,6 +148,7 @@ "cleanup_pause": "", "cm": "nocm", "cm_version": "", + "cm_pc_version": "", "disk_size": "40000", "ftp_proxy": "{{env `ftp_proxy`}}", "headless": "", diff --git a/debian78-i386.json b/debian78-i386.json index df60bb8..fb8f1dd 100644 --- a/debian78-i386.json +++ b/debian78-i386.json @@ -137,6 +137,7 @@ "environment_vars": [ "CM={{user `cm`}}", "CM_VERSION={{user `cm_version`}}", + "CM_PC_VERSION={{user `cm_pc_version`}}", "CLEANUP_PAUSE={{user `cleanup_pause`}}", "UPDATE={{user `update`}}", "INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}", @@ -165,6 +166,7 @@ "cleanup_pause": "", "cm": "nocm", "cm_version": "", + "cm_pc_version": "", "disk_size": "40000", "ftp_proxy": "{{env `ftp_proxy`}}", "headless": "", diff --git a/debian78.json b/debian78.json index f6ab3c0..917b197 100644 --- a/debian78.json +++ b/debian78.json @@ -139,6 +139,7 @@ "environment_vars": [ "CM={{user `cm`}}", "CM_VERSION={{user `cm_version`}}", + "CM_PC_VERSION={{user `cm_pc_version`}}", "CLEANUP_PAUSE={{user `cleanup_pause`}}", "UPDATE={{user `update`}}", "INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}", @@ -167,6 +168,7 @@ "cleanup_pause": "", "cm": "nocm", "cm_version": "", + "cm_pc_version": "", "disk_size": "40000", "ftp_proxy": "{{env `ftp_proxy`}}", "headless": "", diff --git a/debian80-i386.json b/debian80-i386.json index 129fcac..622486f 100644 --- a/debian80-i386.json +++ b/debian80-i386.json @@ -137,6 +137,7 @@ "environment_vars": [ "CM={{user `cm`}}", "CM_VERSION={{user `cm_version`}}", + "CM_PC_VERSION={{user `cm_pc_version`}}", "CLEANUP_PAUSE={{user `cleanup_pause`}}", "UPDATE={{user `update`}}", "INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}", @@ -165,6 +166,7 @@ "cleanup_pause": "", "cm": "nocm", "cm_version": "", + "cm_pc_version": "", "disk_size": "40000", "ftp_proxy": "{{env `ftp_proxy`}}", "headless": "", diff --git a/debian80.json b/debian80.json index 946840c..68ca233 100644 --- a/debian80.json +++ b/debian80.json @@ -139,6 +139,7 @@ "environment_vars": [ "CM={{user `cm`}}", "CM_VERSION={{user `cm_version`}}", + "CM_PC_VERSION={{user `cm_pc_version`}}", "CLEANUP_PAUSE={{user `cleanup_pause`}}", "UPDATE={{user `update`}}", "INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}", @@ -167,6 +168,7 @@ "cleanup_pause": "", "cm": "nocm", "cm_version": "", + "cm_pc_version": "", "disk_size": "40000", "ftp_proxy": "{{env `ftp_proxy`}}", "headless": "", diff --git a/debian81-i386.json b/debian81-i386.json index 8f8a811..b359cfb 100644 --- a/debian81-i386.json +++ b/debian81-i386.json @@ -137,6 +137,7 @@ "environment_vars": [ "CM={{user `cm`}}", "CM_VERSION={{user `cm_version`}}", + "CM_PC_VERSION={{user `cm_pc_version`}}", "CLEANUP_PAUSE={{user `cleanup_pause`}}", "UPDATE={{user `update`}}", "INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}", @@ -165,6 +166,7 @@ "cleanup_pause": "", "cm": "nocm", "cm_version": "", + "cm_pc_version": "", "disk_size": "40000", "ftp_proxy": "{{env `ftp_proxy`}}", "headless": "", diff --git a/debian81.json b/debian81.json index 301afd9..e7c985c 100644 --- a/debian81.json +++ b/debian81.json @@ -139,6 +139,7 @@ "environment_vars": [ "CM={{user `cm`}}", "CM_VERSION={{user `cm_version`}}", + "CM_PC_VERSION={{user `cm_pc_version`}}", "CLEANUP_PAUSE={{user `cleanup_pause`}}", "UPDATE={{user `update`}}", "INSTALL_VAGRANT_KEY={{user `install_vagrant_key`}}", @@ -167,6 +168,7 @@ "cleanup_pause": "", "cm": "nocm", "cm_version": "", + "cm_pc_version": "", "disk_size": "40000", "ftp_proxy": "{{env `ftp_proxy`}}", "headless": "", diff --git a/script/cmtool.sh b/script/cmtool.sh index 6b1deb8..87a5633 100644 --- a/script/cmtool.sh +++ b/script/cmtool.sh @@ -8,6 +8,7 @@ # 'chefdk' -- build a box with Chef Development Kit # 'salt' -- build a box with Salt # 'puppet' -- build a box with Puppet +# 'puppet_collections' -- build a box with Puppet Collections # # Values for CM_VERSION can be (when CM is chef|chefdk|salt|puppet): # 'x.y.z' -- build a box with version x.y.z of Chef @@ -81,6 +82,24 @@ install_puppet() rm -f ${DEB_NAME} } +install_puppet_collections() +{ + echo "==> Installing Puppet Collections ${CM_PC_VERSION}" + DEB_RELEASE=$(/usr/bin/lsb_release -cs) + DEB_NAME="puppetlabs-release-${CM_PC_VERSION}-${DEB_RELEASE}.deb" + wget http://apt.puppetlabs.com/${DEB_NAME} + dpkg -i ${DEB_NAME} + apt-get update + if [[ ${CM_VERSION:-} == 'latest' ]]; then + echo "==> Installing latest puppet-agent version" + apt-get install -y puppet-agent + else + echo "==> Installing puppet-agent version $CM_VERSION" + apt-get install -y puppet-agent=$CM_VERSION$DEB_RELEASE + fi + + rm -f ${DEB_NAME} +} # # Main script # @@ -102,6 +121,10 @@ case "${CM}" in install_puppet ;; + 'puppet_collections') + install_puppet_collections + ;; + *) echo "==> Building box without baking in a configuration management tool" ;;