Puppet Class: profile::environment

Defined in:
modules/profile/manifests/environment.pp

Overview

Class profile::environment

Sets up the base environment for all hosts (profile, editor, sysctl, etc)

Parameters

Parameters:

  • ls_aliases (Boolean) (defaults to: lookup('profile::environment::ls_aliases'))
  • custom_skel_bashrc (Optional[String[1]]) (defaults to: lookup('profile::environment::custom_skel_bashrc'))
  • custom_skel_zshrc (Optional[String[1]]) (defaults to: lookup('profile::environment::custom_skel_zshrc'))
  • custom_bashrc (Optional[String[1]]) (defaults to: lookup('profile::environment::custom_bashrc'))
  • editor (Enum['vim', 'use_default']) (defaults to: lookup('profile::environment::editor'))
  • profile_scripts (Hash[String, Stdlib::Filesource]) (defaults to: lookup('profile::environment::profile_scripts'))


13
14
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'modules/profile/manifests/environment.pp', line 13

class profile::environment (
    Boolean                    $ls_aliases         = lookup('profile::environment::ls_aliases'),
    Optional[String[1]]        $custom_skel_bashrc = lookup('profile::environment::custom_skel_bashrc'),
    Optional[String[1]]        $custom_skel_zshrc  = lookup('profile::environment::custom_skel_zshrc'),
    Optional[String[1]]        $custom_bashrc      = lookup('profile::environment::custom_bashrc'),
    Enum['vim', 'use_default'] $editor             = lookup('profile::environment::editor'),
    Hash[String, Stdlib::Filesource] $profile_scripts = lookup('profile::environment::profile_scripts'),
) {
    if $ls_aliases {
        exec { 'uncomment root bash aliases':
            path    => '/bin:/usr/bin',
            command => "sed -i '
                    /^#alias ll=/ s/^#//
                    /^#alias la=/ s/^#//
                ' /root/.bashrc",
            onlyif  => "grep -q '^#alias ll' /root/.bashrc",
        }
    }

    if $custom_bashrc {
        file { '/etc/bash.bashrc':
                content => template($custom_bashrc),
                owner   => 'root',
                group   => 'root',
                mode    => '0444',
        }
    }
    if $custom_skel_bashrc {
        file { '/etc/skel/.bashrc':
                content => template($custom_skel_bashrc),
                owner   => 'root',
                group   => 'root',
                mode    => '0644',
        }
    }
    if $custom_skel_bashrc {
        file { '/etc/skel/.zshrc':
                content => template($custom_skel_zshrc),
                owner   => 'root',
                group   => 'root',
                mode    => '0644',
        }
    }

    if $editor != 'use_default' {
        file { '/etc/alternatives/editor':
            ensure => link,
            target => "/usr/bin/${editor}",
        }
    }

    $profile_scripts.each |$name, $source| {
        file {
            "/etc/profile.d/${name}":
                ensure => present,
                owner  => 'root',
                group  => 'root',
                mode   => '0444',
                source => $source,
        }
    }

    ### Settings commons to all realms

    $wikimedia_cluster = $::realm ? {
        'labs'  => "labs\n",
        default => "${::site}\n",
    }

    file { '/etc/wikimedia-cluster':
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        content => $wikimedia_cluster,
    }

    # script to generate ssh fingerprints of the server
    file { '/usr/local/bin/gen_fingerprints':
        source => 'puppet:///modules/base/environment/gen_fingerprints',
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    # Global vim defaults
    file { '/etc/vim/vimrc.local':
        owner  => 'root',
        group  => 'root',
        mode   => '0444',
        source => 'puppet:///modules/base/environment/vimrc.local',
    }
}