Developer purple banner

Get Started with the Cohesity Ansible Module!

Chandrashekar Dashudi Headshot

By Chandrashekar Dashudu • April 24, 2020

Ansible is a simple yet powerful tool to automate complex multi tier IT application environments. It provides solutions to a wide variety of automation challenges. All the rich features that Ansible provides makes it one of the top 10 open source projects on GitHub.

Cohesity’s Integrations team has realized the potential of having a Cohesity Ansible module and has already published a Cohesity Module on Ansible Galaxy with a 5/5 score. We are constantly adding new features in our Ansible module to support all popular workflows. The number of downloads for our role on Galaxy is increasing, which shows that many customers who use Ansible are also using this resource. The Integrations team wrote the Ansible module using the Cohesity Python SDK they published earlier. Using the Cohesity Python SDK for our Ansible roles gives us more confidence in our SDKs.

To help the users of our Ansible module, we have produced detailed documentation for our Developer Portal under Ansible Integration. The documentation also includes sample code and workflows to get started with the Ansible module.

Cohesity welcomes and encourages any contribution from our partners and developers. You can contribute the form of bug fixes, new-feature requests, fixes, and suggestions for our documentation, including new sample workflows. Read the Hello Cohesity Developers! blog to learn more about the contribution process and resources.

Sample Workflow

Let’s go through an example here using the Cohesity Ansible module to get started. In this example, we will perform Cohesity agent installation on a bunch of physical linux servers. Imagine you have hundreds of servers which are to be protected using Cohesity Dataplatform. You can use a single playbook to install the agent on all the servers at once saving a lot of time.

This below steps assumes that you have already installed Ansible on the host from where you will run the playbook. 

Step 1: Install the Cohesity Ansible module from Ansible Galaxy

ansible-galaxy install cohesity.cohesity_ansible_role

Step 2: Create an Inventory File  

You can add more servers depending on your requirements.

# cat inventory
[centos] # Enter your IP here # Enter your IP here


We see here that we have two  Linux servers and we have provided the private key location for ansible to login and install the agent.

Step 3: Create the playbook install-agent.yml

# cat install-agent.yml
  - hosts: centos
    # => Please change these variables to connect
    # => to your Cohesity Cluster
        var_cohesity_server: YOUR_CLUSTER_IP_OR_FQDN
        var_cohesity_admin: USER_NAME
        var_cohesity_password: PASSWORD
        var_validate_certs: False
    become: true
        - cohesity.cohesity_ansible_role
      - name: Install new Cohesity Agent on each Physical Linux Server
            name: cohesity.cohesity_ansible_role
            tasks_from: agent
            cohesity_server: "{{ var_cohesity_server }}"
            cohesity_admin: "{{ var_cohesity_admin }}"
            cohesity_password: "{{ var_cohesity_password }}"
            cohesity_validate_certs: "{{ var_validate_certs }}"
                state: present

For more examples and different options, see the Developer Portal.

Step 4: Run the Playbook

In our example, running this playbook installs the agent on the specified server.

# ansible-playbook install-agent.yml -i inventory

PLAY [centos] ************************************************************************************************************************************************

TASK [Gathering Facts] ***************************************************************************************************************************************
ok: []
ok: []


PLAY RECAP ***************************************************************************************************************************************************               : ok=5    changed=3    unreachable=0    failed=0    skipped=3    rescued=0    ignored=0               : ok=5    changed=3    unreachable=0    failed=0    skipped=3    rescued=0    ignored=0 

For a video demo that takes you through the full workflow of physical server protection and recovery, see the video below.


Our Cohesity Ansible roles are becoming popular and more and more of our customers are using them. They help automate various other Cohesity workflows, which saves a lot of time. The good thing about having a playbook for a workflow is it’s easy to share. If you have a workflow to share, reach out to us here!

To explore more features that are enabled by the Cohesity Ansible module, visit the documentation on the Developer Portal. In an upcoming blog soon, we will go over the VMware protection workflow using the Cohesity Ansible module.