Hello,

I'm interested in extending the svc module for nosh (and possibly other
daemontools family toolsets) and have a couple of questions/observations.

A. current svc extension issues
==================================

The module currently defines a "_load_dist_subclass" function which can
be called from the Svc class but is commented out there.

It is similar to the "load_platform_subclass" mechanism available from
module_utils/basic.py.

If uncommented to enable this mechanism, however, a run fails with the
following error:

        Traceback (most recent call last):
        File "/tmp/ansible_thaxkjfw/ansible_module_svc.py", line 321, in 
<module>
            main()
        File "/tmp/ansible_thaxkjfw/ansible_module_svc.py", line 281, in main
            svc = Svc(module)
        File "/tmp/ansible_thaxkjfw/ansible_module_svc.py", line 137, in __new__
            return _load_dist_subclass(cls, args, kwargs)
        File "/tmp/ansible_thaxkjfw/ansible_module_svc.py", line 117, in 
_load_dist_subclass
            distro = kwargs['module'].params['distro']
        KeyError: 'module'

The offending line is:

        distro = kwargs['module'].params['distro']

The idea is to get the 'distro' parameter provided by the user call (or
the default). There's a trivial issue due to the fact that it's
actually defined as 'dist' in the AnsibleModule passed in, but this is
not the cause for the error.

I replaced the line with:

        distro = args[0][0].params['distro']

Which works. But I have to say that I rather stumbled upon it and I'm
not sure how robust it is (I'm quite unfamiliar with Ansible internals).

-> Is there a better way to reference this parameter?

To subclass, one then just creates something like:

        class Subclass(Svc):
                distro = "subclass-name"
                ...

Which I have done for nosh.

The preliminary code is available here:

https://github.com/tacatac/ansible_svc_module

I've not bothered to clone the ansible repository there but can do so
eventually to create a pull request if there's any interest.


B. system/runit and system/service
==================================

I noticed that system/runit.py is apparently a transposition of the svc
module, with the same problematic _load_dist_subclass function (but the
same offer to be used for derivative implementations ;)

It should be easy to subclass Runit in the svc module.

Ideally these managers should be integrated to system/service for
high-level use, but that module seems to have an OS-first discovery
logic while runit and nosh (and certainly other daemontools suites) can
run on various platforms. Which might be awkward to implement.

Regards,
taca

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to