Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade formula to standards #2

Merged
merged 4 commits into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
===============
================
lighttpd-formula
===============
================

A simple saltstack formula to install and configure lighttpd.

Expand All @@ -19,15 +19,18 @@ configuration lines in the templates provided.

When providing pillar data is not enough for your needs, you can apply the
_Template Override and Files Switch_ (TOFS) pattern as described in the
documentation file `TOFS_pattern.md`.
documentation file `TOFS_pattern.rst`.

.. note::

Currently this formula supports Debian and Arch os_family.
Currently this formula supports RedHat, Debian, Suse and Arch os_family.
Some distributions provide modules as extra packages, you can add them
via pillar extra_packages list.

TODO:
This formula doesn't manage lighttpd configuration modules on all Systems
only Debian is supported.
only Debian is supported.
Vhost support

See the full `Salt Formulas
<http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_ doc.
Expand All @@ -39,18 +42,17 @@ Available states
:local:

``lighttpd``
-----------
------------

Meta-state for inclusion of all states for lighttpd.

``lighttpd.install``
--------------------

Installs the lighttpd package.

Installs the lighttpd package. If extra_packages are supported via pillar.

``lighttpd.config``
----------------
-------------------

Configures the lighttpd package.

Expand All @@ -60,7 +62,7 @@ Configures the lighttpd package.
Manages the startup and running state of the lighttpd service.

``lighttpd.modules``
-----------------
--------------------

Manages the modules via lighty-mods-enable/disable on Debian systems.
This is pillar driven see pillar.example
Expand Down
2 changes: 0 additions & 2 deletions TOFS_pattern.md → TOFS_pattern.rst
Original file line number Diff line number Diff line change
Expand Up @@ -312,5 +312,3 @@ The generalization of this comes with the usage of the macro `files_switch` in a
{%- endfor %}
{%- endmacro %}
```


22 changes: 18 additions & 4 deletions lighttpd/config.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@
#
# Manages the main lighttpd server configuration file.

{% from "lighttpd/map.jinja" import lighttpd with context %}
{% from "lighttpd/macros.jinja" import files_switch with context -%}
{#- Get the `tplroot` from `tpldir` #}
{%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_package_install = tplroot ~ '.install' %}
{% from tplroot ~ "/map.jinja" import lighttpd with context %}
{% from tplroot ~ "/macros.jinja" import files_switch with context -%}
{% set file = lighttpd.get('config', ['lighttpd.conf']) %}

include:
- {{ sls_package_install }}

lighttpd_config:
file.managed:
- name: /etc/lighttpd/{{ lighttpd.config }}
- source: {{ files_switch('lighttpd', ['/etc/lighttpd/' ~ file,
'/etc/lighttpd/' ~ file ~ '.jinja']) }}
- source: {{ files_switch(
salt['config.get'](
tplroot ~ ':tofs:files:lighttpd_config',
['/etc/lighttpd/lighttpd.conf', '/etc/lighttpd/lighttpd.conf.jinja']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the default template. Since you're only using /etc/lighttpd/lighttpd.conf in the repo, /etc/lighttpd/lighttpd.conf.jinja can be removed.

)
) }}
- mode: 644
- user: root
- group: root
- template: jinja
- require:
- sls: {{ sls_package_install }}
14 changes: 14 additions & 0 deletions lighttpd/defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
lighttpd:
package: lighttpd
extra_packages: []
service: lighttpd
config: lighttpd.conf
conf_available: /etc/lighttpd/conf.d
conf_enabled: /etc/lighttpd/conf.d
conf_use_symlink: False
modules:
enabled: []
disabled: []
Loading