Sync puppet module rsync to v0.3.0 from upstream
v0.3.0 sha1: d0707c4ae3674b63c2193c0012ceb9fa90ed41b6 Repo link: https://github.com/puppetlabs/puppetlabs-rsync Implements: blueprint merge-openstack-puppet-modules Change-Id: I873975f11ad5d839c5a52c2c3301b1f63fe92f5f
This commit is contained in:
parent
acc99fcd0b
commit
a11e8ffd2d
@ -3,4 +3,3 @@ fixtures:
|
|||||||
"xinetd": "git://github.com/ghoneycutt/puppet-xinetd"
|
"xinetd": "git://github.com/ghoneycutt/puppet-xinetd"
|
||||||
symlinks:
|
symlinks:
|
||||||
"rsync": "#{source_dir}"
|
"rsync": "#{source_dir}"
|
||||||
"stdlib": "#{source_dir}/../stdlib"
|
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
source :rubygems
|
|
||||||
|
|
||||||
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 2.7']
|
|
||||||
gem 'puppet', puppetversion
|
|
||||||
gem 'puppetlabs_spec_helper', '>= 0.1.0'
|
|
6
deployment/puppet/rsync/.gitignore
vendored
6
deployment/puppet/rsync/.gitignore
vendored
@ -1,5 +1,3 @@
|
|||||||
*.swp
|
|
||||||
pkg/
|
pkg/
|
||||||
.DS_Store
|
Gemfile.lock
|
||||||
metadata.json
|
.rspec
|
||||||
coverage/
|
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<projectDescription>
|
|
||||||
<name>rsync</name>
|
|
||||||
<comment></comment>
|
|
||||||
<projects>
|
|
||||||
<project>xinetd</project>
|
|
||||||
</projects>
|
|
||||||
<buildSpec>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
<buildCommand>
|
|
||||||
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
|
|
||||||
<arguments>
|
|
||||||
</arguments>
|
|
||||||
</buildCommand>
|
|
||||||
</buildSpec>
|
|
||||||
<natures>
|
|
||||||
<nature>org.cloudsmith.geppetto.pp.dsl.ui.puppetNature</nature>
|
|
||||||
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
|
|
||||||
</natures>
|
|
||||||
</projectDescription>
|
|
28
deployment/puppet/rsync/.travis.yml
Normal file
28
deployment/puppet/rsync/.travis.yml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
language: ruby
|
||||||
|
bundler_args: --without development
|
||||||
|
script: "bundle exec rake spec SPEC_OPTS='--format documentation'"
|
||||||
|
|
||||||
|
rvm:
|
||||||
|
- 1.8.7
|
||||||
|
- 1.9.3
|
||||||
|
- 2.0.0
|
||||||
|
env:
|
||||||
|
matrix:
|
||||||
|
- PUPPET_GEM_VERSION="~> 2.7.0"
|
||||||
|
- PUPPET_GEM_VERSION="~> 3.0"
|
||||||
|
- PUPPET_GEM_VERSION="~> 3.2.0"
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
exclude:
|
||||||
|
- rvm: 1.9.3
|
||||||
|
env: PUPPET_GEM_VERSION="~> 2.7.0"
|
||||||
|
- rvm: 2.0.0
|
||||||
|
env: PUPPET_GEM_VERSION="~> 2.7.0"
|
||||||
|
- rvm: 1.8.7
|
||||||
|
env: PUPPET_GEM_VERSION="~> 3.2.0"
|
||||||
|
notifications:
|
||||||
|
email: false
|
@ -1,2 +1,22 @@
|
|||||||
|
* 2014-06-18 0.3.0
|
||||||
|
Features:
|
||||||
|
- Added rsync::put defined type.
|
||||||
|
- Added 'recursive', 'links', 'hardlinks', 'copylinks', 'times' and 'include'
|
||||||
|
parameters to rsync::get.
|
||||||
|
- Added 'uid' and 'gid' parameters to rsync::server
|
||||||
|
- Improved support for Debian
|
||||||
|
- Added 'exclude' parameter to rsync::server::module
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
- Added /usr/local/bin to path for the rsync command exec.
|
||||||
|
|
||||||
|
|
||||||
|
* 2013-01-31 0.2.0
|
||||||
|
- Added use_chroot parameter.
|
||||||
|
- Ensure rsync package is installed.
|
||||||
|
- Compatability changes for Ruby 2.0.
|
||||||
|
- Added execuser parameter to run command as specified user.
|
||||||
|
- Various typo and bug fixes.
|
||||||
|
|
||||||
* 2012-06-07 0.1.0
|
* 2012-06-07 0.1.0
|
||||||
- Initial release
|
- Initial release
|
||||||
|
8
deployment/puppet/rsync/Gemfile
Normal file
8
deployment/puppet/rsync/Gemfile
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
source "https://rubygems.org"
|
||||||
|
|
||||||
|
gem 'puppetlabs_spec_helper'
|
||||||
|
if puppetversion = ENV['PUPPET_GEM_VERSION']
|
||||||
|
gem 'puppet', puppetversion, :require => false
|
||||||
|
else
|
||||||
|
gem 'puppet', :require => false
|
||||||
|
end
|
@ -1,9 +0,0 @@
|
|||||||
name 'puppetlabs-rsync'
|
|
||||||
version '0.1.0'
|
|
||||||
source 'https://github.com/puppetlabs/puppetlabs-rsync'
|
|
||||||
author 'Puppet Labs'
|
|
||||||
license 'Apache License 2.0'
|
|
||||||
summary 'Puppet module to install and configure rsync'
|
|
||||||
project_page 'https://github.com/puppetlabs/puppetlabd-rsync'
|
|
||||||
|
|
||||||
dependency 'puppetlabs/xinetd', '>= 1.1.0'
|
|
@ -8,13 +8,20 @@ providing defines to easily grab data via rsync.
|
|||||||
get files via rsync
|
get files via rsync
|
||||||
|
|
||||||
## Parameters: ##
|
## Parameters: ##
|
||||||
$source - source to copy from
|
$source - source to copy from
|
||||||
$path - path to copy to, defaults to $name
|
$path - path to copy to, defaults to $name
|
||||||
$user - username on remote system
|
$user - username on remote system
|
||||||
$purge - if set, rsync will use '--delete'
|
$purge - if set, rsync will use '--delete'
|
||||||
$exlude - string to be excluded
|
$recursive - if set, rsync will use '-r'
|
||||||
$keyfile - ssh key used to connect to remote host
|
$links - if set, rsync will use '--links'
|
||||||
$timeout - timeout in seconds, defaults to 900
|
$hardlinks - if set, rsync will use '--hard-links'
|
||||||
|
$copylinks - if set, rsync will use '--copy-links'
|
||||||
|
$times - if set, rsycn will use '--times'
|
||||||
|
$include - string to be included
|
||||||
|
$exclude - string to be excluded
|
||||||
|
$keyfile - ssh key used to connect to remote host
|
||||||
|
$timeout - timeout in seconds, defaults to 900
|
||||||
|
$execuser - user to run the command (passed to exec)
|
||||||
|
|
||||||
## Actions: ##
|
## Actions: ##
|
||||||
get files via rsync
|
get files via rsync
|
||||||
@ -29,6 +36,31 @@ get files via rsync
|
|||||||
require => File['/foo'],
|
require => File['/foo'],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Definition: rsync::put #
|
||||||
|
|
||||||
|
put 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: ##
|
||||||
|
put files via rsync
|
||||||
|
|
||||||
|
## Requires: ##
|
||||||
|
$source must be set
|
||||||
|
|
||||||
|
## Sample Usage: ##
|
||||||
|
rsync::put { '${rsyncDestHost}:/repo/foo':
|
||||||
|
user => 'user',
|
||||||
|
source => "/repo/foo/",
|
||||||
|
}
|
||||||
|
|
||||||
# Definition: rsync::server::module #
|
# Definition: rsync::server::module #
|
||||||
|
|
||||||
sets up a rsync server
|
sets up a rsync server
|
||||||
|
43
deployment/puppet/rsync/files/defaults
Normal file
43
deployment/puppet/rsync/files/defaults
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# Debian defaults file for rsync daemon mode.
|
||||||
|
#### This file is being maintained by Puppet.
|
||||||
|
#### DO NOT EDIT!
|
||||||
|
|
||||||
|
# start rsync in daemon mode from init.d script?
|
||||||
|
# only allowed values are "true", "false", and "inetd"
|
||||||
|
# Use "inetd" if you want to start the rsyncd from inetd,
|
||||||
|
# all this does is prevent the init.d script from printing a message
|
||||||
|
# about not starting rsyncd (you still need to modify inetd's config yourself).
|
||||||
|
RSYNC_ENABLE=true
|
||||||
|
|
||||||
|
# which file should be used as the configuration file for rsync.
|
||||||
|
# This file is used instead of the default /etc/rsyncd.conf
|
||||||
|
# Warning: This option has no effect if the daemon is accessed
|
||||||
|
# using a remote shell. When using a different file for
|
||||||
|
# rsync you might want to symlink /etc/rsyncd.conf to
|
||||||
|
# that file.
|
||||||
|
# RSYNC_CONFIG_FILE=
|
||||||
|
|
||||||
|
# what extra options to give rsync --daemon?
|
||||||
|
# that excludes the --daemon; that's always done in the init.d script
|
||||||
|
# Possibilities are:
|
||||||
|
# --address=123.45.67.89 (bind to a specific IP address)
|
||||||
|
# --port=8730 (bind to specified port; default 873)
|
||||||
|
RSYNC_OPTS=''
|
||||||
|
|
||||||
|
# run rsyncd at a nice level?
|
||||||
|
# the rsync daemon can impact performance due to much I/O and CPU usage,
|
||||||
|
# so you may want to run it at a nicer priority than the default priority.
|
||||||
|
# Allowed values are 0 - 19 inclusive; 10 is a reasonable value.
|
||||||
|
RSYNC_NICE=''
|
||||||
|
|
||||||
|
# run rsyncd with ionice?
|
||||||
|
# "ionice" does for IO load what "nice" does for CPU load.
|
||||||
|
# As rsync is often used for backups which aren't all that time-critical,
|
||||||
|
# reducing the rsync IO priority will benefit the rest of the system.
|
||||||
|
# See the manpage for ionice for allowed options.
|
||||||
|
# -c3 is recommended, this will run rsync IO at "idle" priority. Uncomment
|
||||||
|
# the next line to activate this.
|
||||||
|
# RSYNC_IONICE='-c3'
|
||||||
|
|
||||||
|
# Don't forget to create an appropriate config file,
|
||||||
|
# else the daemon will not start.
|
@ -26,16 +26,21 @@
|
|||||||
#
|
#
|
||||||
define rsync::get (
|
define rsync::get (
|
||||||
$source,
|
$source,
|
||||||
$path = undef,
|
$path = $name,
|
||||||
$user = undef,
|
$user = undef,
|
||||||
$purge = undef,
|
$purge = undef,
|
||||||
$exclude = undef,
|
$recursive = undef,
|
||||||
$keyfile = undef,
|
$links = undef,
|
||||||
$timeout = '900'
|
$hardlinks = undef,
|
||||||
|
$copylinks = undef,
|
||||||
|
$times = undef,
|
||||||
|
$include = undef,
|
||||||
|
$exclude = undef,
|
||||||
|
$keyfile = undef,
|
||||||
|
$timeout = '900',
|
||||||
|
$execuser = 'root',
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include rsync
|
|
||||||
|
|
||||||
if $keyfile {
|
if $keyfile {
|
||||||
$Mykeyfile = $keyfile
|
$Mykeyfile = $keyfile
|
||||||
} else {
|
} else {
|
||||||
@ -47,26 +52,52 @@ define rsync::get (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if $purge {
|
if $purge {
|
||||||
$MyPurge = '--delete'
|
$MyPurge = ' --delete'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Not currently correct, there can be multiple --exclude arguments
|
||||||
if $exclude {
|
if $exclude {
|
||||||
$MyExclude = "--exclude=${exclude}"
|
$MyExclude = " --exclude=${exclude}"
|
||||||
}
|
}
|
||||||
|
|
||||||
if $path {
|
# Not currently correct, there can be multiple --include arguments
|
||||||
$MyPath = $path
|
if $include {
|
||||||
} else {
|
$MyInclude = " --include=${include}"
|
||||||
$MyPath = $name
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$rsync_options = "-a ${MyPurge} ${MyExclude} ${MyUser}${source} ${MyPath}"
|
if $recursive {
|
||||||
|
$MyRecursive = ' -r'
|
||||||
|
}
|
||||||
|
|
||||||
|
if $links {
|
||||||
|
$MyLinks = ' --links'
|
||||||
|
}
|
||||||
|
|
||||||
|
if $hardlinks {
|
||||||
|
$MyHardLinks = ' --hard-links'
|
||||||
|
}
|
||||||
|
|
||||||
|
if $copylinks {
|
||||||
|
$MyCopyLinks = ' --copy-links'
|
||||||
|
}
|
||||||
|
|
||||||
|
if $times {
|
||||||
|
$MyTimes = ' --times'
|
||||||
|
}
|
||||||
|
|
||||||
|
$rsync_options = "-a${MyPurge}${MyExclude}${MyInclude}${MyLinks}${MyHardLinks}${MyCopyLinks}${MyTimes}${MyRecursive} ${MyUser}${source} ${path}"
|
||||||
|
|
||||||
exec { "rsync ${name}":
|
exec { "rsync ${name}":
|
||||||
command => "rsync -q ${rsync_options}",
|
command => "rsync -q ${rsync_options}",
|
||||||
path => [ '/bin', '/usr/bin' ],
|
path => [ '/bin', '/usr/bin', '/usr/local/bin' ],
|
||||||
|
user => $execuser,
|
||||||
|
# perform a dry-run to determine if anything needs to be updated
|
||||||
|
# this ensures that we only actually create a Puppet event if something needs to
|
||||||
|
# be updated
|
||||||
|
# TODO - it may make senes to do an actual run here (instead of a dry run)
|
||||||
|
# and relace the command with an echo statement or something to ensure
|
||||||
|
# that we only actually run rsync once
|
||||||
|
onlyif => "test `rsync --dry-run --itemize-changes ${rsync_options} | wc -l` -gt 0",
|
||||||
timeout => $timeout,
|
timeout => $timeout,
|
||||||
}
|
}
|
||||||
|
|
||||||
Package['rsync'] -> Exec["rsync ${name}"]
|
|
||||||
}
|
}
|
||||||
|
@ -6,5 +6,5 @@ class rsync {
|
|||||||
|
|
||||||
package { 'rsync':
|
package { 'rsync':
|
||||||
ensure => installed,
|
ensure => installed,
|
||||||
}
|
} -> Rsync::Get<| |>
|
||||||
}
|
}
|
||||||
|
76
deployment/puppet/rsync/manifests/put.pp
Normal file
76
deployment/puppet/rsync/manifests/put.pp
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# Definition: rsync::put
|
||||||
|
#
|
||||||
|
# put 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:
|
||||||
|
# put files via rsync
|
||||||
|
#
|
||||||
|
# Requires:
|
||||||
|
# $source must be set
|
||||||
|
#
|
||||||
|
# Sample Usage:
|
||||||
|
#
|
||||||
|
# rsync::put { '${rsyncDestHost}:/repo/foo':
|
||||||
|
# user => 'user',
|
||||||
|
# source => "/repo/foo/",
|
||||||
|
# } # rsync
|
||||||
|
#
|
||||||
|
define rsync::put (
|
||||||
|
$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 {
|
||||||
|
$MyUserOpt = "-e 'ssh -i ${Mykeyfile} -l ${user}' "
|
||||||
|
$MyUser = "${user}@"
|
||||||
|
}
|
||||||
|
|
||||||
|
if $purge {
|
||||||
|
$MyPurge = '--delete'
|
||||||
|
}
|
||||||
|
|
||||||
|
if $exclude {
|
||||||
|
$MyExclude = "--exclude=${exclude}"
|
||||||
|
}
|
||||||
|
|
||||||
|
if $path {
|
||||||
|
$MyPath = $path
|
||||||
|
} else {
|
||||||
|
$MyPath = $name
|
||||||
|
}
|
||||||
|
|
||||||
|
$rsync_options = "-a ${MyPurge} ${MyExclude} ${MyUserOpt}${source} ${MyUser}${MyPath}"
|
||||||
|
|
||||||
|
exec { "rsync ${name}":
|
||||||
|
command => "rsync -q ${rsync_options}",
|
||||||
|
path => [ '/bin', '/usr/bin' ],
|
||||||
|
# perform a dry-run to determine if anything needs to be updated
|
||||||
|
# this ensures that we only actually create a Puppet event if something needs to
|
||||||
|
# be updated
|
||||||
|
# TODO - it may make senes to do an actual run here (instead of a dry run)
|
||||||
|
# and relace the command with an echo statement or something to ensure
|
||||||
|
# that we only actually run rsync once
|
||||||
|
onlyif => "test `rsync --dry-run --itemize-changes ${rsync_options} | wc -l` -gt 0",
|
||||||
|
timeout => $timeout,
|
||||||
|
}
|
||||||
|
}
|
@ -10,25 +10,41 @@ class rsync::server(
|
|||||||
$use_xinetd = true,
|
$use_xinetd = true,
|
||||||
$address = '0.0.0.0',
|
$address = '0.0.0.0',
|
||||||
$motd_file = 'UNSET',
|
$motd_file = 'UNSET',
|
||||||
$use_chroot = 'yes'
|
$use_chroot = 'yes',
|
||||||
|
$uid = 'nobody',
|
||||||
|
$gid = 'nobody'
|
||||||
) inherits rsync {
|
) inherits rsync {
|
||||||
|
|
||||||
|
$conf_file = $::osfamily ? {
|
||||||
|
'Debian' => '/etc/rsyncd.conf',
|
||||||
|
default => '/etc/rsync.conf',
|
||||||
|
}
|
||||||
|
|
||||||
$rsync_fragments = '/etc/rsync.d'
|
$rsync_fragments = '/etc/rsync.d'
|
||||||
|
|
||||||
if($use_xinetd) {
|
if $use_xinetd {
|
||||||
include xinetd
|
include xinetd
|
||||||
xinetd::service { 'rsync':
|
xinetd::service { 'rsync':
|
||||||
bind => $address,
|
bind => $address,
|
||||||
port => '873',
|
port => '873',
|
||||||
server => '/usr/bin/rsync',
|
server => '/usr/bin/rsync',
|
||||||
server_args => '--daemon --config /etc/rsync.conf',
|
server_args => "--daemon --config ${conf_file}",
|
||||||
require => Package['rsync'],
|
require => Package['rsync'],
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
service { 'rsync':
|
service { 'rsync':
|
||||||
ensure => running,
|
ensure => running,
|
||||||
enable => true,
|
enable => true,
|
||||||
subscribe => Exec['compile fragments'],
|
hasstatus => true,
|
||||||
|
hasrestart => true,
|
||||||
|
subscribe => Exec['compile fragments'],
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $::osfamily == 'Debian' ) {
|
||||||
|
file { '/etc/default/rsync':
|
||||||
|
source => 'puppet:///modules/rsync/defaults',
|
||||||
|
notify => Service['rsync'],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,23 +58,26 @@ class rsync::server(
|
|||||||
ensure => directory,
|
ensure => directory,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Template uses:
|
||||||
|
# - $use_chroot
|
||||||
|
# - $address
|
||||||
|
# - $motd_file
|
||||||
file { "${rsync_fragments}/header":
|
file { "${rsync_fragments}/header":
|
||||||
content => template('rsync/header.erb'),
|
content => template('rsync/header.erb'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file { $conf_file:
|
||||||
|
ensure => present,
|
||||||
|
} ~> Exec['compile fragments']
|
||||||
|
|
||||||
# perhaps this should be a script
|
# perhaps this should be a script
|
||||||
# this allows you to only have a header and no fragments, which happens
|
# 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
|
# by default if you have an rsync::server but not an rsync::repo on a host
|
||||||
# which happens with cobbler systems by default
|
# which happens with cobbler systems by default
|
||||||
exec { 'compile fragments':
|
exec { 'compile fragments':
|
||||||
refreshonly => true,
|
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)",
|
command => "ls ${rsync_fragments}/frag-* 1>/dev/null 2>/dev/null && if [ $? -eq 0 ]; then cat ${rsync_fragments}/header ${rsync_fragments}/frag-* > ${conf_file}; else cat ${rsync_fragments}/header > ${conf_file}; fi; $(exit 0)",
|
||||||
subscribe => File["${rsync_fragments}/header"],
|
subscribe => File["${rsync_fragments}/header"],
|
||||||
path => '/bin:/usr/bin',
|
path => '/bin:/usr/bin:/usr/local/bin',
|
||||||
}
|
}
|
||||||
|
|
||||||
anchor{'rsync_server_end':}
|
|
||||||
Exec ['compile fragments'] -> Anchor['rsync_server_end']
|
|
||||||
Service <| title=='xinetd' |> -> Anchor['rsync_server_end']
|
|
||||||
Service <| title=='rsync' |> -> Anchor['rsync_server_end']
|
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,12 @@ define rsync::server::module (
|
|||||||
$list = 'yes',
|
$list = 'yes',
|
||||||
$uid = '0',
|
$uid = '0',
|
||||||
$gid = '0',
|
$gid = '0',
|
||||||
$incoming_chmod = 'a=r,u+w,D+x',
|
$incoming_chmod = '0644',
|
||||||
$outgoing_chmod = 'a=r,u+w,D+x',
|
$outgoing_chmod = '0644',
|
||||||
$max_connections = '0',
|
$max_connections = '0',
|
||||||
$lock_file = '/var/run/rsyncd.lock',
|
$lock_file = '/var/run/rsyncd.lock',
|
||||||
$secrets_file = undef,
|
$secrets_file = undef,
|
||||||
|
$exclude = undef,
|
||||||
$auth_users = undef,
|
$auth_users = undef,
|
||||||
$hosts_allow = undef,
|
$hosts_allow = undef,
|
||||||
$hosts_deny = undef) {
|
$hosts_deny = undef) {
|
||||||
|
@ -58,4 +58,24 @@ describe 'rsync::server', :type => :class do
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'when overriding uid' do
|
||||||
|
let :params do
|
||||||
|
{ :uid => 'testuser' }
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_file(fragment_file).with_content(/^uid\s*=\s*testuser$/)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'when overriding gid' do
|
||||||
|
let :params do
|
||||||
|
{ :gid => 'testgroup' }
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_file(fragment_file).with_content(/^gid\s*=\s*testgroup$/)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -17,13 +17,22 @@ describe 'rsync::get', :type => :define do
|
|||||||
|
|
||||||
it {
|
it {
|
||||||
should contain_exec("rsync foobar").with({
|
should contain_exec("rsync foobar").with({
|
||||||
'command' => 'rsync -q -a example.com foobar',
|
'command' => 'rsync -q -a example.com foobar',
|
||||||
#'onlyif' => 'test `rsync --dry-run --itemize-changes -a example.com foobar | wc -l` -gt 0',
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a example.com foobar | wc -l` -gt 0",
|
||||||
'timeout' => '900'
|
'timeout' => '900',
|
||||||
|
'user' => 'root'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "when setting the execuser" do
|
||||||
|
let :params do
|
||||||
|
common_params.merge( { :execuser => 'username' } )
|
||||||
|
end
|
||||||
|
|
||||||
|
it{ should contain_exec("rsync foobar").with({ 'user' => 'username' }) }
|
||||||
|
end
|
||||||
|
|
||||||
describe "when setting the timeout" do
|
describe "when setting the timeout" do
|
||||||
let :params do
|
let :params do
|
||||||
common_params.merge( { :timeout => '200' } )
|
common_params.merge( { :timeout => '200' } )
|
||||||
@ -41,8 +50,8 @@ describe 'rsync::get', :type => :define do
|
|||||||
|
|
||||||
it {
|
it {
|
||||||
should contain_exec("rsync foobar").with({
|
should contain_exec("rsync foobar").with({
|
||||||
'command' => 'rsync -q -a -e \'ssh -i /home/mr_baz/.ssh/id_rsa -l mr_baz\' mr_baz@example.com foobar'
|
'command' => 'rsync -q -a -e \'ssh -i /home/mr_baz/.ssh/id_rsa -l mr_baz\' mr_baz@example.com foobar',
|
||||||
#'onlyif' => "test `rsync --dry-run --itemize-changes -a -e \'ssh -i /home/mr_baz/.ssh/id_rsa -l mr_baz\' mr_baz@example.com foobar | wc -l` -gt 0",
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a -e \'ssh -i /home/mr_baz/.ssh/id_rsa -l mr_baz\' mr_baz@example.com foobar | wc -l` -gt 0",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -54,8 +63,8 @@ describe 'rsync::get', :type => :define do
|
|||||||
|
|
||||||
it {
|
it {
|
||||||
should contain_exec("rsync foobar").with({
|
should contain_exec("rsync foobar").with({
|
||||||
'command' => 'rsync -q -a example.com foobar'
|
'command' => 'rsync -q -a example.com foobar',
|
||||||
#'onlyif' => "test `rsync --dry-run --itemize-changes -a example.com foobar | wc -l` -gt 0",
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a example.com foobar | wc -l` -gt 0",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -70,8 +79,8 @@ describe 'rsync::get', :type => :define do
|
|||||||
|
|
||||||
it {
|
it {
|
||||||
should contain_exec("rsync foobar").with({
|
should contain_exec("rsync foobar").with({
|
||||||
'command' => 'rsync -q -a -e \'ssh -i /path/to/keyfile -l mr_baz\' mr_baz@example.com foobar'
|
'command' => 'rsync -q -a -e \'ssh -i /path/to/keyfile -l mr_baz\' mr_baz@example.com foobar',
|
||||||
#'onlyif' => "test `rsync --dry-run --itemize-changes -a -e \'ssh -i /path/to/keyfile -l mr_baz\' mr_baz@example.com foobar | wc -l` -gt 0",
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a -e \'ssh -i /path/to/keyfile -l mr_baz\' mr_baz@example.com foobar | wc -l` -gt 0",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -83,8 +92,21 @@ describe 'rsync::get', :type => :define do
|
|||||||
|
|
||||||
it {
|
it {
|
||||||
should contain_exec("rsync foobar").with({
|
should contain_exec("rsync foobar").with({
|
||||||
'command' => 'rsync -q -a --exclude=/path/to/exclude/ example.com foobar'
|
'command' => 'rsync -q -a --exclude=/path/to/exclude/ example.com foobar',
|
||||||
#'onlyif' => "test `rsync --dry-run --itemize-changes -a --exclude=/path/to/exclude/ example.com foobar | wc -l` -gt 0",
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a --exclude=/path/to/exclude/ example.com foobar | wc -l` -gt 0",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when setting an include path" do
|
||||||
|
let :params do
|
||||||
|
common_params.merge({ :include => '/path/to/include/' })
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_exec("rsync foobar").with({
|
||||||
|
'command' => 'rsync -q -a --include=/path/to/include/ example.com foobar',
|
||||||
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a --include=/path/to/include/ example.com foobar | wc -l` -gt 0",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -96,8 +118,73 @@ describe 'rsync::get', :type => :define do
|
|||||||
|
|
||||||
it {
|
it {
|
||||||
should contain_exec("rsync foobar").with({
|
should contain_exec("rsync foobar").with({
|
||||||
'command' => 'rsync -q -a --delete example.com foobar'
|
'command' => 'rsync -q -a --delete example.com foobar',
|
||||||
#'onlyif' => "test `rsync --dry-run --itemize-changes -a --delete example.com foobar | wc -l` -gt 0"
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a --delete example.com foobar | wc -l` -gt 0"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when enabling recursive" do
|
||||||
|
let :params do
|
||||||
|
common_params.merge({ :recursive => true })
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_exec("rsync foobar").with({
|
||||||
|
'command' => 'rsync -q -a -r example.com foobar',
|
||||||
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a -r example.com foobar | wc -l` -gt 0"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when enabling links" do
|
||||||
|
let :params do
|
||||||
|
common_params.merge({ :links => true })
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_exec("rsync foobar").with({
|
||||||
|
'command' => 'rsync -q -a --links example.com foobar',
|
||||||
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a --links example.com foobar | wc -l` -gt 0"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when enabling hardlinks" do
|
||||||
|
let :params do
|
||||||
|
common_params.merge({ :hardlinks => true })
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_exec("rsync foobar").with({
|
||||||
|
'command' => 'rsync -q -a --hard-links example.com foobar',
|
||||||
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a --hard-links example.com foobar | wc -l` -gt 0"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when enabling copylinks" do
|
||||||
|
let :params do
|
||||||
|
common_params.merge({ :copylinks => true })
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_exec("rsync foobar").with({
|
||||||
|
'command' => 'rsync -q -a --copy-links example.com foobar',
|
||||||
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a --copy-links example.com foobar | wc -l` -gt 0"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when enabling times" do
|
||||||
|
let :params do
|
||||||
|
common_params.merge({ :times => true })
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_exec("rsync foobar").with({
|
||||||
|
'command' => 'rsync -q -a --times example.com foobar',
|
||||||
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a --times example.com foobar | wc -l` -gt 0"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -109,8 +196,8 @@ describe 'rsync::get', :type => :define do
|
|||||||
|
|
||||||
it {
|
it {
|
||||||
should contain_exec("rsync foobar").with({
|
should contain_exec("rsync foobar").with({
|
||||||
'command' => 'rsync -q -a example.com barfoo'
|
'command' => 'rsync -q -a example.com barfoo',
|
||||||
#'onlyif' => "test `rsync --dry-run --itemize-changes -a example.com barfoo | wc -l` -gt 0"
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a example.com barfoo | wc -l` -gt 0"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
117
deployment/puppet/rsync/spec/defines/put_spec.rb
Normal file
117
deployment/puppet/rsync/spec/defines/put_spec.rb
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
describe 'rsync::put', :type => :define do
|
||||||
|
let :title do
|
||||||
|
'foobar'
|
||||||
|
end
|
||||||
|
|
||||||
|
let :common_params do
|
||||||
|
{
|
||||||
|
:source => 'example.com'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when using default class paramaters" do
|
||||||
|
let :params do
|
||||||
|
common_params
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_exec("rsync foobar").with({
|
||||||
|
'command' => 'rsync -q -a example.com foobar',
|
||||||
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a example.com foobar | wc -l` -gt 0",
|
||||||
|
'timeout' => '900'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when setting the timeout" do
|
||||||
|
let :params do
|
||||||
|
common_params.merge( { :timeout => '200' } )
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_exec("rsync foobar").with({ 'timeout' => '200' })
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when setting a user but not a keyfile" do
|
||||||
|
let :params do
|
||||||
|
common_params.merge({ :user => 'mr_baz' })
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_exec("rsync foobar").with({
|
||||||
|
'command' => 'rsync -q -a -e \'ssh -i /home/mr_baz/.ssh/id_rsa -l mr_baz\' example.com mr_baz@foobar',
|
||||||
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a -e \'ssh -i /home/mr_baz/.ssh/id_rsa -l mr_baz\' example.com mr_baz@foobar | wc -l` -gt 0",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when setting a keyfile but not a user" do
|
||||||
|
let :params do
|
||||||
|
common_params.merge( { :keyfile => "/path/to/keyfile" } )
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_exec("rsync foobar").with({
|
||||||
|
'command' => 'rsync -q -a example.com foobar',
|
||||||
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a example.com foobar | wc -l` -gt 0",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when setting a user and a keyfile" do
|
||||||
|
let :params do
|
||||||
|
common_params.merge({
|
||||||
|
:user => 'mr_baz',
|
||||||
|
:keyfile => '/path/to/keyfile'
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_exec("rsync foobar").with({
|
||||||
|
'command' => 'rsync -q -a -e \'ssh -i /path/to/keyfile -l mr_baz\' example.com mr_baz@foobar',
|
||||||
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a -e \'ssh -i /path/to/keyfile -l mr_baz\' example.com mr_baz@foobar | wc -l` -gt 0",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when setting an exclude path" do
|
||||||
|
let :params do
|
||||||
|
common_params.merge({ :exclude => '/path/to/exclude/' })
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_exec("rsync foobar").with({
|
||||||
|
'command' => 'rsync -q -a --exclude=/path/to/exclude/ example.com foobar',
|
||||||
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a --exclude=/path/to/exclude/ example.com foobar | wc -l` -gt 0",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when enabling purge" do
|
||||||
|
let :params do
|
||||||
|
common_params.merge({ :purge => true })
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_exec("rsync foobar").with({
|
||||||
|
'command' => 'rsync -q -a --delete example.com foobar',
|
||||||
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a --delete example.com foobar | wc -l` -gt 0"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "when setting a custom path" do
|
||||||
|
let :params do
|
||||||
|
common_params.merge({ :path => 'barfoo' })
|
||||||
|
end
|
||||||
|
|
||||||
|
it {
|
||||||
|
should contain_exec("rsync foobar").with({
|
||||||
|
'command' => 'rsync -q -a example.com barfoo',
|
||||||
|
'onlyif' => "test `rsync --dry-run --itemize-changes -a example.com barfoo | wc -l` -gt 0"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
@ -29,8 +29,8 @@ describe 'rsync::server::module', :type => :define do
|
|||||||
it { should contain_file(fragment_file).with_content(/^list\s*=\s*yes$/) }
|
it { should contain_file(fragment_file).with_content(/^list\s*=\s*yes$/) }
|
||||||
it { should contain_file(fragment_file).with_content(/^uid\s*=\s*0$/) }
|
it { should contain_file(fragment_file).with_content(/^uid\s*=\s*0$/) }
|
||||||
it { should contain_file(fragment_file).with_content(/^gid\s*=\s*0$/) }
|
it { should contain_file(fragment_file).with_content(/^gid\s*=\s*0$/) }
|
||||||
it { should contain_file(fragment_file).with_content(/^incoming chmod\s*=\s*a=r,u\+w,D\+x$/) }
|
it { should contain_file(fragment_file).with_content(/^incoming chmod\s*=\s*0644$/) }
|
||||||
it { should contain_file(fragment_file).with_content(/^outgoing chmod\s*=\s*a=r,u\+w,D\+x$/) }
|
it { should contain_file(fragment_file).with_content(/^outgoing chmod\s*=\s*0644$/) }
|
||||||
it { should contain_file(fragment_file).with_content(/^max connections\s*=\s*0$/) }
|
it { should contain_file(fragment_file).with_content(/^max connections\s*=\s*0$/) }
|
||||||
it { should_not contain_file(fragment_file).with_content(/^lock file\s*=.*$/) }
|
it { should_not contain_file(fragment_file).with_content(/^lock file\s*=.*$/) }
|
||||||
it { should_not contain_file(fragment_file).with_content(/^secrets file\s*=.*$/) }
|
it { should_not contain_file(fragment_file).with_content(/^secrets file\s*=.*$/) }
|
||||||
@ -64,7 +64,7 @@ describe 'rsync::server::module', :type => :define do
|
|||||||
let :params do
|
let :params do
|
||||||
mandatory_params.merge({ k => v })
|
mandatory_params.merge({ k => v })
|
||||||
end
|
end
|
||||||
it { should contain_file(fragment_file).with_content(/^#{k.to_s.gsub('_', ' ')}\s*=\s*#{v.to_a.join(' ')}$/)}
|
it { should contain_file(fragment_file).with_content(/^#{k.to_s.gsub('_', ' ')}\s*=\s*#{Array(v).join(' ')}$/)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2,11 +2,13 @@
|
|||||||
# DO NOT EDIT
|
# DO NOT EDIT
|
||||||
|
|
||||||
pid file = /var/run/rsyncd.pid
|
pid file = /var/run/rsyncd.pid
|
||||||
uid = nobody
|
uid = <%= @uid %>
|
||||||
gid = nobody
|
gid = <%= @gid %>
|
||||||
use chroot = <%= @use_chroot %>
|
use chroot = <%= @use_chroot %>
|
||||||
log format = %t %a %m %f %b
|
log format = %t %a %m %f %b
|
||||||
syslog facility = local3
|
syslog facility = local3
|
||||||
timeout = 300
|
timeout = 300
|
||||||
address = <%= @address %>
|
address = <%= @address %>
|
||||||
<% if @motd_file != 'UNSET' %>motd file = <%= @motd_file %><% end %>
|
<% if @motd_file != 'UNSET' -%>
|
||||||
|
motd file = <%= @motd_file %>
|
||||||
|
<% end -%>
|
||||||
|
@ -11,11 +11,24 @@ gid = <%= @gid %>
|
|||||||
incoming chmod = <%= @incoming_chmod %>
|
incoming chmod = <%= @incoming_chmod %>
|
||||||
outgoing chmod = <%= @outgoing_chmod %>
|
outgoing chmod = <%= @outgoing_chmod %>
|
||||||
max connections = <%= @max_connections %>
|
max connections = <%= @max_connections %>
|
||||||
<% if Integer(@max_connections) > 0 %>lock file = <%= @lock_file %><% end %>
|
<% if Integer(@max_connections) > 0 -%>
|
||||||
<% if @comment %>comment = <%= @comment %><% end %>
|
lock file = <%= @lock_file %>
|
||||||
<% if @secrets_file %>secrets file = <%= @secrets_file %><% end %>
|
<% end -%>
|
||||||
<% if @auth_users %>auth users = <%= @auth_users.to_a.join(', ')%><% end %>
|
<% if @comment -%>
|
||||||
<% if @hosts_allow %>hosts allow = <%= @hosts_allow.to_a.join(' ')%><% end %>
|
comment = <%= @comment %>
|
||||||
<% if @hosts_deny %>hosts deny = <%= @hosts_deny.to_a.join(' ')%><% end %>
|
<% end -%>
|
||||||
|
<% if @secrets_file -%>
|
||||||
|
secrets file = <%= @secrets_file %>
|
||||||
|
<% end -%>
|
||||||
|
<% if @auth_users -%>
|
||||||
|
auth users = <%= @auth_users.to_a.join(', ')%>
|
||||||
|
<% end -%>
|
||||||
|
<% if @hosts_allow -%>
|
||||||
|
hosts allow = <%= @hosts_allow.to_a.join(' ')%>
|
||||||
|
<% end -%>
|
||||||
|
<% if @hosts_deny -%>
|
||||||
|
hosts deny = <%= @hosts_deny.to_a.join(' ')%>
|
||||||
|
<% end -%>
|
||||||
|
<% if @exclude -%>
|
||||||
|
exclude = <%= @exclude.to_a.join(' ')%>
|
||||||
|
<% end -%>
|
||||||
|
Loading…
Reference in New Issue
Block a user