geerlingguy/ansible-role-supervisor

var supervisor_programs list vs dict

Closed this issue · 2 comments

Is there a reason to use a list in place of a dict to define supervisor_programs ?

You define it like this:

supervisor_programs:
    - name: 'apache'
        command: "{{ apache_start_command }}"
        state: present
        configuration: |
            autostart=true
            autorestart=true
            startretries=1
            startsecs=1
            redirect_stderr=true
            stderr_logfile=/var/log/apache-err.log
            stdout_logfile=/var/log/apache-out.log
            user=root
            killasgroup=true
            stopasgroup=true

Why not define it like this:

supervisor_programs:
    apache:
        command: "{{ apache_start_command }}"
        state: present
        autostart: true
        autorestart: true
        startretries: 1
        startsecs: 1
        redirect_stderr: true
        stderr_logfile: /var/log/apache-err.log
        stdout_logfile: /var/log/apache-out.log
        user: root
        killasgroup: true
        stopasgroup: true

It will simplify a little the programm conf template:

[program:{{ item.key }}]
{% for option, value in item.value.iteritems() %}
{{ option }} = {{ value }}
{% endfor %}

Maybe I miss something 😕

For one, state: present would need to be filtered out from that list (it's used as a flag for whether to include the job or not).

I also like managing programs as completely independent entities, thus one array/list item per program, and a separate conf.d file per program. If it's ordered as a dict, then it feels like it's supposed to be more formally structured—and it makes it more difficult (imo) to separate out 'metadata' type information (like state, for now) from actual program configuration values.

Oh yeah, I missed that line ! 😅

Thank you for that good explanation !