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
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
added info - I am running on Centos8 release 8.2.2004
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
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
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
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
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
Hi,
I am running into similar issue and I get following error. Can anyone please help?
ansible: 2.11.6
python: 3.9.9
As stated above, I did download ansible Commvault module from GitHub into library directory but still get following issue:
TASK KLogin] *************************************************************************************************************************************************************************************************************
fatal: :localhost]: FAILED! => {"msg": "module (commvault) is missing interpreter line"}
@Tej , I checked out database for that error and didn’t find anything.
I would suggest creating a case with support.
Please share the solution here once resolved
Hi Mike,
I was able to solve it on my own. I had ended up creating Commvault’s python file and ansible.cfg in ansiblevenv\library folder and voila it worked like a charm!!
Thank you very much.
Thanks for sharing, @Tej !
Hi Wondering if Commvault has any module in ansible to support Server restore rather than just files restore. Currently below is what I am using to restore a file in ansible.
- name: Restore
commvault:
operation: "restore_in_place"
entity_type: subclient
commcell: "{{ commcell }}"
entity: {
client: "vcentertest",
agent: "Virtual Server",
backupset: "defaultbackupset",
subclient: "BackupTesting"
}
args: {
paths: \tst-cvlt-ansi\C$\Windows\Logs\CBS]
}
register: restore_job
@Tej , I’ll tag @Sachin in for his reply!
Hi @Tej,
Can you please help me understand what you mean by Server restore here? Are you trying full VM restore? If yes, which hypervisor is this?
Thanks,
Sachin
Hi Sachin,
Thank you for your reply.
Yes I am trying to perform a full VM-Backup and Restore on Esxi 7.0, VMware client.
Hi @Tej
Please use this script
- name: full backup
commvault:
operation: "backup"
entity_type: subclient
commcell: "{{ commcell }}"
entity: {
client: "{{ client }}",
agent: "Virtual Server",
backupset: "{{ backupset }}",
subclient: "{{ subclient }}"
}
args: {
backup_level: "Full"
}
- name: restore
commvault:
operation: "full_vm_restore_in_place"
entity_type: subclient
commcell: "{{ commcell }}"
entity: {
client: "{{ client }}",
agent: "Virtual Server",
backupset: "{{ backupset }}",
subclient: "{{ subclient }}"
}
args: {
vm_to_restore: "{{ vm_name }}"
}
You can check out other args you can pass to the restore function here: https://github.com/Commvault/cvpysdk/blob/fbcbb183d2c66c4156a2b9aa1e5a17b245866a3f/cvpysdk/subclients/virtualserver/vmware.py#L85
Hello Team,
First and foremost thank you for your continuous community support. With the help of yours as the bare metal restore was done. We would like to start automating backup and restores (on demand) using ansible, so that it can be part of a deployment pipeline as needed.
In this regards, can anyone help to let me know if there is any module for IBM Db2 LUW backup and restore modules?
Thank you in advance.
Hello Team,
First and foremost thank you for your continuous community support. With the help of yours as the bare metal restore was done. We would like to start automating backup and restores (on demand) using ansible, so that it can be part of a deployment pipeline as needed.
In this regards, can anyone help to let me know if there is any module for IBM Db2 LUW backup and restore modules?
Thank you in advance.
@Mike Struening / @kevinj can you please shed some insight?
I’ll defer to @kevinj on this for his thoughts.
Hi @Tej
Please check if this will help
- name: full backup
commvault:
operation: "db2_backup"
entity_type: subclient
commcell: "{{ commcell }}"
entity: {
client: "{{ client }}",
agent: "DB2",
backupset: "{{ backupset }}",
subclient: "{{ subclient }}"
}
args: {
backup_level: "Full"
}
- name: full restore
commvault:
operation: "restore_entire_database"
entity_type: backupset
commcell: "{{ commcell }}"
entity: {
client: "{{ client }}",
agent: "DB2",
backupset: "{{ backupset }}",
}
args: {
dest_client_name: "{{ dest_client }}",
dest_instance_name: "{{ dest_instance }}",
dest_database_name: "{{ dest_db }}"
}