Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Feb 13, 2017
0 parents commit aee977a
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 0 deletions.
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Copyright (c) 2017 Richard Clark <[email protected])

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Derived from the dhcpd-formula from Salt Stack Formulas under the following licence

Copyright (c) 2013-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.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
34 changes: 34 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
tftpd
=====

Formula to install, configure and start tftpd.

.. note::

See the full `Salt Formulas installation and usage instructions
<http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_.

Available states
================

.. contents::
:local:

``tftpd``
---------

Install and turn on tftpd.

.. note::

To have more pythonic variables the dashes ('-') in their names
are replaced with underscores ('_') so 'dynamic-bootp' becomes
'dynamic_bootp' in pillar[tftpd].

``tftpd.config``
----------------

Manage configuration for tftpd.
Includes tftpd state as well

See ``pillar.example`` for pillar-data for a sample configuration.
5 changes: 5 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tftpd:
user: tftp
directory: /srv/tftp
address: '0.0.0.0:69'
options: '--secure'
24 changes: 24 additions & 0 deletions tftpd/config.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% from "tftpd/map.jinja" import tftpd, tftpd_settings with context %}
include:
- tftpd
{% if tftpd.service_config is defined %}
service_config:
file.managed:
- name: {{ tftpd.service_config }}
- source: {{ 'salt://tftpd/files/service_config.' ~ salt['grains.get']('os_family') }}
- makedirs: True
- template: jinja
- user: root
{% if 'BSD' in salt['grains.get']('os') %}
- group: wheel
{% else %}
- group: root
{% endif %}
- mode: 644
- watch_in:
- service: tftpd
{% endif %}
7 changes: 7 additions & 0 deletions tftpd/defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
tftpd:
user: tftp
directory: /srv/tftp
bind_address: '0.0.0.0:69'
options: '--secure'
11 changes: 11 additions & 0 deletions tftpd/files/service_config.Debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# default/tftpd
#
# SaltStack-generated default configuration for tftpd-hpa
#
# /etc/default/tftpd-hpa
{% from "tftpd/map.jinja" import tftpd_settings with context %}

TFTP_USERNAME="{{ tftpd_settings.user }}"
TFTP_DIRECTORY="{{ tftpd_settings.directory }}"
TFTP_ADDRESS="{{ tftpd_settings.bind_address }}"
TFTP_OPTIONS="{{ tftpd_settings.options }}"
10 changes: 10 additions & 0 deletions tftpd/init.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% from "tftpd/map.jinja" import tftpd with context %}
tftpd:
pkg.installed:
- name: {{ tftpd.server }}
service.running:
- name: {{ tftpd.service }}
- enable: True
- require:
- pkg: tftpd
26 changes: 26 additions & 0 deletions tftpd/map.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# vim: ft=jinja

{## Start with defaults from defaults.yaml ##}
{% import_yaml "tftpd/defaults.yaml" as default_settings %}

{% set tftpd = salt['grains.filter_by']({
'Debian': {
'server': 'tftpd-hpa',
'service': 'tftpd-hpa',
'service_config': '/etc/default/tftpd-hpa',
},
'RedHat': {
'server': 'tftp-server',
'service': 'tftpd',
'config': '/etc/tftpd/tftpd.conf',
},
}, merge=salt['pillar.get']('tftpd:lookup')) %}

{## Merge in salt:lookup pillar ##}
{% set tftpd_settings = salt['pillar.get'](
'tftpd:config',
default=default_settings.tftpd,
merge=True)
%}

0 comments on commit aee977a

Please sign in to comment.