Skip to content

MBaranekTech/Ansible

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Ansible Automation

Ansible
Automate your infrastructure and deployments with Ansible playbooks.

πŸ“– What is Ansible?

Ansible is an open-source automation tool that allows you to configure servers, deploy applications, and manage IT environments using simple, human-readable YAML files called playbooks. It’s agentless and connects via SSH, making it ideal for managing Linux and cloud infrastructure.


ansible_example

Key features:

Agentless and SSH-based
Uses YAML for configuration (playbooks)
Automates provisioning, configuration, deployment, and orchestration
Supports Linux, macOS, Windows, cloud (AWS, Azure, GCP), Docker, Kubernetes

Example:

Install and configure Nginx, Docker, databases
Deploy apps (Node.js, Django, PHP, etc.)
Manage users, firewalls, cron jobs
Provision servers on AWS/GCP/Azure

πŸ›  Requirements

Python 3
Ansible control node
SSH access to remote hosts
Sudo privileges on remote hosts

πŸ“ Project Structure

β”œβ”€β”€ inventory.ini # Inventory of remote hosts
β”œβ”€β”€ nginx.yml # Example playbook to install Nginx
└── README.md # This file

πŸ“Œ SSH KEYs

Step 1: Generate SSH Key on Ansible node

ssh-keygen -t rsa -b 4096 
Press Enter to accept defaults (save in ~/.ssh/id_rsa)

Step 2: Copy Public Key to Remote Host

ssh-copy-id MBaranekTech@192.168.1.10
ssh-copy-id MBaranekTech@192.168.1.11

Step 3: Set Correct Permissions

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Step 4: Test Passwordless SSH

ssh MBaranekTech@192.168.1.10
ssh MBaranekTech@192.168.1.11

πŸ“š Test host connectivity

ansible all -i inventory.ini -m ping

πŸš€ Example Playbook: Install Nginx

- name: Install and start Nginx
  hosts: client
  become: true
  tasks:
    - name: Install Nginx
      apt:
        name: nginx
        state: present

    - name: Start and enable Nginx
      service:
        name: nginx
        state: started
        enabled: true

πŸ“‘ Inventory Example (inventory.ini)

[client]
192.168.1.10 ansible_user=MBaranekTech ansible_ssh_private_key_file=~/.ssh/id_rsa
192.168.1.11 ansible_user=MBaranekTech ansible_ssh_private_key_file=~/.ssh/id_rsa

πŸ§ͺ How to Run a Playbook

ansible-playbook -i inventory.ini nginx-playbook.yml --ask-become-pass

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published