Wednesday, October 7, 2020

Copy a text file from your machine to Remote Host Using Ansible playbook

 Step1: create your own inventory file in any folder i have created a folder name inventory in which i have created a file name cpIn.ini(inventory file for host)

$ cat cpIn.ini

[host-group]

localhost

in cpIn.ini i have created a host group in which i have taken localhost as a host

Step2: write playbook copy_playbook.yml
 ---
 - hosts: host-group
   become: yes
   become_user: host machine name(changing permission from rad to write(from localhost to destination host))
   tasks:
     - name: copy file to remote host
       copy:
         src: /source/file/destination/path
         dest: /host/machine/destination/path

step 3 write command

$ ansible-playbook copy_playbook.yml -i inventory/inv.ini(inventory file destination)


Wednesday, September 16, 2020

Ansible_Basics_01

 Ansible's Features and Capabilities


Configuration Management

Ansible is designed to be very simple reliable, and consistent for configuration management. Ansible Configuration are simple data description of infrastructure and are both  readable by humans ans parse-able by machine. All you need to start managing system is a password or an SSH(Secure Socket Shell, a network protocol )key. 

An example of how easy Ansible makes configuration management: if you want to install an updated version of a specific type of software on all the machines in your enterprise, all you have to do is write out all the IP addresses of the nodes (also called remote hosts) and write an Ansible playbook to install it on all the nodes, then run the playbook from your control machine.,

Application Deployment

Ansible lets you quickly and easily deploy multi-tier apps. You won’t need to write custom code to automate your systems; you list the tasks required to be done by writing a playbook, and Ansible will figure out how to get your systems to the state you want them to be in. In other words, you won’t have to configure the applications on every machine manually. When you run a playbook from your control machine, Ansible uses SSH to communicate with the remote hosts and run all the commands (tasks).

Orchestration

As the name suggests, orchestration involves bringing different elements into a beautifully run whole operation—similar to the way a musical conductor brings the notes produced by all the different instruments into a cohesive artistic work. For example, with application deployment, you need to manage not just the front-end and backend services but the databases, networks, storage, and so on. You also need to make sure that all the tasks are handled in the proper order. Ansible uses automated workflows, provisioning, and more to make orchestrating tasks easy. And once you’ve defined your infrastructure using the Ansible playbooks, you can use that same orchestration wherever you need to, thanks to the portability of Ansible playbooks.

Security and Compliance

As with application deployment, site wide security policies (such as firewall rules or locking down users) can be implemented along with other automated processes. If you configure the security details on the control machine and run the associated playbook, all the remote hosts will automatically be updated with those details. That means you won’t need to monitor each machine for security compliance continually manually. And for extra security, an admin’s user ID and password aren’t retrievable in plain text on Ansible.

Cloud Provisioning

The first step in automating your applications’ life cycle is automating the provisioning of your infrastructure. With Ansible, you can provision cloud platforms, virtualized hosts, network devices, and bare-metal servers.



Ansible Architecture 



Inventory

Inventory is lists of nodes or hosts having their IP addresses, databases, servers, etc. which are need to be managed.

API's

The Ansible API's works as the transport for the public or private cloud services.

Modules

Ansible connected the nodes and spread out the Ansible modules programs. Ansible executes the modules and removed after finished. These modules can reside on any machine; no database or servers are required here. You can work with the chose text editor or a terminal or version control system to keep track of the changes in the content.

Plugins

Plugins is a piece of code that expends the core functionality of Ansible. There are many useful plugins, and you also can write your own.

Playbooks

Playbooks consist of your written code, and they are written in YAML format, which describes the tasks and executes through the Ansible. Also, you can launch the tasks synchronously and asynchronously with playbooks.

Hosts

In the Ansible architecture, hosts are the node systems, which are automated by Ansible, and any machine such as RedHat, Linux, Windows, etc.

Networking

Ansible is used to automate different networks, and it uses the simple, secure, and powerful agentless automation framework for IT operations and development. It uses a type of data model which separated from the Ansible automation engine that spans the different hardware quite easily.

Cloud

A cloud is a network of remote servers on which you can store, manage, and process the data. These servers are hosted on the internet and storing the data remotely rather than the local server. It just launches the resources and instances on the cloud, connect them to the servers, and you have good knowledge of operating your tasks remotely.

CMDB

CMDB is a type of repository which acts as a data warehouse for the IT installations.




                                                                                                                                        Reshma Mohane
                                                                                     

Ansible_Basics_00

Ansible


Problem Before Ansible :- 
                                                             suppose you have 100 server and you wants to install 2 packages suppose package A and package B to all those 100 server so what will you do 

1. log in to the server
2. check package A and package B already installed or not
3. if not then install using two command
           yum install A -y
           yum install B -y

this process take 6 mint of time on one server so since we have 100 server so it will take 600 mint it will become an very hug time taking process.

Solution 1:- This solution is the next problem for ansible
 suppose you are good at shell script so 
1. you will write a shell script program to install both the packages to the server
2. you will again write the shell script program to apply previous written shell program to all the 100 server
this process take 3 mint for each server we have 100 server so it is taking 300 mint fore all the server so we have reduces the half of the time but even its taking so much time   

Solution by Ansible:- 

To overcome this type of situation of for performing this type of configuration task in less time we use configuration management tool like ansible puppet and so on. 
                                                                                                                what ansible will do ansible will install both the packages in all the system parallel since it was taking 3 mint for 1 server so if we have 100 server and we are writing playbook so it will take only 3 mint to install both the packages into all the server.  

What is Ansible ?

Ansible is an open source(you can download it without buying any license) automation tool.
its very simple to setup and very powerful
Ansible is helpful to do 
  • Configuration management
  • Task Automation
  • IT orchestration
  • Cloud provisioning
  • Application Deployment
More Definition :- 

Ansible - Ansible is a software tool that provides simple but powerful automation ( Automation is the creation and application of technology to monitor and control the production and delivery of products and services with minimal human intervention.  ) for cross platform computer support. it is primarily intended for it professionals, who use it for application deployment( Software deployment includes all of the steps, processes, and activities that are required to make a software system or update available to its intended users. update on workstation and server, cloud provisioningCloud provisioning is the allocation of a cloud provider's resources and services to a customer), Configuration Management ( Configuration management is a process for maintaining computer systems, servers, and software in a desired, consistent state. It's a way to make sure that a system performs as it's expected to as changes are made over time.) intra-service orchestration Application or service orchestration is the process of integrating two or more applications and/or services together to automate a process, or  synchronize data in real-time. Often, point-to-point integration may be used as the path of least resistance. and nearly anything a  system administrator does on weekly or daily basis. Ansible doesn't depends on agent software and has no additional security infrastructure, so its easy to deploy.  




Copy a text file from your machine to Remote Host Using Ansible playbook

 Step1: create your own inventory file in any folder i have created a folder name inventory in which i have created a file name cpIn.ini(inv...