Here below are the Ansible Roles for installing Java, Jenkins, Maven on Ubuntu EC2 instance using Ansible. You need to installJava first (first link below) and then do the steps in the second link for installing Jenkins, third link for installing Maven.
Click here if you would like to create a new Ubuntu EC2 instance using Ansible Playbook.
You can watch this lab on YouTube:
Pre-requisites: Setup Ansible on your EC2 instance.
We will learn how to create Ansible Role for provisioning a new EC2 instance in AWS cloud. We will pick a playbook which has all the logic and we will refactor into reusable ansible role.
What is Ansible Role?
Ansible also lets you organize tasks in a directory structure called a Role. Using Ansible roles you can break down complex playbooks into smaller and manageable chunks. Ansible role enables reuse and share our Ansible code efficiently.
How to create Ansible Role?
Using ansible galaxy command, we can create Ansible role. This will create the below directory with all the files.
directory structure of Ansible role
aws-infra-role/
├── README.md
├── create.yml
├── defaults
│ └── main.yml
├── handlers
│ └── main.yml
├── meta
│ └── main.yml
├── tasks
│ ├── create-ec2.yml
│ └── create-sg.yml
├── tests
│ ├── inventory
│ └── test.yml
└── vars
└── main.yml
Directory structure explained
tasks - contains the main list of tasks to be executed by the role. handlers - handlers are typically used to start, reload, restart, and stop services. defaults - default variables for the role. vars - other variables for the role. Vars has the higher priority than defaults. meta - defines some data / information about this role (author, dependency, versions, examples, etc,.)
Ansible is #1 configuration management tool. It can also be used for infrastructureprovisioning as well. or You can use Ansible in combination of Terraform which can take care of infra automation and Ansible can do configuration management. We will be setting up Ansible on Red Hat VM in Azure cloud And create some resources in AWS Cloud by using Ansible playbooks.
Ansible Architecture:
The best way to install Ansible in Linux is to use PIP, a package manager for Python.
Pre-requisites:
Create new Red Hat EC2 in AWS Cloud for setting up Ansible, just open port 22 in firewall rule.
How to setup Ansible on Red Hat Linux VM?
Watch Steps in YouTube channel:
Change host name to AnsibleMgmtNode sudo hostnamectl set-hostname AnsibleMgmtNode
Ansible is an open-source, configuration management tool that automates cloud provisioning, configuration management, and application deployments. Using Ansible you can provision virtual machines, containers, network, and complete cloud infrastructures.
Automate Azure cloud infrastructure setup using Ansible and Azure pipeline
Integrate Ansible with Azure Cloud
Integrating Ansible with Microsoft Azure allows you to automate and manage your Azure infrastructure using Ansible playbooks and modules. Ansible provides a collection of Azure-specific modules that enable you to provision and configure resources in Azure.
To configure Azure credentials, you need the following information:
Your Azure subscription ID and tenant ID
The service principal application ID and secret
Pre-requisites:
Azure account subscription, click here if you don't have one.
Service principal to create any resources in Azure cloud using Azure cloud shell or Azure CLI
Create Azure Service Principal
Run the following commands to create an Azure Service Principal:
az ad sp create-for-rbac --name <service-principal-name> \
--role Contributor \
--scopes /subscriptions/<subscription_id>
Save the above output in a file as you will not be able retrieve later.
Create an Ansible playbook
Create a simple playbook to create resource group in Azure. Make sure you modify the name of the resource group and location below.
How to setup Ansible on Red Hat Linux VM and Integrate with Azure Cloud?
Ansible is #1 configuration management tool. It can also be used for infrastructureprovisioning as well. or You can use Ansible in combination of Terraform which can take care of infra automation and Ansible can do configuration management. We will be setting up Ansible on Red Hat VM in Azure cloud And create some resources in Azure Cloud by using Ansible playbooks.
Ansible Architecture:
The best way to install Ansible in Linux is to use PIP, a package manager for Python.
In this section, you create a local credentials file to provide credentials to Ansible. For security reasons, credential files should only be used in development environments.
mkdir ~/.azure
vi ~/.azure/credentials
Insert the following lines into the file. Replace the placeholders with the service principal values.