Install and remove a program in the same Puppet declaration

The program I want on my VM requires 7-zip as part of the installation process but not after the install. I want to leave the VM as clean as possible by removing 7-zip after the install is done. In puppet it seems like it would be easy enough to declare once to ensure present and again later to ensure absent.

I am currently stuck with a Duplicate declaration error. In my case 7-zip but this could appear for any package.

Duplicate declaration: Package[7-Zip 19.00 (x64 edition)] is already

I have the code split into multiple classes but here is what is looks like in a single manifest.

$installer_location = 'puppet:///resources/'
$installer_name = "7z1900-${::architecture}.msi"
$install_directory = 'C:/temp/'

#Create directory for installer
file { 'install_dir':
  ensure => directory,
  path   => $install_directory,

# Copy installer local 
file { 'Copy_7zip_installer':
  ensure => present,
  path   => "${install_directory}${installer_name}",
  source => "${installer_location}${installer_name}",

# install 7zip 
package { 'Install 7-zip':
  ensure   => present,
  provider => 'windows',
  source   => "${install_directory}${installer_name}",

#Use 7-zip to unpack archive and do pipelines agent install
String $package_path = lookup('azure_pipelines_agent::package_source')
String $package_name = lookup('azure_pipelines_agent::package_name')
String $install_path = lookup('azure_pipelines_agent::install_path')

# Create the install directory
file { 'install-path':
ensure => directory,
  path   => $install_path,

# Copy Azure pipeline package
# Due to a bug the archive forge module requires 7-zip 
# instead of defaulting to powershell for .zip files
archive { 'extract_azure_package':
  source       => $package_path,
  path         => "${install_path}${package_name}",
  extract      => true,
  extract_path => $install_path,
  cleanup      => true,

# uninstall 7zip 
# The title (or name) of the package must match the value of the package’s DisplayName property in the registry
package { '7-Zip 19.00 (x64 edition)':
  ensure   => absent,
  provider => 'windows',
  source   => "${install_directory}${installer_name}",

# ... Configuration and setup of Azure Pipeline Agent

Is there a simple means of working around what puppet sees as a duplicate declaration?

Go to Source
Author: JaredStroeb

Automating puppet master deployment with r10k

I am looking to automate the process of standing up and tearing down a development environment. Puppet currently manages the production and staging systems. I am looking to leverage r10k to populate the Puppet master environments, starting with dev. My issue is, how do I provide a secret key to the Puppet master that it can use to access bit bucket repo’s in an automated fashion? My plan is to use Terraform to codify the infrastructure and puppet to manage the systems. When the development suite isn’t needed, I would like to be able to tear it down completely.

Go to Source
Author: deejay