Supervisor groups in Stouts.supervisor for Ansible

This week I made a pull request to support groups in Stouts.supervisor.

It was simple, I refactored the code a bit to use a Jinja macro to build the sections, since the configuration structure in the sections is all the same.


{% macro set_section(section_label, sections) %}
    {% for section in sections %}
        [{{ section_label }}:{{ section.name }}]

        {% for option, value in section.items() %}
            {% if option != 'name' %}
                {{ option }} = {{ value }}
            {% endif %}
        {% endfor %}
    {% endfor %}
{% endmacro %}

...

{{ set_section('program', supervisor_tasks) }}

...

{{ set_section('group', supervisor_groups) }}

This role has all supervisor configuration in the main file. I always use conf.d to separate different configurations, I guess that will be next in this role. :-)

Here my fork of Stouts.supervisor.

Javier Aguirre

Read more posts by this author.

comments powered by Disqus