This repository was archived by the owner on Feb 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathserver.pp
131 lines (111 loc) · 3.04 KB
/
server.pp
1
2
3
4
5
6
7
8
9
10
11
12
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
class puphpet::server {
include ::puphpet::params
include ::git
include ::ntp
include ::swap_file
$server = $puphpet::params::hiera['server']
each( ['puppet', 'www-data', 'www-user'] ) |$group| {
if ! defined(Group[$group]) {
group { $group:
ensure => present
}
}
}
case $puphpet::params::ssh_username {
'root': {
$user_home = '/root'
$manage_home = false
}
default: {
$user_home = "/home/${puphpet::params::ssh_username}"
$manage_home = true
}
}
@user { $puphpet::params::ssh_username:
ensure => present,
shell => '/bin/bash',
home => $user_home,
managehome => $manage_home,
groups => ['www-data', 'www-user'],
require => [Group['www-data'], Group['www-user']],
}
realize(User[$puphpet::params::ssh_username])
each( ['apache', 'nginx', 'httpd', 'www-data', 'www-user'] ) |$key| {
if ! defined(User[$key]) {
user { $key:
ensure => present,
shell => '/bin/bash',
groups => 'www-data',
require => Group['www-data']
}
}
}
# copy dot files to ssh user's home directory
if ! defined(Puphpet::Server::Link_dotfiles[$puphpet::params::ssh_username]) {
puphpet::server::link_dotfiles { $puphpet::params::ssh_username: }
}
case $::osfamily {
'debian': {
include apt
Class['apt::update'] -> Package <|
title != 'python-software-properties' and
title != 'software-properties-common'
|>
if ! defined(Package['augeas-tools']) {
package { 'augeas-tools':
ensure => present,
}
}
}
'redhat': {
class { 'yum': extrarepo => ['epel'] }
Class['::yum'] -> Yum::Managed_yumrepo <| |> -> Package <| |>
if ! defined(Package['augeas']) {
package { 'augeas':
ensure => present,
}
}
}
default: {
error('PuPHPet currently only works with Debian and RHEL families')
}
}
case $::operatingsystem {
'ubuntu': {
if ! defined(Apt::Key['14AA40EC0831756756D7F66C4F4EA0AAE5267A6C']){
apt::key { '14AA40EC0831756756D7F66C4F4EA0AAE5267A6C':
server => 'hkp://keyserver.ubuntu.com:80'
}
}
if ! defined(Apt::Key['945A6177078449082DDCC0E5551CE2FB4CBEDD5A']){
apt::key { '945A6177078449082DDCC0E5551CE2FB4CBEDD5A':
server => 'hkp://keyserver.ubuntu.com:80'
}
}
apt::ppa { 'ppa:pdoes/ppa':
require => Apt::Key['945A6177078449082DDCC0E5551CE2FB4CBEDD5A']
}
}
'redhat', 'centos': {
}
default: {
error('PuPHPet supports Ubuntu, CentOS and RHEL only')
}
}
# config file could contain no packages key
$packages = array_true($server, 'packages') ? {
true => $server['packages'],
default => { }
}
# git handled by module
$filtered_packages = delete($packages, [
'git',
])
each( $filtered_packages ) |$package| {
if ! defined(Package[$package]) {
package { $package:
ensure => present,
}
}
}
}