-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adding apt/* and debian manifests to deal with APT sources. So far hardcoding Sensuapp ones as from Sensu wiki - Add init.pp to be compliant with Puppet module guidelines
- Loading branch information
Alexander Fortin
committed
Jul 5, 2012
1 parent
13f8230
commit dda9188
Showing
4 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# | ||
# Add/remove an apt key | ||
# | ||
# == Parameters: | ||
# | ||
# $title:: The key id | ||
# $ensure:: "present" or "absent" | ||
# $url:: The url of the key | ||
# $server:: The server from which download the key | ||
# url or server are required on ensure is "present" | ||
# | ||
define sensu::apt::key($ensure, $url = '', $server = '') { | ||
|
||
case $ensure { | ||
|
||
'present': { | ||
|
||
if $url != '' { | ||
exec { "apt-key_present_$title": | ||
command => "/usr/bin/wget -O- -q '${url}' | /usr/bin/apt-key add -", | ||
unless => "/usr/bin/apt-key list | /bin/grep -c '$title'", | ||
} | ||
} else { | ||
exec { "apt-key_present_$title": | ||
command => "/usr/bin/apt-key adv --keyserver '${server}' --recv '${title}'", | ||
unless => "/usr/bin/apt-key list | /bin/grep -c '$title'", | ||
} | ||
} | ||
|
||
} | ||
|
||
'absent': { | ||
|
||
exec { "apt-key_absent_$title": | ||
command => "/usr/bin/apt-key del '$title'", | ||
onlyif => "/usr/bin/apt-key list | /bin/grep -c '$title'", | ||
} | ||
|
||
} | ||
|
||
default: { | ||
fail "Invalid 'ensure' value '$ensure' for apt::key" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
# | ||
# Add/remove a source | ||
# | ||
# == Parameters: | ||
# | ||
# $title:: The source name | ||
# $ensure:: "present" or "absent" | ||
# $content:: The content to add to source.list | ||
# | ||
define sensu::apt::source($ensure, $content = '') { | ||
|
||
$filepath = "/etc/apt/sources.list.d/${title}.list" | ||
|
||
case $ensure { | ||
|
||
'present': { | ||
|
||
file { "add_apt_source_$filepath": | ||
path => $filepath, | ||
content => $content | ||
} | ||
|
||
exec { "update_apt_source_$filepath": | ||
command => '/usr/bin/apt-get update', | ||
subscribe => File["add_apt_source_$filepath"], | ||
refreshonly => true | ||
} | ||
|
||
} | ||
|
||
'absent': { | ||
|
||
file { $filepath: | ||
ensure => absent | ||
} | ||
} | ||
|
||
default: { | ||
fail "Invalid 'ensure' value '$ensure' for apt::source" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
class sensu::debian { | ||
|
||
sensu::apt::key { 'sensuapp': | ||
ensure => 'present', | ||
url => 'http://repos.sensuapp.org/apt/pubkey.gpg', | ||
} | ||
|
||
sensu::apt::source { 'sensuapp': | ||
ensure => 'present', | ||
content => 'deb http://repos.sensuapp.org/apt sensu main', | ||
require => Sensu::Apt::Key['sensuapp'], | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
class sensu { | ||
|
||
case $::operatingsystem { | ||
# add apt sources | ||
'Debian': { include 'sensu::debian' } | ||
'Ubuntu': { include 'sensu::debian' } | ||
default : {} | ||
} | ||
|
||
} |