Solved

Commvault Ansible

  • 8 April 2021
  • 9 replies
  • 121 views

Badge +3

Anyone using CVPySDK and Ansible?  

I am unable to get it to function.  I have pip installed and can run the commcell functions from within the python interpreter.

When I attempt to use it in a playbook, I get an error…

 

ERROR! couldn’t resolve module/action ‘commvault’

 

Ansible 2.10.7

python 3.6.8.

 

Ken

icon

Best answer by keng 10 April 2021, 15:43

Thank you Sachin!

 

That was the problem.  I was confused (as a new Ansible developer) as to what the module was.

I thought that cvpysdk was the module and missed that the git repository and cvpysdk were two different things.

 

I have now successfully authenticated with Ansible.

Thanks for your help.

 

Ken

View original

9 replies

Userlevel 5
Badge +10

Hi @keng 

Thank you for the question and welcome to the Community!

Just to cover off some basics, please confirm the initial steps have been performed from:

https://github.com/Commvault/ansible

Installing CVPySDK

CVPySDK can be installed directly from PyPI using pip:

>>> pip install cvpysdk

CVPySDK is available on GitHub here

It can also be installed from source.

After downloading, from within the cvpysdk directory, execute:

>>> python setup.py install

 

Thanks,

Stuart

Badge +3

Hi @keng 

Thank you for the question and welcome to the Community!

Just to cover off some basics, please confirm the initial steps have been performed from:

https://github.com/Commvault/ansible

Installing CVPySDK

CVPySDK can be installed directly from PyPI using pip:

>>> pip install cvpysdk

CVPySDK is available on GitHub here

It can also be installed from source.

After downloading, from within the cvpysdk directory, execute:

>>> python setup.py install

 

Thanks,

Stuart

 

Thanks for the response Stuart!

 

As I indicated in my initial post, I have already installed using the PIP method and I am am able to run the scripts from the python prompt.  

I may be wrong but I thought that the “python setup.py install”  command was to be used only if downloading directly.   I cannot find “setup.py” in the cvpysdk directory after installing using PIP.

Ken

 

 

Badge +3

added info - I am running on Centos8 release 8.2.2004

Userlevel 5
Badge +10

Hi @keng 

I have just attempted following those steps myself on a default lab Commserve and I’m seeing the same as you - there is no setup.py in the cvpysdk directory.

I’ll follow this up internally to see what the process is here.

From the error message, it looks like the python commvault module isn’t fully registered, which I’m assuming should be performed by the setup script, but as we are both seeing this isn’t present in the directory.

I’ll get back to you once I have more info.

Thanks,

Stuart

Badge +3

Thank you!

Badge

Hi @keng,

 

Looks like the commvault ansible module is not detected by ansible. This module is a local module and is not automatically added to the ansible library. You might have to add this to the ANSIBLE_LIBRARY environment variable. For details refer to https://docs.ansible.com/ansible/latest/dev_guide/developing_locally.html

 

Or you can also clone the commvault ansible module and use it exactly the same way, having library directory in the current working directory. 
So if your file is cv_backup.yaml then your folder structure should be like

 

ansible_files/

                library/commvault.py

                cv_backup.yaml

 

Please let us know if you need any other help.

 

Thanks

 

Badge +3

Thanks Sachin,

 

I have attempted what I think you have recommended.

my playbook is:

ansiblevenv/cvlogin.yml

I have created ansiblevenv/library

Within the library folder I have copied all *py in cvpysdk

ie…

ansiblevenv\library\commcell.py

ansiblevenv\library\job.py

…. (etc)

I am still get the same error.

 

I have also used the command line argument -M to point to the original installation folder..

ansible-playbook -M /usr/local/lib/python3.6/site-packages/cvpysdk  “playbook.yml”

same error.

Ken

 

Badge

Hi @keng,

 

Looks like you have copied the cvpysdk files under the library directory. But we have to copy the commvault ansible module (commvault.py) file.

 

You can get a copy of the commvault module from the GitHub repository.

https://github.com/Commvault/ansible/tree/master/library

 

After copying the ansible module your directory structure should look something like below.

ansiblevenv\library\commvault.py

 

Thanks,

Sachin

Badge +3

Thank you Sachin!

 

That was the problem.  I was confused (as a new Ansible developer) as to what the module was.

I thought that cvpysdk was the module and missed that the git repository and cvpysdk were two different things.

 

I have now successfully authenticated with Ansible.

Thanks for your help.

 

Ken

Reply