Search This Blog

Tuesday 19 November 2019

Ansible Basics Learning

Ansible tools:
ansible-tower   its UI based managing ansible playbooks
ansible- playbook  runs ansible playbook ,executing the defined tasks on targeted hosts
ansible -pull   to pull playbooks from repos and execute
ansible-inventory  used to display or dump the configured inventory as Ansible sees it
ansible-doc  it is documentation tool
ansible-galaxy    command to manage Ansible roles in shared repositories
ansible-console  console for executing ahoc commands
ansible-config     to  view ansible configuration
ansible-vault   encryption/decryption utility for Ansible data files




m   module name
all  it search for local host first not found check at deafault under /etc/andible/hosts
--extra-vars   to pass varaible from outside playbook
-i  pass custom   inventory file create inside playbook
-l   pass the group or hostname to be executed from inverntory file or hosts file
-v or -vvv or -vvvv   verbosity to view logs in debugging mode
--private-key   to pass ssh key
-u User name
-a to execute any ycommand on nodes
--check    to perform dryrun before execute
-- help

default host path:      etc/ansible/hosts
default config path:  /etc/ansible/ansible.cfg


--gather facts     gethering information from remote systems before connecting to remote system
- name  to describe the task going to perform
- hosts: host name/group  you want to connect
-connection    types of connection  local,netconf
- tasks:    block to write task to be performed
-loop:  to loop through task below
-vars:   define list  of values in varaible


Modules:

Service  module   - to check status of service on  remote node (name,state,enable)
raw Module:    to  execute  linux command on  remote node ( ls -l )
fail : print message if fails
when :  check error is foudn in previous result and print fail message
redhat subscription module :   to perform redhat subscription on rhel.
uri module -- to call apis










It is opensource automation tool
It is used to automate IT infrastruvcture
It is used to configure Networdk devices and deploy software on remote devices

Advantages:
It is easy to use and deploy
It is agent less
simple syntax written in YAML called Playbooks
It is powerfull and flexible

Ansible terms:

Controller Machine: The machine where Ansible is installed, responsible for running the provisioning on the servers you are managing.
Inventory: An initialization file that contains information about the servers you are managing.
Playbook: The entry point for Ansible provisioning, where the automation is defined through tasks using YAML format.
Task: A block that defines a single procedure to be executed, e.g. Install a package.

Module: A module typically abstracts a system task, like dealing with packages or creating and changing files. Ansible has a multitude of built-in modules, but you can also create custom ones.
Role: A pre-defined way for organizing playbooks and other files in order to facilitate sharing and reusing portions of a provisioning.
Play: A provisioning executed from start to finish is called a play. In simple words, execution of a playbook is called a play.
Facts: Global variables containing information about the system, like network interfaces or operating system.
Handlers: Used to trigger service status changes, like restarting or stopping a service.

No comments:

Post a Comment

REST API

  API  is an application programming interface. It is a set of rules that allow programs to talk to each other. The developer creates the AP...