Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updating module to comply with style guide

now passes puppet-lint
  • Loading branch information...
commit 233775c776cc66523193eba6142e2e5634fbb559 1 parent acd6afe
Garrett Honeycutt authored
View
65 manifests/get.pp
@@ -0,0 +1,65 @@
+# Definition: rsync::get
+#
+# get files via rsync
+#
+# Parameters:
+# $source - source to copy from
+# $path - path to copy to, defaults to $name
+# $user - username on remote system
+# $purge - if set, rsync will use '--delete'
+# $exlude - string to be excluded
+# $keyfile - path to ssh key used to connect to remote host, defaults to /home/${user}/.ssh/id_rsa
+# $timeout - timeout in seconds, defaults to 900
+#
+# Actions:
+# get files via rsync
+#
+# Requires:
+# $source must be set
+#
+# Sample Usage:
+#
+# rsync::get { '/foo':
+# source => "rsync://${rsyncServer}/repo/foo/",
+# require => File['/foo'],
+# } # rsync
+#
+define rsync::get (
+ $source,
+ $path = undef,
+ $user = undef,
+ $purge = undef,
+ $exclude = undef,
+ $keyfile = undef,
+ $timeout = '900'
+) {
+
+ if $keyfile {
+ $Mykeyfile = $keyfile
+ } else {
+ $Mykeyfile = "/home/${user}/.ssh/id_rsa"
+ }
+
+ if $user {
+ $MyUser = "-e 'ssh -i ${Mykeyfile} -l ${user}' ${user}@"
+ }
+
+ if $purge {
+ $MyPurge = '--delete'
+ }
+
+ if $exclude {
+ $MyExclude = "--exclude=${exclude}"
+ }
+
+ if $path {
+ $MyPath = $path
+ } else {
+ $MyPath = $name
+ }
+
+ exec { "rsync ${name}":
+ command => "rsync -qa ${MyPurge} ${MyExclude} ${MyUser}${source} ${MyPath}",
+ timeout => $timeout,
+ }
+}
View
66 manifests/init.pp
@@ -1,66 +1,10 @@
# Class: rsync
#
-# This module manages rsync and provides a define for grabbing files via rsync
+# This module manages rsync
#
class rsync {
- package { "rsync": }
-
- # Definition: rsync::get
- #
- # get files via rsync
- #
- # Parameters:
- # $source - source to copy from
- # $path - path to copy to, defaults to $name
- # $user - username on remote system
- # $purge - if set, rsync will use '--delete'
- # $exlude - string to be excluded
- # $keyfile - ssh key used to connect to remote host
- # $timeout - timeout in seconds, defaults to 900
- #
- # Actions:
- # get files via rsync
- #
- # Requires:
- # $source must be set
- #
- # Sample Usage:
- #
- # rsync::get { "/foo":
- # source => "rsync://$rsyncServer/repo/foo/",
- # require => File["/foo"],
- # } # rsync
- #
- define get ($source, $path = undef, $user = undef, $purge = undef, $exclude = undef, $keyfile = undef, $timeout = "900") {
-
- if $keyfile {
- $Mykeyfile = $keyfile
- } else {
- $Mykeyfile = "/home/$user/.ssh/id_rsa"
- }
-
- if $user {
- $MyUser = "-e 'ssh -i $Mykeyfile -l $user' $user@"
- }
-
- if $purge {
- $MyPurge = "--delete"
- }
-
- if $exclude {
- $MyExclude = "--exclude=$exclude"
- }
-
- if $path {
- $MyPath = $path
- } else {
- $MyPath = $name
- }
-
- exec {"rsync $name":
- command => "rsync -qa $MyPurge $MyExclude $MyUser$source $MyPath",
- timeout => $timeout,
- } # exec
- } # define rsync::get
-} # class rsync
+ package { 'rsync':
+ ensure => installed,
+ }
+}
View
22 manifests/repo.pp
@@ -7,17 +7,17 @@
#
class rsync::repo {
- include rsync::server
+ include rsync::server
- $base = "/data/rsync"
+ $base = '/data/rsync'
- file { "$base":
- ensure => directory,
- } # file
+ file { $base:
+ ensure => directory,
+ }
- # setup default rsync repository
- rsync::server::module{ "repo":
- path => $base,
- require => File["$base"],
- } # rsync::server::module
-} # class rsync::repo
+ # setup default rsync repository
+ rsync::server::module{ 'repo':
+ path => $base,
+ require => File[$base],
+ }
+}
View
114 manifests/server.pp
@@ -8,89 +8,43 @@
#
class rsync::server(
$use_xinetd = true,
- $address = '0.0.0.0'
+ $address = '0.0.0.0'
) inherits rsync {
+ $rsync_fragments = '/etc/rsync.d'
- $rsync_fragments = "/etc/rsync.d"
-
- # Definition: rsync::server::module
- #
- # sets up a rsync server
- #
- # Parameters:
- # $path - path to data
- # $comment - rsync comment
- # $motd - file containing motd info
- # $read_only - yes||no, defaults to yes
- # $write_only - yes||no, defaults to no
- # $list - yes||no, defaults to no
- # $uid - uid of rsync server, defaults to 0
- # $gid - gid of rsync server, defaults to 0
- # $incoming_chmod - incoming file mode, defaults to 644
- # $outgoing_chmod - outgoing file mode, defaults to 644
- # $max_connections - maximum number of simultaneous connections allowed
- # $lock_file - file used to support the max connections parameter
- # only needed if max_connections > 0
- #
- # Actions:
- # sets up an rsync server
- #
- # Requires:
- # $path must be set
- #
- # Sample Usage:
- # # setup default rsync repository
- # rsync::server::module{ "repo":
- # path => $base,
- # require => File["$base"],
- # } # rsync::server::module
- #
- define module ($path, $comment = undef, $motd = undef, $read_only = 'yes', $write_only = 'no', $list = 'yes', $uid = '0', $gid = '0', $incoming_chmod = '644', $outgoing_chmod = '644', $max_connections = 0, $lock_file = '/var/run/rsyncd.lock') {
- if $motd {
- file { "/etc/rsync-motd-$name":
- source => "puppet:///modules/rsync/motd-$motd",
- }
- } # fi
-
- file { "$rsync::server::rsync_fragments/frag-$name":
- content => template("rsync/module.erb"),
- notify => Exec["compile fragments"],
- }
- } # define rsync::server::module
-
- if($use_xinetd) {
- include xinetd
- xinetd::service {"rsync":
- bind => $address,
- port => "873",
- server => "/usr/bin/rsync",
- server_args => "--daemon --config /etc/rsync.conf",
- require => Package['rsync'],
- } # xinetd::service
- } else {
- service { 'rsync':
- ensure => running,
- enable => true,
- subscribe => Exec['compile fragments'],
- }
+ if($use_xinetd) {
+ include xinetd
+ xinetd::service { 'rsync':
+ bind => $address,
+ port => '873',
+ server => '/usr/bin/rsync',
+ server_args => '--daemon --config /etc/rsync.conf',
+ require => Package['rsync'],
+ }
+ } else {
+ service { 'rsync':
+ ensure => running,
+ enable => true,
+ subscribe => Exec['compile fragments'],
}
+ }
- file {
- "$rsync_fragments":
- ensure => directory;
- "$rsync_fragments/header":
- content => template('rsync/header.erb');
- } # file
+ file { $rsync_fragments:
+ ensure => directory,
+ }
+ file { "${rsync_fragments}/header":
+ content => template('rsync/header.erb'),
+ }
- # perhaps this should be a script
- # this allows you to only have a header and no fragments, which happens
- # by default if you have an rsync::server but not an rsync::repo on a host
- # which happens with cobbler systems by default
- exec {"compile fragments":
- refreshonly => true,
- command => "ls $rsync_fragments/frag-* 1>/dev/null 2>/dev/null && if [ $? -eq 0 ]; then cat $rsync_fragments/header $rsync_fragments/frag-* > /etc/rsync.conf; else cat $rsync_fragments/header > /etc/rsync.conf; fi; $(exit 0)",
- subscribe => File["$rsync_fragments/header"],
- path => ['/bin'],
- } # exec
-} # class rsync::server
+ # perhaps this should be a script
+ # this allows you to only have a header and no fragments, which happens
+ # by default if you have an rsync::server but not an rsync::repo on a host
+ # which happens with cobbler systems by default
+ exec { 'compile fragments':
+ refreshonly => true,
+ command => "ls ${rsync_fragments}/frag-* 1>/dev/null 2>/dev/null && if [ $? -eq 0 ]; then cat ${rsync_fragments}/header ${rsync_fragments}/frag-* > /etc/rsync.conf; else cat ${rsync_fragments}/header > /etc/rsync.conf; fi; $(exit 0)",
+ subscribe => File["${rsync_fragments}/header"],
+ path => ['/bin'],
+ }
+}
View
57 manifests/server/module.pp
@@ -0,0 +1,57 @@
+# Definition: rsync::server::module
+#
+# sets up a rsync server
+#
+# Parameters:
+# $path - path to data
+# $comment - rsync comment
+# $motd - file containing motd info
+# $read_only - yes||no, defaults to yes
+# $write_only - yes||no, defaults to no
+# $list - yes||no, defaults to yes
+# $uid - uid of rsync server, defaults to 0
+# $gid - gid of rsync server, defaults to 0
+# $incoming_chmod - incoming file mode, defaults to 0644
+# $outgoing_chmod - outgoing file mode, defaults to 0644
+# $max_connections - maximum number of simultaneous connections allowed, defaults to 0
+# $lock_file - file used to support the max connections parameter, defaults to /var/run/rsyncd.lock
+# only needed if max_connections > 0
+#
+# Actions:
+# sets up an rsync server
+#
+# Requires:
+# $path must be set
+#
+# Sample Usage:
+# # setup default rsync repository
+# rsync::server::module { 'repo':
+# path => $base,
+# require => File[$base],
+# }
+#
+define rsync::server::module (
+ $path,
+ $comment = undef,
+ $motd = undef,
+ $read_only = 'yes',
+ $write_only = 'no',
+ $list = 'yes',
+ $uid = '0',
+ $gid = '0',
+ $incoming_chmod = '0644',
+ $outgoing_chmod = '0644',
+ $max_connections = '0',
+ $lock_file = '/var/run/rsyncd.lock') {
+
+ if $motd {
+ file { "/etc/rsync-motd-${name}":
+ source => "puppet:///modules/rsync/motd-${motd}",
+ }
+ }
+
+ file { "${rsync::server::rsync_fragments}/frag-${name}":
+ content => template('rsync/module.erb'),
+ notify => Exec['compile fragments'],
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.