Hi Patrick,

SNMP can definitely be a beast.

I'd be interested if seeing if you could share an example of some of the
output from the snmp module.

My other piece of advice would probably be to define constants for each of
the MIB values, and see if there is an snmp library defines any of these
(it might not).

I'd also move the import to the top of the file, and enclose it in a
try/except ImportError block, so it can produce a nice error when something
is not defined.

calls like "print json.dumps" can be replaced with the "fail_json" and
"exit_json" calls you can see throughout AnsibleModule code.

You can also use the "required_together" feature of argument_spec (grep
through the code) to simplify some of the argument checking.

Variables that are not constants, like SNMP_AUTH should be downcased
("snmp_auth")

Additionally, some duplication like:

snmp_result['ansible_facts']

throughout the system

Could be done just by having the final module return like so:

exit_json(ansible_facts=results)

As you can find done by 'setup', the most basic ansible facts module.


Hope that helps for starters

My other thought is different types of devices might not surface the same
types of things, so it may be possible your module is written for certain
network hardware -- which might make the module not generally applicable?
(i.e. is it always true that an SNMP thing has an IP address?)

Possibly something to think about.

On Wed, Oct 22, 2014 at 3:40 PM, Patrick Ogenstad <[email protected]>
wrote:

> Hi,
>
> I'd like to get some feedback on an Ansible module I've written. It can
> target SNMP devices and collect information which it stores as Ansible
> facts.
>
> There is some more information about the module here:
> http://networklore.com/ansible-snmp-facts/
>
> Specifically I would like to get suggestions about the structure of the
> data which is to be stored.
>
> Best regards
> Patrick
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/49d164d2-4069-4947-87ca-3f042f2ee676%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/49d164d2-4069-4947-87ca-3f042f2ee676%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgypdNa5VL%2BUKLapdPec8M28kxPQxf9A1imgmDoqL%2Bp57A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to