diff --git a/README.md b/README.md index d0cce13..b5bde9e 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/#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 (false|startup|running). + +```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/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", diff --git a/templates/rsync.conf.lua.erb b/templates/rsync.conf.lua.erb index b301372..cbcc9c3 100644 --- a/templates/rsync.conf.lua.erb +++ b/templates/rsync.conf.lua.erb @@ -2,6 +2,13 @@ sync { default.rsync, source = "<%= @source %>", target = "<%= @target %>", + <%- if @delete != true -%> + <%- if @delete == false -%> + delete = <%= @delete %>, + <%- else -%> + delete = "<%= @delete %>", + <%- end -%> + <%- end -%> rsync = { <% @options.each do |key, val| -%> <%= key %> = <%= val %>, diff --git a/templates/rsyncssh.conf.lua.erb b/templates/rsyncssh.conf.lua.erb index 69c2dee..1afbd45 100644 --- a/templates/rsyncssh.conf.lua.erb +++ b/templates/rsyncssh.conf.lua.erb @@ -2,6 +2,13 @@ sync { default.rsyncssh, source = "<%= @source %>", targetdir = "<%= @targetdir %>", + <%- if @delete != true -%> + <%- if @delete == false -%> + delete = <%= @delete %>, + <%- else -%> + delete = "<%= @delete %>", + <%- end -%> + <%- end -%> host = "<%= @host %>", rsync = { <% @rsync_options.each do |key, val| -%>