How to Install Ansible | How to Setup Master & Worker Server

How to Install Ansible | How to Setup Master & Worker Server

Ansible

Ansible is an open-source automation tool used for configuration management, application deployment, and task automation. It is widely used due to its simplicity, flexibility, and power.

Ease of Use

  • Agentless: Unlike other tools like Puppet or Chef, Ansible does not require any agent installation on managed nodes. It uses SSH for communication, simplifying management.
  • Simple Configuration: Uses YAML for writing playbooks, which is easy to read and understand, even for non-programmers
  • Minimal Dependencies: Ansible requires only Python installed on the target machine.

Use Cases for Ansible

  • Server Provisioning: Automating the setup of servers.
  • Application Deployment: Deploying and managing software across systems.
  • Configuration Management: Ensuring systems stay in the desired state.
  • Continuous Delivery (CD): Automating workflows in CI/CD pipelines.
  • Orchestration: Managing complex workflows and interdependent systems.

2 Create Instance

Create 3 Instance

Launch Instance & Use This command first

  • sudo apt-add-repository ppa:ansible/ansible

Enter to add Repo in my system list

  • Update System

  • Sudo apt install ansible

  • Check Ansible version ansible --version

  • Jump at Host files : sudo nano /etc/ansible/hosts

Image 1
Image 2

  • Add This commands on host file I have use only one instance currently you can use 2 Server

  • Now copy SSH key from local to EC2 Instance :

scp -i ansible_masters.pem ansible_masters.pem
[servers]

server1 ansible_host= Instance IP Here

server2 ansible_host= Instance IP Here

#all is keywork which is show's all server or group sab ke sab

[all:vars]

ansible_python_insterpreter=/usr/bin/python3

ansible_ssh_private_key=/home/ubuntu/keys/ansible_masters.pem

[server1:vars]

ansible_user=ubuntu

[server2:vars]

ansible_user=ec2-user

Modules Meaning : Value already set

When you facing any error on line number then you can use this commands

After the save hosts file need to run this command : ansible-inventory --list

Now ping your both servers after changes on hosts file : ansible servers - m ping

Troubleshoot Permission Error on Master Server : keys/ ansible_master.pem
if facing same error need to change ownership
changing ownership
sudo chown root ansible_masters.pem

add file on : ansible_ssh_private_key_file=/home - - - -

save & run command ansible servers -m ping
now error is different need to troubleshoot again : ping command reached at servers
sudo chown $USER keys/ansible_masters.pem
Now its running after the change owner Main issue
both server is connected now check how mush space we have : ansible servers -a "free -h"
Server Uptime
Now we can 4 server till we see the name of redhat or then upload that key file to the master server through scp and then use that key in the ansible file and ping both server
Now Update both server from the master server
Install Nginx Server on server 1 from the master server : ansible server1 -a "sudo apt-get install nginx -y"
Check on
Update Second Server & Install Nginx Server
Install Nginx Server : sudo yum install -y nginx
Now install
Server 1 Docker Status logs

This is all for the basic configuration. In the next post we will discussed about the playbook, what is the playbook or how we create it, what is its configuration etc.

#AnsibleAutomation #ServerManagement #CloudComputing #InfrastructureAsCode #DevOpsPractices


Anurag Prakash

AWS and Azure Cloud | AWS Certified Solutions Architect | DevOps Expert | Kubernetes | CI/CD | Terraform | Ansible | Azure DevOps | Python | EKS, AKS, OpenShift | EU Blue Card Holder

2 个月

Wow nice!!

Tanmay Modh

Software Engineer | Temenos TripleA Plus | WealthSuite | DevOps & Cloud Enthusiast

2 个月

Well done Burhan ????!

Shoaib Ansari

Cloud Engineer | Network Engineer | IT Support | Oracle & Google Cloud | DevOps Learner

2 个月

Gazab ??. Keep it up Burhan ????

Md. Afzal Hassan Ehsani

Bridging Development and Operations | Passionate About Scaling & Orchestrating Production Applications with DevOps

2 个月

Well done Burhan ???? ??

Shubham Londhe

Helping Students and Professionals build their Careers | Experience in DevOps | Python | AWS | PySpark | SQL | NoSQL | 1000+ Learners placed

2 个月

Ye hui naa baaat

要查看或添加评论,请登录

Burhan ?????的更多文章