Enabling cloud automation through an infrastructure-as-code approach is of great importance to organizations adopting DevOps practices. Environment provisioning and updates should not become a bottleneck or introduce more risk when meeting the fast-growing demands of a line-of-business application. The ease of use and repeatability of Infrastructure as Code helps to bridge this gap.
There are multiple options to enable infrastructure-as-code automation of NetApp® Cloud Volumes ONTAP and NetApp Cloud Manager, allowing this approach to form the central piece of the storage management strategy for any organization. This blog will show you step by step how to automate Cloud Volumes ONTAP and Cloud Manager deployment using Terraform and Ansible.
Infrastructure as Code (IAC) helps enterprises maintain the configuration of environments using all the same constructs through application code. IAC creates definitions of environments using a descriptive model; this can be considered the source code of your infrastructure, and you can use that source code to create environments with the same configuration every time you need it deployed. Any changes to the target environment are achieved by updating this source code in the DevOps pipeline. IAC fits into the DevOps paradigm of continuous delivery which implements a lean process for building, testing, configuring, and deploying environments.
The concept of IAC stretches beyond just automating infrastructure deployment. Along with automation, it brings the following benefits to the table:
Now let's see how to perform infrastructure as code Ansible and Terraform deployments.
When implementing Infrastructure as code, Ansible and Terraform are two popular tools used by DevOps team. NetApp Cloud Manager and Cloud Volumes ONTAP deployment and configuration can be easily automated using these Terraform and Ansible. In this section we’ll show you how to do that, starting with the prerequisites and deployment options.
Note that for this demo, Terraform is being installed using an Ubuntu machine.
Also note that our demonstration takes place using AWS, however the process could be carried out using a deployment in Azure just as easily.
To deploy Cloud Manager and Cloud Volumes ONTAP using terraform and Ansible, the following prerequisites need to be completed:
1. Download the appropriate version of Terraform for your operating system from https://www.terraform.io/downloads.html.
2. Download the file using the wget command
#wget
https://releases.hashicorp.com/terraform/0.12.6/terraform_0.12.6_linux_amd64.zip
# unzip ./terraform_0.12.6_linux_amd64.zip /usr/local/bin/
4. Verify the installation by running the terraform command:
The following steps will show you how to install Ansible.
1. Start by installing Ansible with the following commands:# sudo apt update
# sudo apt install software-properties-common
# sudo apt-add-repository --yes --update ppa:ansible/ansible
#sudo apt install ansible
2. Next, we need to install boto and botocore. Boto is a Python interface required for AWS.Install boto3 and botocore using the following commands:
$ sudo apt install python-pip
$ pip install boto3
$ pip install botocore
3. Import boto to Python using the following commands:$ python
$ import boto
Now, you’ll need to configure your connection to AWS through the AWS Command Line Interface (AWS CLI).
1. Install the AWS CLI:# apt-get install awscli
2. Confirm that the AWS CLI is installed:
3. Configure AWS CLI using the following command. You will be prompted to enter the AWS Access key ID and your secret access key.
[terraform]
aws_access_key_id = <AWS access key id>
aws_secret_access_key = <AWS secret access key>
https://services.cloud.netapp.com/refresh-token
2. Click on “Generate Refresh Token” for cloud manager API:
3. Click on “Copy to clipboard” to copy the refresh token. Save the token by pasting it in a text editor as this token will be used later in the Terraform configuration.
This entire process can be seen demonstrated in the video in this post.
The deployment process of Cloud Manager using Terraform is illustrated in the following diagram:
In this section we will cover the configuration files required for deploying Cloud Manager in AWS using Terraform and walk you through all the deployment steps involved.
Note: The same process can be followed for deployment of Cloud Manager in Azure also. The configuration files and deployment process for that cloud are explained here: https://github.com/edarzi/cloud-manager-automation-samples/tree/master/terraform/azure
Download and edit the following Terraform and Ansible files as explained below for deploying Cloud Manager using Terraform and Ansible.
Main.tf: Available here. This is the main configuration file for Terraform and can be used with the following changes:
Outputs.tf : Available here. This file specifies the output of deployment. It can be used as is without any changes.
terraform.tfvars: Available here. The Terraform variable file should be updated with environment specific values as listed below:
Cloud Manager_setup.yaml: Available here. Download the file to the same location as the Terraform files and update the path of the file in the variable ansible_provision_file.
#terraform init
A. This command will download and install the Terraform AWS plugin:
#terraform plan
#terraform apply
This command will apply the changes and create the deployment. Type ”Yes” when prompted if you want to apply the Terraform plan, as shown below:
3. Once the Terraform deployment is completed successfully, you will get the Cloud Manager ID and IP as output:
4. You can also view the Cloud Manager deployed in AWS console:
5. You can connect to the deployed Cloud Manager from http://cloud.netapp.com. Go from Cloud Central-> Fabric view-> View Cloud Managers.
In this section we will cover the configuration files required for deploying Cloud Manager in AWS using Ansible and walk you through the deployment steps involved.
ansible-playbook createCloud Manager.yml --extra-vars "AWSAccessKey=[access key] AWSSecretKey=[secret Key] region=us-west-2 instancename=Cloud ManagerTest IAMRole='' refToken=[refresh token string] portalUserName=[portal user mail]"
2. Replace values of the variable as follows:3. Once this information has been entered, you will be able to see the Cloud Manager instance being provisioned in the AWS console.
4. Once deployed, you can connect to the deployed cloud manager from Cloud Central-> Fabric view->View cloud managers.
In this section we will cover the configuration files required for deploying a single node Cloud Volumes ONTAP in AWS using Ansible and give you step-by-step instructions for all the deployment steps involved.
Start by downloading these required config files:
createCloud Volumes ONTAP.yml: Update the following values in the yaml file:
Cloud Volumes ONTAP_single.j2: Available here. Download the file to ../templates/ folder in the local machine, corresponding to the location from which the Ansible command will be executed. This is the template file for configuring Cloud Volumes ONTAP properties such as the export policy, tiering policy, snapshot policy, etc.
Run the following Ansible command to deploy Cloud Volumes ONTAP:
ansible-playbook createCloud Volumes ONTAP.yml --extra-vars "Cloud ManagerIp=[Cloud Manager IP] refToken=[refresh token string]"
Replace values of the variable as follows:
You should now have a fully functional Cloud Volumes ONTAP deployment up and running thanks to using infrastructure as code.
To make you IAC deployment possible both Cloud Volumes ONTAP and Cloud Manager are completely API driven. Cloud Volumes ONTAP offers enterprise class data management features in the cloud over NAS and SAN protocols (NFS, SMB /CIFS, and iSCSI) of your choice. In addition to providing efficient storage solutions for enterprise applications and databases, it is the go-to solution for other use cases including data migration to cloud, Disaster Recovery (DR), Backup and Archive.
Cloud Volumes ONTAP is highly geared towards automating cloud operations. Cloud Volumes ONTAP and Cloud Manager deployment through infrastructure- as- code automation helps to address the DevOps challenges faced by organizations when it comes to configuring enterprise cloud storage solutions. As demonstrated in this blog, when implementing infrastructure as code, Ansible and Terraform go hand in hand to achieve the level of efficiency expected in large scale cloud storage deployment in both Azure and AWS.