Merge branch 'master' of bitbucket.org:tmakinen/puppet
This commit is contained in:
commit
a0237e2649
4 changed files with 79 additions and 17 deletions
|
@ -67,7 +67,7 @@ class network::hostname {
|
||||||
"debian","ubuntu": {
|
"debian","ubuntu": {
|
||||||
file { "/etc/hostname":
|
file { "/etc/hostname":
|
||||||
ensure => present,
|
ensure => present,
|
||||||
content => "${homename}\n",
|
content => "${::homename}\n",
|
||||||
mode => "0644",
|
mode => "0644",
|
||||||
owner => "root",
|
owner => "root",
|
||||||
group => "root",
|
group => "root",
|
||||||
|
@ -77,7 +77,7 @@ class network::hostname {
|
||||||
if versioncmp($::operatingsystemrelease, "17") == 1 {
|
if versioncmp($::operatingsystemrelease, "17") == 1 {
|
||||||
file { "/etc/hostname":
|
file { "/etc/hostname":
|
||||||
ensure => present,
|
ensure => present,
|
||||||
content => "${homename}\n",
|
content => "${::homename}\n",
|
||||||
mode => "0644",
|
mode => "0644",
|
||||||
owner => "root",
|
owner => "root",
|
||||||
group => "root",
|
group => "root",
|
||||||
|
@ -85,25 +85,30 @@ class network::hostname {
|
||||||
} else {
|
} else {
|
||||||
augeas { "set-hostname":
|
augeas { "set-hostname":
|
||||||
context => "/files/etc/sysconfig/network",
|
context => "/files/etc/sysconfig/network",
|
||||||
changes => "set HOSTNAME ${homename}",
|
changes => "set HOSTNAME ${::homename}",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"centos","redhat": {
|
"centos","redhat": {
|
||||||
augeas { "set-hostname":
|
augeas { "set-hostname":
|
||||||
context => "/files/etc/sysconfig/network",
|
context => "/files/etc/sysconfig/network",
|
||||||
changes => "set HOSTNAME ${homename}",
|
changes => "set HOSTNAME ${::homename}",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"openbsd": {
|
"openbsd": {
|
||||||
file { "/etc/myname":
|
file { "/etc/myname":
|
||||||
ensure => present,
|
ensure => present,
|
||||||
content => "${homename}\n",
|
content => "${::homename}\n",
|
||||||
mode => "0644",
|
mode => "0644",
|
||||||
owner => "root",
|
owner => "root",
|
||||||
group => "wheel",
|
group => "wheel",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"openwrt": {
|
||||||
|
uci::set { "system.@system[0].hostname":
|
||||||
|
value => $::homename,
|
||||||
|
}
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
fail("network::hostname not supported on ${::operatingsystem}")
|
fail("network::hostname not supported on ${::operatingsystem}")
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,9 @@ class puppet::client {
|
||||||
}
|
}
|
||||||
|
|
||||||
case $::operatingsystem {
|
case $::operatingsystem {
|
||||||
openbsd: { $vardir = "/var/puppet" }
|
"openbsd": { $vardir = "/var/puppet" }
|
||||||
default: { $vardir = "/var/lib/puppet" }
|
"openwrt": { $vardir = "/etc/puppet" }
|
||||||
|
default: { $vardir = "/var/lib/puppet" }
|
||||||
}
|
}
|
||||||
|
|
||||||
case $::operatingsystem {
|
case $::operatingsystem {
|
||||||
|
@ -140,22 +141,29 @@ class puppet::client {
|
||||||
|
|
||||||
file { "/usr/local/sbin/puppet-check":
|
file { "/usr/local/sbin/puppet-check":
|
||||||
ensure => present,
|
ensure => present,
|
||||||
|
name => $::operatingsystem ? {
|
||||||
|
"openwrt" => "/usr/sbin/puppet-check",
|
||||||
|
default => "/usr/local/sbin/puppet-check",
|
||||||
|
},
|
||||||
source => "puppet:///modules/puppet/puppet-check",
|
source => "puppet:///modules/puppet/puppet-check",
|
||||||
mode => "0755",
|
mode => "0755",
|
||||||
owner => "root",
|
owner => "root",
|
||||||
group => $::operatingsystem ? {
|
group => $::operatingsystem ? {
|
||||||
openbsd => "wheel",
|
"openbsd" => "wheel",
|
||||||
default => "root",
|
default => "root",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
cron { "puppet-check":
|
cron { "puppet-check":
|
||||||
ensure => present,
|
ensure => present,
|
||||||
environment => $::operatingsystem ? {
|
environment => $::operatingsystem ? {
|
||||||
openbsd => "PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin",
|
"openbsd" => "PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin",
|
||||||
default => undef,
|
default => undef,
|
||||||
},
|
},
|
||||||
command => "/usr/local/sbin/puppet-check",
|
command => $::operatingsystem ? {
|
||||||
user => root,
|
"openwrt" => "/usr/sbin/puppet-check",
|
||||||
|
default => "/usr/local/sbin/puppet-check",
|
||||||
|
},
|
||||||
|
user => "root",
|
||||||
hour => 5,
|
hour => 5,
|
||||||
minute => fqdn_rand(60),
|
minute => fqdn_rand(60),
|
||||||
require => File["/usr/local/sbin/puppet-check"],
|
require => File["/usr/local/sbin/puppet-check"],
|
||||||
|
|
|
@ -107,17 +107,22 @@ class ssh::hostkeys {
|
||||||
class ssh::server {
|
class ssh::server {
|
||||||
|
|
||||||
if $::operatingsystem != "OpenBSD" {
|
if $::operatingsystem != "OpenBSD" {
|
||||||
package { "openssh-server":
|
package { "ssh-server":
|
||||||
ensure => installed,
|
ensure => installed,
|
||||||
|
name => $::operatingsystem ? {
|
||||||
|
"openwrt" => "dropbear",
|
||||||
|
default => "openssh-server",
|
||||||
|
},
|
||||||
before => Service["sshd"],
|
before => Service["sshd"],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
service { "sshd":
|
service { "sshd":
|
||||||
name => $::operatingsystem ? {
|
name => $::operatingsystem ? {
|
||||||
"debian" => "ssh",
|
"debian" => "ssh",
|
||||||
"ubuntu" => "ssh",
|
"openwrt" => "dropbear",
|
||||||
default => "sshd",
|
"ubuntu" => "ssh",
|
||||||
|
default => "sshd",
|
||||||
},
|
},
|
||||||
ensure => running,
|
ensure => running,
|
||||||
enable => true,
|
enable => true,
|
||||||
|
|
44
uci/manifests/init.pp
Normal file
44
uci/manifests/init.pp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
|
||||||
|
# Helper class for UCI commit
|
||||||
|
#
|
||||||
|
class uci {
|
||||||
|
|
||||||
|
if $::operatingsystem != "OpenWRT" {
|
||||||
|
fail("uci not supported on ${::operatingsystem}")
|
||||||
|
}
|
||||||
|
|
||||||
|
exec { "uci commit":
|
||||||
|
user => "root",
|
||||||
|
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||||
|
refreshonly => true,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
# Set value using UCI
|
||||||
|
#
|
||||||
|
# === Parameters
|
||||||
|
#
|
||||||
|
# $name:
|
||||||
|
# UCI key to set
|
||||||
|
# $value:
|
||||||
|
# Value for given key
|
||||||
|
#
|
||||||
|
# === Sample usage
|
||||||
|
#
|
||||||
|
# uci::set { "uhttpd.main.listen_http":
|
||||||
|
# value => "8080",
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
define uci::set($value) {
|
||||||
|
|
||||||
|
include uci
|
||||||
|
|
||||||
|
exec { "uci set ${name}=${value}":
|
||||||
|
user => "root",
|
||||||
|
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||||
|
unless => "uci get ${name} | egrep '^${value}\$'",
|
||||||
|
notify => Exec["uci commit"],
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue