Skip to content

Commit

Permalink
psick::puppet::facter profile and minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
alvagante committed Oct 18, 2023
1 parent 8c97178 commit ecff69b
Show file tree
Hide file tree
Showing 12 changed files with 181 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Changelog

## Release 1.1.0

- More updates for Puppet 8 compatibility
- Added psick::puppet::facter profile to manage facter.conf

## Release 1.0.4

- Updated psick::timezone to support more recent Debian derivatives
Expand Down
3 changes: 2 additions & 1 deletion data/windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ psick::puppet::pe_agent::config_file_path: 'c:/programdata/puppetlabs/puppet/etc
psick::puppet::postrun::puppet_conf_path: 'c:/programdata/puppetlabs/puppet/etc/puppet.conf'
psick::puppet::pe_client_tools::repo_path: 'windows'
psick::puppet::pe_client_tools::package_suffix: '-x64.msi'
psick::puppet::pe_client_tools::package_download_dir: 'c:/tmp'
psick::puppet::pe_client_tools::package_download_dir: 'c:/tmp'
psick::puppet::facter::config_file_dir: 'c:/programdata/puppetlabs/facter/etc'
6 changes: 3 additions & 3 deletions docs/hosts.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ psick::hosts::file class manages /etc/hosts
To customise its behaviour you can set the template to use to manage ```/etc/hosts```, and the ipaddress, domain and hostname values for the local node (by default the relevant facts values are used):

psick::hosts::file::template: 'psick/hosts/file/hosts.erb' # Default value
psick::hosts::file::ipaddress: '10.0.0.4' # Default: $::ipaddress
psick::hosts::file::domain: 'domain.com' # Default: $::domain
psick::hosts::file::hostname: 'www01' # Default: $::hostname
psick::hosts::file::ipaddress: '10.0.0.4' # Default: $::networking['ip']
psick::hosts::file::domain: 'domain.com' # Default: $::networking['domain']
psick::hosts::file::hostname: 'www01' # Default: $::networking['hostname']


56 changes: 55 additions & 1 deletion manifests/admin.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,58 @@
# @class admin
# This class manages an admin user and SSH access on Puppet managed nodes.
#
# == Parameters
#
# [*ensure*]
# Whether the admin user should be present or absent. Defaults to `present`.
#
# [*user_class*]
# The name of the class that manages the admin user on infrastructure nodes. Defaults to `::psick::admin::user`.
# Note: If default is changed other params of this class might not be used.
#
# [*master_class*]
# The name of the class that manages the central master node from which ssh access is granted. Defaults to `::psick::admin::master`.
# Note: If default is changed other params of this class might not be used.
#
# [*node_class*]
# The name of the class that manages nodes which allow access from master node. Defaults to `::psick::admin::node`.
# Note: If default is changed other params of this class might not be used.
#
# [*user*]
# The name of the admin user. Defaults to `admin`.
#
# [*master*]
# The hostname or IP address of the master node. Defaults to `''`.
#
# [*keyshare_method*]
# The method used to share SSH keys between nodes and the master node. Defaults to `storeconfigs`.
#
# [*auto_prereq*]
# Whether to automatically include prerequisite classes. Defaults to the value of `$psick::auto_prereq`.
#
# [*master_enable*]
# Whether to enable master management. If true, master class is included and node is a master. Defaults to `false`.
#
# [*node_enable*]
# Whether to enable node management. If true, node class is included and node can bve controlled from master. Defaults to `true`.
#
# [*manage*]
# Whether to manage any resource on this class. Defaults to the value of `$psick::manage`.
#
# [*noop_manage*]
# Whether to manage noop for this class resources. Defaults to the value of `$psick::noop_manage`.
#
# [*noop_value*]
# The value to use for noop mode. Defaults to the value of `$psick::noop_value`.
#
# == Example
#
# To manage the admin user and SSH access from master node, just include the `psick::admin` class:
#
# include psick::admin
#
# Via Hiera on the master node set:
#
# psick::admin::master_enable: true
#
class psick::admin (

Expand Down
2 changes: 1 addition & 1 deletion manifests/hostname.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
if $update_host_entry {
host { $host:
ensure => present,
host_aliases => $fqdn,
host_aliases => $::networking['fqdn'],
ip => $ip,
}
}
Expand Down
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
Enum['first','hash','deep'] $resources_merge_behaviour = 'deep',
Enum['first','hash','deep'] $resources_defaults_merge_behaviour = 'deep',

# $::osfamily based resources
# $::os['family'] based resources
# Hash $osfamily_resources (lookup with $osfamily_resources_merge_behaviour) = {},
# Hash $osfamily_resources_defaults (lookup with $osfamily_resources_defaults_merge_behaviour) = {},
Enum['first','hash','deep'] $osfamily_resources_merge_behaviour = 'deep',
Expand Down
8 changes: 4 additions & 4 deletions manifests/network/example42.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
# for the file /etc/sysconfig/network
# @param routes Hash of routes to pass to ::network::mroute define
# Note: This is not a real class parameter but a key looked up
# via hiera_hash('psick::network::routes', {})
# via lookup('psick::network::routes', Hash, 'deep', {})
# @param interfaces Hash of interfaces to pass to ::network::interface define
# Note: This is not a real class parameter but a key looked up
# via hiera_hash('psick::network::interfaces', {})
# via lookup('psick::network::interfaces', Hash, 'deep', {})
# Note that this psick automatically adds some default
# options according to the interface type. You can override
# them in the provided hash
Expand All @@ -23,7 +23,7 @@
file { '/etc/modprobe.d/bonding.conf':
ensure => file,
}
$routes = hiera_hash('psick::network::routes', {})
$routes = lookup('psick::network::routes', Hash, 'deep', {})
$routes.each |$r,$o| {
psick::network::route { $r:
routes => $o[routes],
Expand All @@ -45,7 +45,7 @@
bonding_opts => "resend_igmp=1 updelay=30000 use_carrier=1 miimon=100 downdelay=100 xmit_hash_policy=0 primary_reselect=0 fail_over_mac=0 arp_validate=0 mode=${bonding_mode} arp_interval=0 ad_select=0",
bonding_master => 'yes',
}
$interfaces = hiera_hash('psick::network::interfaces', {})
$interfaces = lookup('psick::network::interfaces', Hash, 'deep', {})
$interfaces.each |$r,$o| {
if $r =~ /^bond/ {
$options = $default_options + $default_bonding_options + $o
Expand Down
2 changes: 1 addition & 1 deletion manifests/network/interface.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#
# @param ensure If to create or remove the relevant configuration file.
# @param template The epp or erb template to use for the interface configuration
# file. Default is automatically defined based on $::osfamily,
# file. Default is automatically defined based on $::os['family'],
# @param config_path The path of the interface configuration file.
# Default is automatically defined based on the Operating System.
# @param enable_dhcp If to configure the interface to use dhcp.
Expand Down
49 changes: 49 additions & 0 deletions manifests/puppet/facter.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# @summary A short summary of the purpose of this class
#
# A description of what this class does
#
# @example
# include psick::puppet::facter
class psick::puppet::facter (
Psick::Ensure $ensure = 'present',
Boolean $manage = $psick::manage,
Boolean $noop_manage = $psick::noop_manage,
Boolean $noop_value = $psick::noop_value,
String $config_file_dir = '/etc/puppetlabs/facter',
String $config_file_template = 'psick/puppet/facter/facter.conf.epp',
Hash $cli_settings = {},
Hash $global_settings = {},
Hash $fact_groups = {},
Array[String] $blocklist = [],
Array[Hash] $ttls = [],
) {
if $manage {
if $noop_manage {
noop($noop_value)
}
$parameters = {
cli_settings => $cli_settings,
global_settings => $global_settings,
fact_groups => $fact_groups,
blocklist => $blocklist,
ttls => $ttls,
}
if $cli_settings != {}
or $global_settings != {}
or $fact_groups != {}
or $blocklist != []
or $ttls != [] {
psick::tools::create_dir { "psick::puppet::facter ${config_file_dir}":
path => $config_file_dir,
before => File["${config_file_dir}/facter.conf"],
}
file { "${config_file_dir}/facter.conf":
ensure => $ensure,
owner => 'root',
group => 'root',
mode => '0644',
content => psick::template($config_file_template,$parameters),
}
}
}
}
28 changes: 19 additions & 9 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "example42-psick",
"version": "1.0.4",
"version": "1.1.0",
"author": "Example42",
"summary": "Psick: the infrastructure module.",
"license": "Apache-2.0",
Expand All @@ -10,11 +10,11 @@
"dependencies": [
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 3.2.0 < 7.0.0"
"version_requirement": ">= 3.2.0 < 10.0.0"
},
{
"name": "example42/tp",
"version_requirement": ">= 2.0.3 < 4.0.0"
"version_requirement": ">= 2.0.3 < 5.0.0"
},
{
"name": "example42/psick_profile",
Expand All @@ -30,21 +30,24 @@
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"6",
"7"
"7",
"8"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"6",
"7"
"7",
"8"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"6",
"7"
"7",
"8"
]
},
{
Expand All @@ -57,13 +60,20 @@
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"8"
"8",
"9",
"10",
"11",
"12"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"16.04"
"16.04",
"18.04",
"20.04",
"22.04"
]
},
{
Expand All @@ -79,7 +89,7 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 4.5.0 < 8.0.0"
"version_requirement": ">= 4.5.0 < 9.0.0"
}
],
"description": "Psick Puppet module. A single module to manage an extendable Puppet infrastructure",
Expand Down
13 changes: 13 additions & 0 deletions spec/classes/puppet/facter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'psick::puppet::facter' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }

it { is_expected.to compile.with_all_deps }
end
end
end
28 changes: 28 additions & 0 deletions templates/puppet/facter/facter.conf.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# File managed by Puppet
facts : {
blocklist : <%= $blocklist %>
ttls : [
<% $ttls.each | $k | {-%>
<% $k.each | $kk, $vv | { -%>
{ "<%= $kk %>" : <%= $vv %> },
<% } -%>
<% } -%>
]
}
global : {
<% $global_settings.each | $k,$v | { -%>
<%= $k %> : <%= $v %>,
<% } -%>
}
cli : {
<% $cli_settings.each | $k,$v | { -%>
<%= $k %> : <%= $v %>,
<% } -%>
}
fact-groups : {
<% $fact_groups.each | $k | { -%>
<% $k.each | $kk | { -%>
<%= $k %> : <%= $kk %>,
<% } -%>
<% } -%>
}

0 comments on commit ecff69b

Please sign in to comment.