Apr 24, 2020|3 min|Developers

Get Started with the Cohesity Ansible Module!

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]
10.2.159.242 # Enter your IP here
10.2.159.183 # Enter your IP here

[centos:vars]
ansible_user=root
ansible_ssh_private_key_file=/PATH/TO/SSH/KEYS

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
    vars:
        var_cohesity_server: YOUR_CLUSTER_IP_OR_FQDN
        var_cohesity_admin: USER_NAME
        var_cohesity_password: PASSWORD
        var_validate_certs: False
    become: true
    roles:
        - cohesity.cohesity_ansible_role
    tasks:
      - name: Install new Cohesity Agent on each Physical Linux Server
        include_role:
            name: cohesity.cohesity_ansible_role
            tasks_from: agent
         vars:
            cohesity_server: "{{ var_cohesity_server }}"
            cohesity_admin: "{{ var_cohesity_admin }}"
            cohesity_password: "{{ var_cohesity_password }}"
            cohesity_validate_certs: "{{ var_validate_certs }}"
            cohesity_agent:
                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: [10.2.159.242]
ok: [10.2.159.183]

<<>

PLAY RECAP ***************************************************************************************************************************************************
10.2.159.183               : ok=5    changed=3    unreachable=0    failed=0    skipped=3    rescued=0    ignored=0   
10.2.159.242               : 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.

Wrap-up

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. 

 

Written by

chandrashekar-dashudi-headshot

Chandrashekar Dashudu

Technical Marketing Engineer

chandrashekar-dashudi-headshot

Chandrashekar Dashudu

Technical Marketing Engineer

Chandrashekar is a TME who serves as an SME for Cohesity's API and API integration. Apart for API, he focuses on Cohesity Marketplace apps. He is an engineering background in Computer Science from NCSU.

X image
Icon ionic ios-globe

You are now leaving the German section of www.cohesity.com/de/ and come to an English section of the site. Please click if you want to continue.

Don't show this warning again

Icon ionic ios-globe

You are now leaving the German section of www.cohesity.com/de/ and come to an English section of the site. Please click if you want to continue.

Don't show this warning again