Posts

Showing posts with the label ansible

How to make your ansible inventory ?

Image
 Ansible is capable of working with one host or multiple hosts at the same time. But for multiple hosts its required to create a group of hosts. A file can be created to define a host or a group of hosts known as inventory. The default location of inventory is a file called ' /etc/ansible/hosts '. But you can create the inventory file with any name and can call it using -i <path-to-inventory-file> while running the playbooks. Ansible inventory file can be created using YAML or INI format. INI is the most common format and have better control while working with large number of groups. More information are available in inventory  documentation. If there is a need to assign some specific variable or some common variable to a group of hosts, it can be easily done using inventory file. Let's discus this using an example. Let say you need to deploy 2 linux vms in vSphere platform and you have the following folder structure to keep your playbooks in terms of ansible roles, ...

Ansible role based deployment for windows guest along with os customization, WinRM and AD integration

Image
 In enterprise level, just deploying the windows vm is always not enough. The vm need to connect AD to support enterprise logins and many guest os level changes needed like configuring DNS, NTP, adding multiple hard disks, applying the disk labels etc. Using ansible modules these steps can be done easily. Its always a good practice to write role based ansible playbooks and using tags so that when needed a specific role can be called using its respective tag. In this example we will perform the below tasks using ansible roles: VM Deployment Guest OS customization Windows Updates Software Upload Software Installation VM Deletion Lets go through the following example to understand how these requirements can be achieved: Each role consists of multiple tasks in it which will be performed sequentially. These roles will use specific ansible modules which are part of ansible collections . Under roles folder we have subfolders for each role which will have atleast 2 folders in it. task...

VMware OVA deployment using ansible

To deploy OVA on VMware platform using ansible a provision server is required from where ansible playbooks need to be executed. Follow the steps as mentioned in  how to build ansible provision server for VMware  and make the provision server ready. With the help of vmware_deploy_ovf  module ansible can deploy VMware OVA. Let say the requirement is to deploy the OVA in a vm folder and under a resource pool in hosts view, then it should go through the following check points: Create vm folder and resource pool if not present OVA should be available in the provision server Before deploying the OVA, extract the OVA and check the custom section of .ovf file to see what all variable need to pass in the playbook at the time of deployment. We will create three yml files to keep: vmware ova deployment code ( vsphere_ova_deploy.yml ) vmware environment login details ( vsphere_creds.yml ) variables used for the guest deployment ( vsphere_var.yml ) In m...

VMware guest deployment using Ansible

To deploy VMware guest using ansible a provision server is required from where ansible playbooks need to be executed. Follow the steps as mentioned in  how to build ansible provision server for VMware  and make the provision server ready. We will create three yml files to keep: vmware guest deployment code ( vsphere_guest_deploy.yml ) vmware environment login details ( vsphere_creds.yml ) variables used for the guest deployment ( vsphere_var.yml ) This vsphere_guest_deploy.yml playbook will perform the following tasks: Make sure to have a template in the vCenter Server VM need to be deployed in a dedicated vm folder and resource pool VM folder and resource pool will be created if not available For this deployment an application user is needed in vCenter which should have required privilege to perform all the above tasks.  Content of vCenter credentials yml file: Content of vCenter variable file: Content of vmware guest d...

How to build Ansible provision server for VMware ?

Ansible is a great automation tool for infrastructure as a code and using ansible modules to automate VMware platform is really easy. In order to start the automation, need to configure a provision server where ansible and some of its dependencies need to be installed. A provision server can be on any operating system. But in this document we have focused on the following two opensource operating systems: Ubuntu 20.04 LTS CentOS 8.x  Following steps need to be performed to configure Ubuntu 20.04 LTS as a provision server: a. Install python3-pip:     # apt-get  install  python3-pip  -y    Upgrade pip3 to the latest version:   # pip3  install  --upgrade  pip b. Install & check latest ansible  version:       # pip3 install ansible   # pip3 show ansible      c.  Install & check  pyVmomi :       # pip3 install pyvmomi ...

VNC Configuration using Ansible in CentOS 6

Image
1. Install epel repo on CentOS 6 system:     # yum install epel-release  -y 2. Install ansible using yum:     # yum install ansible  -y 3. Go to the '/etc/ansible/roles' directory and run the below command to create the required directory structure:     # ansible-galaxy  init  vnc6  --offline        - vnc6 was created successfully   # tree vnc6        vnc6     ├── defaults     │   └── main.yml     ├── files     ├── handlers     │   └── main.yml     ├── meta     │   └── main.yml     ├── README.md     ├── tasks     │   └── main.yml     ├── tests     │   ├── inventory     │   └── test.yml     └── vars         └── main.yml     4....

OpenStack instance deployment using Ansible

This document will help to deploy the Openstack  instances using Ansible. 1. Follow the steps and configure CentOS 7 based ansible  provisioning server for OpenStack. 2. Create  'rdo' directory under '/opt' directory:        # mkdir  /opt/rdo 3. Create 'img-upload.yaml' under '/opt/rdo' directory and add the below content: --- - name: Image Upload activity   hosts: localhost   tasks:   - name: Download cirros image     get_url:       url: http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img       dest: /tmp/cirros-0.3.4-x86_64-disk.img   - name: Upload cirros image to openstack     os_image:       name: Ansible_Demo       container_format: bare       disk_format: qcow2       state: present  ...