Skip to content

Commvault/ansible

Repository files navigation

Ansible Commvault module

Ansible is a radically simple IT automation engine that automates cloud provisioning, configuration management, application deployment, intra-service orchestration, and many other IT needs.

How Ansible Works | Ansible.com

Getting started with Ansible

Getting started with playbooks

Introduction

Ansible Commvault module can be used in playbooks to automate commvault operations

Commvault module uses CVPySDK to perform operations

All agents supported by CVPySDK are supported by commvault ansible module

CVPySDK, in turn, uses Commvault REST API to perform operations on a Commcell via WebConsole.

Requirements

  • Ansible
  • Python 3 or above
  • CVPySDK
  • Commvault Software v11 SP16 or later release with WebConsole installed

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

Installing Ansible

Using Ansible commvault module

Login to Commcell:

---
- name: Commvault Ansible
  gather_facts: no
  hosts: localhost
  connection: local

  vars:
  webconsole_hostname: 'webconsole_hostname'
  commcell_username: 'commcell_username'
  commcell_password: 'commcell_password'

  tasks:
    - name: Login
      commvault:
          operation: login
          entity: {
          webconsole_hostname: "{{ webconsole_hostname }}",
          commcell_username: "{{ commcell_username }}",
          commcell_password: "{{ commcell_password }}"
          }
      register: commcell

Force HTTPS login using self-signed certificate

- name: Login
  commvault:
      operation: login
      entity: {
      webconsole_hostname: "{{ webconsole_hostname }}",
      commcell_username: "{{ commcell_username }}",
      commcell_password: "{{ commcell_password }}",
      force_https: True,
      certificate_path: '/tmp/certificates'
      }
  register: commcell

Run backup for a subclient:

- name: Backup
  commvault:
          operation: "backup"
          entity_type: subclient
          commcell: "{{ commcell }}"
          entity: {
          client: "client name",
          agent: "file system",
          backupset: "defaultbackupset",
          subclient: "default"
          }
  register: backup_job

Run restore in place job for a subclient:

- name: Restore
  commvault:
       operation: "restore_in_place"
       entity_type: subclient
       commcell: "{{ commcell }}"
       entity: {
       client: "client name",
       agent: "file system",
       backupset: "defaultbackupset",
       subclient: "default"
       }
       args: {
       paths: ['path']
       }
  register: restore_job

Wait for the restore job to complete:

- name: wait for restore job to complete
  commvault:
      operation: "wait_for_completion"
      entity_type: "job"
      commcell: "{{ commcell }}"
      entity: {
      job_id: "{{ restore_job.output }}"
      }
  register: restore_status

Get storage pool properties:

- name: "get storage pool properties"
  commvault:
      operation: "storage_pool_properties"
      entity_type: storagepool
      commcell: "{{ commcell }}"
      entity: {
      "storage_pool": "dedicated cl2"
      }
  register: storage_pool_props

Explanation:

operation corresponds to a method name in CVPySDK modules, example "restore_in_place" method is in subclient.py module

entity_type corresponds to baisc CVPySDK class, available options are

  • Commcell
  • Clients
  • Client
  • Clientgroups
  • Clientgroup
  • Agents
  • Agent
  • Instances
  • Instance
  • Backupsets
  • Backupset
  • Subclients
  • Subclient
  • Job
  • MediaAgents
  • MediaAgent
  • StoragePools
  • StoragePool
  • DiskLibraries
  • DiskLibrary

commcell is mandatory to perform any tasks, when performing login operation commcell is registered and can later be used in other tasks

entity will contain basic CVPySDK inputs, available options are

  • client
  • clientgroup
  • agent
  • instance
  • backupset
  • subclient
  • job_id
  • media_agent
  • storage_pool
  • disk_library

args contains the arguments to be passed to the method

Contribution Guidelines

  1. We welcome all the enhancements from everyone although we request the developer to follow some guidelines while interacting with the Ansible commvault module codebase.
  2. Before adding any enhancements/bug-fixes, we request you to open an Issue first.
  3. The core team will go over the Issue and notify if it is required or already been worked on.
  4. If the Issue is approved, the contributor can then make the changes to their fork and open a pull request.

Coding Considerations

  • All python code should be PEP8 compliant.
  • All changes should be consistent with the design of the SDK.
  • The code should be formatted using autopep8 with line-length set to 119 instead of default 79.
  • All changes and any new methods/classes should be properly documented.
  • The docstrings should be of the same format as existing docs.

Questions/Comments/Suggestions

If you have any questions or comments, please contact us here. Also Check out our community for Automation incase of queries.

Code of Conduct

Everyone interacting in the Ansible commvault module project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the PyPA Code of Conduct.

License

CVPySDK and Commvault ansible module are licensed under Apache 2.0

About Commvault

https://commvault.github.io/cvpysdk/logo.png


Commvault (NASDAQ: CVLT) is a publicly-traded data protection and information management software company headquartered in Tinton Falls, New Jersey.

It was formed in 1988 as a development group in Bell Labs, and later became a business unit of AT&T Network Systems. It was incorporated in 1996.

Commvault software assists organizations with data backup and recovery, cloud and infrastructure management, and retention and compliance.

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages