From 30b18a9ab69f2eac212f9b61996174b78f16c961 Mon Sep 17 00:00:00 2001 From: wbob Date: Sat, 29 Apr 2017 12:20:40 +0200 Subject: [PATCH 1/7] add delete option --- README.md | 11 +++++++++++ manifests/rsync.pp | 1 + manifests/sync/rsync.pp | 1 + manifests/sync/rsyncssh.pp | 1 + templates/rsync.conf.lua.erb | 1 + templates/rsyncssh.conf.lua.erb | 1 + 6 files changed, 16 insertions(+) diff --git a/README.md b/README.md index d0cce13..303fde2 100644 --- a/README.md +++ b/README.md @@ -22,5 +22,16 @@ lsyncd::rsync: archive: true ``` +# Deletions + +"[By default](https://axkibe.github.io/lsyncd/manual/config/layer4/) Lsyncd will delete files on the target that are not present at the source". +If you need to divert from this behaviour, set one of the possible flags. + +```yaml + source: /tmp/source + target: /tmp/target + delete: false +``` + # Alternatives You might prefer [this lsyncd module](https://github.com/spjmurray/puppet-lsyncd) for Ubuntu, or [this one](https://github.com/thias/puppet-lsyncd) for RHEL. diff --git a/manifests/rsync.pp b/manifests/rsync.pp index 9b97ee3..5bfe75f 100644 --- a/manifests/rsync.pp +++ b/manifests/rsync.pp @@ -3,6 +3,7 @@ $source = undef, $target = undef, $ensure = present, + $delete = true, $options = {}, ) { lsyncd::sync::rsync{$name: diff --git a/manifests/sync/rsync.pp b/manifests/sync/rsync.pp index 35f6ee2..0734e6b 100644 --- a/manifests/sync/rsync.pp +++ b/manifests/sync/rsync.pp @@ -2,6 +2,7 @@ $source = undef, $target = undef, $ensure = present, + $delete = true, $options = {}, ) { $path = "${lsyncd::config_dir}/sync.d/${name}.conf.lua" diff --git a/manifests/sync/rsyncssh.pp b/manifests/sync/rsyncssh.pp index b4c1baf..78c9f20 100644 --- a/manifests/sync/rsyncssh.pp +++ b/manifests/sync/rsyncssh.pp @@ -3,6 +3,7 @@ $targetdir, $host, $ensure = present, + $delete = true, $rsync_options = {}, $ssh_options = {}, ) { diff --git a/templates/rsync.conf.lua.erb b/templates/rsync.conf.lua.erb index b301372..46a4a30 100644 --- a/templates/rsync.conf.lua.erb +++ b/templates/rsync.conf.lua.erb @@ -2,6 +2,7 @@ sync { default.rsync, source = "<%= @source %>", target = "<%= @target %>", + delete = "<%= @delete %>", rsync = { <% @options.each do |key, val| -%> <%= key %> = <%= val %>, diff --git a/templates/rsyncssh.conf.lua.erb b/templates/rsyncssh.conf.lua.erb index 69c2dee..9a81595 100644 --- a/templates/rsyncssh.conf.lua.erb +++ b/templates/rsyncssh.conf.lua.erb @@ -2,6 +2,7 @@ sync { default.rsyncssh, source = "<%= @source %>", targetdir = "<%= @targetdir %>", + delete = "<%= @delete %>", host = "<%= @host %>", rsync = { <% @rsync_options.each do |key, val| -%> From 616a4f6796f698f409e127363d0b65b1110ceb64 Mon Sep 17 00:00:00 2001 From: wbob Date: Sun, 11 Jun 2017 12:55:29 +0200 Subject: [PATCH 2/7] fixed option to use boolean values instead of string --- templates/rsync.conf.lua.erb | 2 +- templates/rsyncssh.conf.lua.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/rsync.conf.lua.erb b/templates/rsync.conf.lua.erb index 46a4a30..6435605 100644 --- a/templates/rsync.conf.lua.erb +++ b/templates/rsync.conf.lua.erb @@ -2,7 +2,7 @@ sync { default.rsync, source = "<%= @source %>", target = "<%= @target %>", - delete = "<%= @delete %>", + delete = <%= @delete %>, rsync = { <% @options.each do |key, val| -%> <%= key %> = <%= val %>, diff --git a/templates/rsyncssh.conf.lua.erb b/templates/rsyncssh.conf.lua.erb index 9a81595..75d5c34 100644 --- a/templates/rsyncssh.conf.lua.erb +++ b/templates/rsyncssh.conf.lua.erb @@ -2,7 +2,7 @@ sync { default.rsyncssh, source = "<%= @source %>", targetdir = "<%= @targetdir %>", - delete = "<%= @delete %>", + delete = <%= @delete %>, host = "<%= @host %>", rsync = { <% @rsync_options.each do |key, val| -%> From ef029a1761307b04f3c74c739583de00784fd49e Mon Sep 17 00:00:00 2001 From: wbob Date: Sun, 11 Jun 2017 13:31:56 +0200 Subject: [PATCH 3/7] include delete option only if false --- templates/rsync.conf.lua.erb | 2 ++ templates/rsyncssh.conf.lua.erb | 2 ++ 2 files changed, 4 insertions(+) diff --git a/templates/rsync.conf.lua.erb b/templates/rsync.conf.lua.erb index 6435605..0aeed7e 100644 --- a/templates/rsync.conf.lua.erb +++ b/templates/rsync.conf.lua.erb @@ -2,7 +2,9 @@ sync { default.rsync, source = "<%= @source %>", target = "<%= @target %>", + <%- if @delete == false -%> delete = <%= @delete %>, + <%- end -%> rsync = { <% @options.each do |key, val| -%> <%= key %> = <%= val %>, diff --git a/templates/rsyncssh.conf.lua.erb b/templates/rsyncssh.conf.lua.erb index 75d5c34..69374dd 100644 --- a/templates/rsyncssh.conf.lua.erb +++ b/templates/rsyncssh.conf.lua.erb @@ -2,7 +2,9 @@ sync { default.rsyncssh, source = "<%= @source %>", targetdir = "<%= @targetdir %>", + <%- if @delete == false -%> delete = <%= @delete %>, + <%- end -%> host = "<%= @host %>", rsync = { <% @rsync_options.each do |key, val| -%> From 75d3e1e6732689b0831352a01ff7bafc753ed08b Mon Sep 17 00:00:00 2001 From: wbob Date: Sun, 11 Jun 2017 13:57:27 +0200 Subject: [PATCH 4/7] clarify README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 303fde2..d55417c 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ lsyncd::rsync: # Deletions -"[By default](https://axkibe.github.io/lsyncd/manual/config/layer4/) Lsyncd will delete files on the target that are not present at the source". -If you need to divert from this behaviour, set one of the possible flags. +"[By default](https://axkibe.github.io/lsyncd/manual/config/layer4/#deletions) Lsyncd will delete files on the target that are not present at the source". +If you need to divert from this behaviour, set one of the other possible flags (delete|startup|running). ```yaml source: /tmp/source From dc15b6e06a02e968c0c5eba6e66d4cf30aef17dc Mon Sep 17 00:00:00 2001 From: wbob Date: Sun, 11 Jun 2017 14:05:09 +0200 Subject: [PATCH 5/7] implement the possible delete parameters beyond boolean false --- templates/rsync.conf.lua.erb | 6 +++++- templates/rsyncssh.conf.lua.erb | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/templates/rsync.conf.lua.erb b/templates/rsync.conf.lua.erb index 0aeed7e..cbcc9c3 100644 --- a/templates/rsync.conf.lua.erb +++ b/templates/rsync.conf.lua.erb @@ -2,8 +2,12 @@ sync { default.rsync, source = "<%= @source %>", target = "<%= @target %>", - <%- if @delete == false -%> + <%- if @delete != true -%> + <%- if @delete == false -%> delete = <%= @delete %>, + <%- else -%> + delete = "<%= @delete %>", + <%- end -%> <%- end -%> rsync = { <% @options.each do |key, val| -%> diff --git a/templates/rsyncssh.conf.lua.erb b/templates/rsyncssh.conf.lua.erb index 69374dd..1afbd45 100644 --- a/templates/rsyncssh.conf.lua.erb +++ b/templates/rsyncssh.conf.lua.erb @@ -2,8 +2,12 @@ sync { default.rsyncssh, source = "<%= @source %>", targetdir = "<%= @targetdir %>", - <%- if @delete == false -%> + <%- if @delete != true -%> + <%- if @delete == false -%> delete = <%= @delete %>, + <%- else -%> + delete = "<%= @delete %>", + <%- end -%> <%- end -%> host = "<%= @host %>", rsync = { From 60773c31c8b265622dcd4fc4bdbc08be68080a31 Mon Sep 17 00:00:00 2001 From: wbob Date: Sun, 11 Jun 2017 14:06:17 +0200 Subject: [PATCH 6/7] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d55417c..b5bde9e 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ lsyncd::rsync: # Deletions "[By default](https://axkibe.github.io/lsyncd/manual/config/layer4/#deletions) Lsyncd will delete files on the target that are not present at the source". -If you need to divert from this behaviour, set one of the other possible flags (delete|startup|running). +If you need to divert from this behaviour, set one of the other possible flags (false|startup|running). ```yaml source: /tmp/source From 44add03c0e353fdc9edc776b17c52fc7fddbf47a Mon Sep 17 00:00:00 2001 From: wbob Date: Sun, 11 Jun 2017 14:48:14 +0200 Subject: [PATCH 7/7] bump version to 1.2.3 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 5f02813..da118f5 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "negz-lsyncd", - "version": "1.2.2", + "version": "1.2.3", "author": "Nic Cope", "license": "Apache-2.0", "summary": "Yet another lsyncd module",