From 630bbcd55f88ca37c7b1599a5ec5498be901feb4 Mon Sep 17 00:00:00 2001 From: Martin Hoefling Date: Sat, 2 May 2015 00:06:42 +0200 Subject: [PATCH] Initial commit --- CHANGELOG.rst | 26 ++------------------------ LICENSE | 2 +- pillar.example | 16 +++++++++++++--- rsyncd/config.sls | 20 ++++++++++++++++++++ rsyncd/files/secrets.jinja | 3 +++ rsyncd/init.sls | 18 ++++++++++++++---- rsyncd/map.jinja | 11 ++++++----- 7 files changed, 59 insertions(+), 37 deletions(-) create mode 100644 rsyncd/files/secrets.jinja diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e4cc4e6..405d3ae 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,28 +1,6 @@ -template formula +rsyncd formula ================ -0.0.5 (2014-07-28) - -- Fixed broken link to Salt Formula documentation - - -0.0.4 (2014-02-26) - -- Add CHANGELOG.rst - - -0.0.3 (2014-02-17) - -- Add map.jinja -- Use map.jinja content in init.sls - - -0.0.2 (2014-02-16) - -- Better README extension changed from .md to .rst -- Add link to Salt Formula documentation - - -0.0.1 (2013-11-03) +0.0.1 (2015-05-01) - Initial version diff --git a/LICENSE b/LICENSE index 3e21c72..7e5bb48 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ - Copyright (c) 2014 Salt Stack Formulas + Copyright (c) 2015 Salt Stack Formulas Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pillar.example b/pillar.example index d034252..1d5c4c9 100644 --- a/pillar.example +++ b/pillar.example @@ -1,3 +1,13 @@ -template: - lookup: - master: template-master +rsyncd: + secrets: + user: mypassword + config: | + uid = nobody + gid = nobody + use chroot = yes + max connections = 4 + syslog facility = local5 + pid file = /var/run/rsyncd.pid + [ftp] + path = /var/ftp/./pub + comment = whole ftp area (approx 6.1 GB) diff --git a/rsyncd/config.sls b/rsyncd/config.sls index e69de29..435bd88 100644 --- a/rsyncd/config.sls +++ b/rsyncd/config.sls @@ -0,0 +1,20 @@ +{% from "rsyncd/map.jinja" import rsyncd with context %} +include: + - rsyncd + +rsyncd_config_file: + file.managed: + - name: {{ rsyncd.configfile }} + - contents_pillar: rsyncd:config + - watch_in: + - service: rsync + +{% if salt['pillar.get']('rsyncd:secrets') %} +rsyncd_secrets_file: + file.managed: + - name: {{ rsyncd.secretsfile }} + - watch_in: + - service: rsync + - source: salt://rsyncd/files/secrets.jinja + - template: jinja +{% endif %} diff --git a/rsyncd/files/secrets.jinja b/rsyncd/files/secrets.jinja new file mode 100644 index 0000000..fb5aa51 --- /dev/null +++ b/rsyncd/files/secrets.jinja @@ -0,0 +1,3 @@ +{% for key, value in salt['pillar.get']('rsyncd:secrets').iteritems() %} +{key}:{value} +{% endfor%} diff --git a/rsyncd/init.sls b/rsyncd/init.sls index 168f466..a57bc33 100644 --- a/rsyncd/init.sls +++ b/rsyncd/init.sls @@ -1,8 +1,18 @@ -{% from "template/map.jinja" import template with context %} +{% from "rsyncd/map.jinja" import rsyncd with context %} -template: +rsync: pkg.installed: - - name: {{ template.pkg }} + - name: {{ rsyncd.pkg }} service.running: - - name: {{ template.service }} + - name: {{ rsyncd.service }} - enable: True + +{% if grains.os_family == 'Debian' %} +/etc/default/rsync: + file.replace: + - pattern: ^.*RSYNC_ENABLE=.*$ + - repl: RSYNC_ENABLE=true + - append_if_not_found: True + - watch_in: + - service: rsync +{% endif %} diff --git a/rsyncd/map.jinja b/rsyncd/map.jinja index 6275604..d16bd9b 100644 --- a/rsyncd/map.jinja +++ b/rsyncd/map.jinja @@ -1,7 +1,8 @@ -{% set rsync = salt['grains.filter_by']({ +{% set rsyncd = salt['grains.filter_by']({ 'Debian': { - 'pkg': 'rsyncd', - 'service': 'rsyncd', - 'config': '/etc/rsyncd.conf', + 'pkg': 'rsync', + 'service': 'rsync', + 'configfile': '/etc/rsyncd.conf', + 'secretsfile': '/etc/rsyncd.secrets' }, -}, merge=salt['pillar.get']('rsync:lookup')) %} +}, merge=salt['pillar.get']('rsyncd:lookup')) %}