Last active
September 22, 2015 22:58
-
-
Save mjinks/ba0c04b98189c63facdf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for name, user in pillar.get('users', {}).items() if user.vsftpd_user_config is defined %} | |
{{ name }}_vsftpd_user_conf: | |
file.managed: | |
- name: /etc/vsftpd/vsftpd_user_conf/{{ name }} | |
- source: salt://vsftpd/files/vsftpd_user_conf-TMPL | |
- template: jinja | |
- watch_in: | |
- service: {{ vsftpd.service }} | |
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo salt 'ftp*' state.sls vsftpd | |
ftp01.chi5.prlss.int: | |
Data failed to compile: | |
---------- | |
Rendering SLS 'base:vsftpd.vsftpd_user_config' failed: Jinja variable 'vsftpd' is undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim: sts=2 ts=2 sw=2 | |
{% from "vsftpd/map.jinja" import vsftpd with context %} | |
vsftpd: | |
{% if vsftpd.server is defined %} | |
pkg.installed: | |
- name: {{ vsftpd.server }} | |
{% endif %} | |
service.running: | |
- enable: True | |
- name: {{ vsftpd.service }} | |
{% if vsftpd.server is defined %} | |
- require: | |
- pkg: {{ vsftpd.server }} | |
{% endif %} | |
include: | |
- vsftpd.config | |
- vsftpd.vsftpd_user_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim:ft=yaml: | |
{%- set vsftpd_config = pillar.get('vsftpd_config', {}) -%} | |
{%- set user = pillar.get('user', {}) -%} | |
{#- present in vsftpd_config and known in actual file options -#} | |
{%- set processed_options = [] -%} | |
{#- generic renderer used for vsftpd known options, -#} | |
{#- and unknown options -#} | |
{%- macro render_option(keyword, default, config_dict=vsftpd_config) -%} | |
{%- set value = config_dict.get(keyword, default) -%} | |
{%- if value is string or value is number -%} | |
{{ keyword }}={{ value }} | |
{%- else -%} | |
{%- for single_value in value -%} | |
{{ keyword }}={{ single_value }} | |
{% endfor -%} | |
{%- endif -%} | |
{%- endmacro -%} | |
{#- macros for render option according to present -#} | |
{%- macro option_impl(keyword, default, present) -%} | |
{%- if present -%} | |
{%- do processed_options.append(keyword) -%} | |
{%- set prefix='' -%} | |
{%- else -%} | |
{#- add prefix to keyword -#} | |
{%- set keyword = prefix ~ keyword -%} | |
{{ render_option(keyword, default) }} | |
{%- endmacro -%} | |
{#- macros for render option commented by default -#} | |
{%- macro option(keyword, default, present) -%} | |
{{ option_impl(keyword, default, keyword in vsftpd_config) }} | |
{%- endmacro -%} | |
{#- macros for render option uncommented by default -#} | |
{%- macro option_default_uncommented(keyword, default, present) -%} | |
{{ option_impl(keyword, default, True) }} | |
{%- endmacro -%} | |
{{ option('anonymous_enable', 'NO') }} | |
{{ option('local_enable', 'YES') }} | |
{{ option('write_enable', 'YES') }} | |
{{ option('local_umask', '002') }} | |
{{ option('dirmessage_enable', 'YES') }} | |
{{ option('xferlog_enable', 'YES') }} | |
{{ option('dual_log_enable', 'YES') }} | |
{{ option('pasv_enable', 'YES') }} | |
{{ option('pasv_promiscuous', 'YES') }} | |
{{ option('pasv_min_port', '50000') }} | |
{{ option('pasv_max_port', '55000') }} | |
{{ option('connect_from_port_20', 'YES') }} | |
{{ option('vsftpd_log_file', '/var/log/vsftpd.log') }} | |
{{ option('xferlog_file', '/var/log/xferlog.log') }} | |
{{ option('xferlog_std_format', 'NO') }} | |
{{ option('nopriv_user', 'ftpsecure') }} | |
{{ option('ftpd_banner', '"Peerless Network Download Server"') }} | |
{{ option('chroot_list_enable', 'YES') }} | |
{{ option('chroot_list_file', '/etc/vsftpd/vsftpd.chroot_list') }} | |
{{ option('chroot_local_user', 'NO') }} | |
{{ option('hide_ids', 'YES') }} | |
{{ option('tcp_wrappers', 'NO') }} | |
{{ option('use_localtime', 'YES') }} | |
{{ option('userlist_deny', 'NO') }} | |
{{ option('userlist_enable', 'YES') }} | |
{{ option('userlist_file', '/etc/vsftpd/vsftpd.user_list') }} | |
{{ option('user_config_dir', '/etc/vsftpd/vsftpd_user_conf') }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment