Ansible is an opensource IT configuration management, deployment and orchestration tool. It aims to provide large productivity gains to a wide variety of automation challenges.
Ansible History:
Michael Dehaan developed ansible and the ansible project began in February 2012.
Redhat acquired the ansible tool in 2015.
Ansible is available for RHEL, Debian, cent OS and oracle Linux.
We can use this tool whether your servers are in on-premises or in cloud.
It turns your code into infrastructure i.e. your computing environment has some of the same attributes as your application.
Advantages:
Ansible is free to use by everyone.
Ansible is very consistent and light weight and no constrains regarding the OS or
underlying hardware are present.
It is very secure due to its agentless capabilities and open SSH security features.
Ansible doesn't need any special system administrator skills to install and use it.
It is push mechanism.
Disadvantages:
Insufficient user interface, though ansible tower is GUI, but it is still in development stage.
Cannot achieve full automation by ansible.
New to the market, therefore limited support and document is available.
Terms used in Ansible:
Ansible Server: the machine where ansible is installed and from which all tasks and Playbooks will be run.
Module: basically, a module is a command or set of similar commands meant to be executed
on the client side.
Task: a task is section that consist of a single procedure to be completed.
Role: a way of organizing tasks and related files to be later called playbook.
Fact: information fetched from the client form the global variables with the gather facts
operation.
Inventory: file containing data about the ansible client servers.
Play: execution of playbook.
Handler: task which is called only if notifier is present.
Notifier: section attributed to a task which calls a handler if the output is changed.
Playbooks: it consists code in YAML format which describes tasks to be executed.
Host: nodes which are automated by ansible.
Installation:
Fallow link you can install based on the distribution you can install using below link
root@ip-172-31-23-165:/home/ubuntu# ansible all -m ping
localhost | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
root@ip-172-31-23-165:/home/ubuntu# ansible all -a "mkdir a" -b
localhost | CHANGED | rc=0 >>
root@ip-172-31-23-165:/home/ubuntu# ansible all -a "ls -ltr " -b
localhost | CHANGED | rc=0 >>
total 16
-rw-r--r-- 1 root root 0 Nov 17 06:33 ansible.cfg
-rw-r--r-- 1 root root 36 Nov 17 06:35 hosts
-rwxr-xr-x 1 ubuntu ubuntu 587 Nov 17 10:47 docker.sh
drwxr-xr-x 5 root root 4096 Nov 17 11:35 MyResumeDocker
drwxr-xr-x 2 root root 4096 Nov 17 12:41 a
Ansible Modules:
Ansible ships with a number of modules (called module library) that can be executed
directly on remote hosts or through "playbooks".
Your library of modules can reside on any machine and there are no servers, daemons or
databases required.
Q. where ansible modules are stored?
The default location of the inventory file is /etc/ansible/hosts.
Below module used to check ansible slave status while pinging
Playbooks in ansible are written in YAML format.
It is human readable data serialization language and is commonly used for configuration files.
Playbook is like a file where you write codes consists of variables, tasks, handlers, files, templates and roles.
Each playbook is composed of one or more 'modules' in a list. Module is a collections of configuration files.
Playbooks are divided into many sectors like
a. Target section: defines the host against which playbooks task has to be executed.
b. Variable: define variables
c. Task section: list of modules that we need to run in an order.
YAML (Yet Another Markup Language):
For ansible nearly every YAML files starts with a list.
Each item in the list is a list of key-value pairs commonly called as a directory.
All YAML files have to begins with "---" and ends with ".
All members ofa list lines must begin with same indentation level starting with -
For e.g:
--- # a list of fruits
Fruits: Mango Strawberry Banana Grapes Apple
sample playbook that will install nginx and visuvalise resume
tasks:
- name: installation apache2
apt: pkg=apache2 state=present
- name: version check
apt: pkg=apache2 state=latest
- name: clone the git directory
ansible.builtin.command: git clone https://github.com/GudditiNaganjaneyulu/MyResume.git
- name: copy files to workdir
copy: src=/root/ansible/MyResume/ dest='{{workdir}}'
- name: remove Html code after copying
ansible.builtin.command: rm -rf /root/ansible/MyResume/
notify: service starting
- name: service starting
service: name=apache2 state=restarted
Variables:
Ansible uses variables which are defined previously to enable more flexibility in playbooks
and roles. They can be used to loop through a set of given values, access various information like the host name of a system and replace certain strings in templates with specific values.
Put variable section above tasks so that we define it first and use it later.
A handler is exactly the same as a task, but it will run when called by another task.
Or
Handlers are just like regular tasks in an ansible playbook, but are only run if the task contains a 'notify' directive and also indicates that it changed something.
Check whether the playbook is formatted correctly or not.
Anible-playbook handlers.yml --check
Loops:
Sometimes you want to repeat a task multiple time. In computer programming this is called as loops.
Common ansible loops include changing ownership on several files and/or directories with the file module, creating multiple users with the user module and repeating a polling step until certain result is reached.
---
- hosts: all
#user: root
become: yes
gather_facts: yes
connection: ssh
tasks:
- name: creation of users
- user: name=“{{item}}” state=present
with item:
- mini
- sana
- ravi
Conditions:
Whenever we have different different scenarios, we put conditions to the scenario. We put conditions in ansible by "when" statement.
---
- hosts: all
become: yes
gather_facts: yes
connection: ssh
tasks:
- name: install nginx if family is debian
command: apt install nginx -y
when: ansible_os_family == "Debian"
name: install nginx if family is Redhat
command: yum install nginx -y
when: ansible_os_family == "Redhat"
Vault:
Ansible allows keeping sensitive data such as passwords or key in encrypted files, rather that a plaintext in your playbooks.
PLAY [all] *********************************************************************************************************************************************
PLAY RECAP *********************************************************************************************************************************************
List of companies provide remote opportunities NAME WEBSITE REGION &yet andyet.com Worldwide 10up 10up.com Worldwide 15Five 15five.com Europe, Americas 17hats 17hats.com Worldwide 18F 18f.gsa.gov USA 1Password 1password.com North America, UK 42 Technologies 42technologies.com Worldwide abiturma abiturma.de Germany Ably ably.io Europe Abstract API abstractapi.com Worldwide acct acct.global Worldwide Acivilate acivilate.com USA Acquia acquia.com Worldwide ActiveCampaign activecampaign.com Dublin, Ireland; USA Ad Hoc adhocteam.us USA Adaface adaface.com Asia AddStructure bazaarvoice.com USA Adzuna adzuna.co.uk Worldwide AE Studio ae.studio USA, BR Aerolab aerolab.co Latin America AgFlow agflow.com Europe Aha! aha.io Worldwide Aim India aimincorp.com India Airbyte airbyte.com Europe, North America, Latin America AirGarage airgarage.com USA AirTreks airtreks.com USA Aivitex aivitex.de Germany Algorand algorand.com USA Algorithmia algorithmia.com the USA or Canada ALICE aliceplatfor...
Are you curious about the magic behind those seamless web applications and services you use daily? Well, let's take a peek into the fascinating world of microservices and the tools that make them work like a charm: Istio, Kiali, Jaeger, Grafana, and Prometheus. These tools might sound a bit technical, but fear not! We're here to break it down in the simplest way possible. 1. Istio: The Traffic Director Istio is an open source service mesh that layers transparently onto existing distributed applications. Istio’s powerful features provide a uniform and more efficient way to secure, connect, and monitor services. Istio is the path to load balancing, service-to-service authentication, and monitoring – with few or no service code changes. The control plane takes your desired configuration, and its view of the services, and dynamically programs the proxy servers, updating them as the rules or the environment changes. Before utilizing Istio After utilizing Istio Imagine you're m...
T ask 1: Create a toolchain Open the creation page for the Develop a Cloud Foundry app toolchain by clicking Create toolchain: You can also select the Develop a Cloud Foundry app toolchain from the Toolchain templates list . Tip: For instructions to navigate to the toolchain templates and select a toolchain to create, see Navigating to the toolchain templates . On the creation page, review the diagram of the toolchain that you are about to create. Review the default information for the toolchain settings. The toolchain's name identifies it in IBM Cloud. Note: The URL to access your application must be unique. By default, the toolchain's name is used in constructing that URL. Make sure that the toolchain's name is unique within IBM Cloud. Each toolchain is associated with a specific region and resource group. Use the menus on the page to select the region and resource group where you want the toolchain created. You can have up to 200 toolchains per resource group. If you w...
Comments
Post a Comment