# Class: profile::puppet::g10k # # This class handles downloading and installation of the g10k tool, a fast # Git and Forge based Puppet environment and module deployment tool. # The latest release of g10k is downloaded from GitHub and placed into '/opt/puppetlabs/bin'. # Additionally, it creates a helper script to easily run g10k with the appropriate configuration. # It also creates a systemd service and timer that runs the g10k script every minute. # # Parameters: None # # Actions: # - Downloads the latest g10k release from GitHub. # - Extracts the download and places the executable in '/opt/puppetlabs/bin'. # - Creates a helper script '/opt/puppetlabs/bin/puppet-g10k' for easy usage of g10k. # - Creates a systemd service and timer that runs the g10k script every minute. # # Usage: # Directly including the class in your node definitions or classify your nodes # using an ENC or Hiera. # Example: # node 'puppet.example.com' { # include profile::puppet::g10k # } # # Requirements: # - The 'puppet-archive' module should be installed in your puppetmaster. # - The 'puppet-systemd' module should be installed on your puppetmaster. # - '/opt/puppetlabs/bin/' directory must exist and be writable. # - Puppet master must have access to the GitHub URL. # # Limitations: # This is designed to work on Unix-like systems only. class profile::puppet::g10k { package { 'unzip': ensure => installed, } archive { '/tmp/g10k.zip': ensure => present, source => 'https://github.com/xorpaul/g10k/releases/latest/download/g10k-linux-amd64.zip', extract => true, extract_path => '/opt/puppetlabs/bin', creates => '/opt/puppetlabs/bin/g10k', cleanup => true, } file { '/opt/puppetlabs/bin/puppet-g10k': ensure => file, owner => 'root', group => 'root', mode => '0755', content => "#!/usr/bin/bash\n/opt/puppetlabs/bin/g10k -config /etc/puppetlabs/r10k/r10k.yaml\n", require => Archive['/tmp/g10k.zip'], } systemd::service { 'puppet-g10k': description => 'puppet-g10k update service', execstart => '/opt/puppetlabs/bin/puppet-g10k', user => 'root', require => File['/opt/puppetlabs/bin/puppet-g10k'], } systemd::timer { 'puppet-g10k': description => 'Run puppet-g10k every minute', unit => 'puppet-g10k.service', on_calendar => '*:0/1', require => Systemd::Service['puppet-g10k'], } }