Puppet Class: cis_security_hardening::config

Defined in:
manifests/config.pp

Summary

Configure the module

Overview

Create files, install scripts and cron jobs

Examples:

include cis_security_hardening::config

Parameters:

  • update_postrun_command (Boolean)

    Update Puppet agent’s postrun command.

  • base_dir (Stdlib::Absolutepath)

    Directory where all files go to.

  • fact_upload_command (Stdlib::Absolutepath)

    Command to use for fact upload.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'manifests/config.pp', line 15

class cis_security_hardening::config (
  Boolean $update_postrun_command,
  Stdlib::Absolutepath $base_dir,
  Stdlib::Absolutepath $fact_upload_command,
) {
  file { $base_dir:
    ensure => directory,
    owner  => 'root',
    group  => 'root',
    mode   => '0700',
  }

  file { "${base_dir}/logs":
    ensure => directory,
    owner  => 'root',
    group  => 'root',
    mode   => '0700',
  }

  file { "${base_dir}/data":
    ensure => directory,
    owner  => 'root',
    group  => 'root',
    mode   => '0700',
  }

  file { "${base_dir}/bin":
    ensure => directory,
    owner  => 'root',
    group  => 'root',
    mode   => '0700',
  }

  file { "${base_dir}/bin/fact_upload.sh":
    ensure  => file,
    content => epp('cis_security_hardening/fact_upload.sh.epp', {
    }),
    owner   => 'root',
    group   => 'root',
    mode    => '0700',
  }

  if $update_postrun_command {
    if fact('cis_security_hardening.puppet_agent_postrun') != "postrun_command = ${fact_upload_command}" {
      file_line { 'append postrun command agent':
        path               => '/etc/puppetlabs/puppet/puppet.conf',
        after              => '[agent]',
        match              => 'postrun_command\s*=',
        line               => "postrun_command = ${fact_upload_command}",
        append_on_no_match => true,
      }

      file_line { 'append postrun command main':
        path               => '/etc/puppetlabs/puppet/puppet.conf',
        after              => 'certname\s*=.*',
        match              => 'postrun_command\s*=',
        line               => "postrun_command = ${fact_upload_command}",
        append_on_no_match => true,
      }
    }
  }
}