Adding New UCS Modules to Ansible

Hello Everyone,

I recently started working on a project for UCS Manager in Ansible using the Python SDK for UCS. The code is https://github.com/btotharye/ansible-ucs. My question is that I would like to start getting this added into the main modules section of the Ansible code if possible. I know there is documentation on this but my main question is should I do it after I have all modules done or as I create new modules should I try to add them in? The main goal of this project I’m creating will be to allow you to completely configure most things in UCS Manager using Ansible.

This is my first time taking on a task like this so I was looking for some feedback from others that have already created custom modules for Ansible.

Any information anyone can provide on this would be most appreciated.

Thanks

This isn’t a direct answer to your question, but more in alignment with getting them eventually merged into the ansible codebase, a few things that I would like to see changed:

  1. Remove the dependency on jsonpickle
  2. Remove the ucs_login and ucs_logout modules
  3. Move the login/logout code into shared code that would live in ansible/module_utils/ucs.py
  4. All modules should utilize the shared login/logout code, instead of logging in in 1 module, passing that around between all the modules, and eventually passing to a logout module. Each module should log in, do work, log out.

Thanks I know I got a bit of cleanup to do before I’m there. Out of curiosity how do you deal with handles like this and the json data without using something like pickle? The issue I had before was without encoding it never seemed to work correctly on processing the data from the handle object.

Thanks I know I got a bit of cleanup to do before I'm there. Out of
curiosity how do you deal with handles like this and the json data without
using something like pickle? The issue I had before was without encoding
it never seemed to work correctly on processing the data from the handle
object.

I think I answered that in my bullets. You really shouldn't be doing what
you are. I strongly believe that the ucs_login and ucs_logout modules
should be removed, and each module should handle log in, execution, and
then log out. Doing that is in best alignment with how other modules work,
and removes the need to pass around a handle.

Sorry makes sense a lot of this is new to me and I’m learning by doing and reading through the ansible documentation. I had the ucs_login and logout as ways initially to get this working and thats why I now want to update this to fall more inline with how Ansible works.

I’ll work on creating a ucs.py that will perform the login/logout operations and go from there.

Thanks

So I spent some time over the weekend updating my code and wouldn’t mind feedback on it. I moved the login/logout for now into a bigger UCS class in the ucs.py file that is right now located in the library folder. In order to fall more in line I built the code in such a way that it expects this ucs.py file to reside in module-utils dir of ansible in order to be able to hopefully contribute this later on. I’m sure there are still things I’m doing wrong but I’ve been reading through more of the Ansible documentation to learn the right way to all of this and it takes time.

It is no where near being done but I’m working on getting all the different functions I want in each file now and getting the documentation completed.

https://github.com/btotharye/ansible-ucs

Curious if I should be doing this any different since its not actually a part of Ansible yet or is this type of “mentality” the right way to build this or should my ucs.py be a part of my own internal library for now until later when its fully done and ready to be committed? I know some of these questions are up to each individual I guess as well.

I am getting an error when I try to run the vlan creation playbook - The error was: ImportError: No module named library.ucs. I was wondering if anyone has seen this issue before?

https://github.com/CiscoUcs/ucsm-ansible
an cisco official effort, worth checking

luni, 16 ianuarie 2017, 18:29:48 UTC+1, brian hopkins a scris: