Please enable JavaScript.
Coggle requires JavaScript to display documents.
Phase 01 - Ansible Fundamentals (Enterprise Linux) - Coggle Diagram
Phase 01 - Ansible Fundamentals (Enterprise Linux)
Ansible
Definition
Open-source IT automation tool
Agentless automation platform
Uses SSH for communication
Push-based automation
Written in Python
Developed by Red Hat
Used for Configuration Management
Used for Application Deployment
Used for Patch Management
Used for OS Provisioning
Used for Security Hardening
Used for Compliance Management
Used for Infrastructure as Code (IaC)
Used for Cloud Automation
Used for Container Automation
Used for Network Automation
Used for Orchestration
Used for Disaster Recovery
Used for Daily Administration Tasks
Enterprise Use Cases
Centralized Linux Administration
Centralized Patch Management
User Management
Package Installation
Service Management
Configuration File Management
Software Deployment
Security Baseline Enforcement
Log Collection
Scheduled Maintenance
Server Provisioning
Database Administration
Web Server Administration
Middleware Deployment
Kubernetes Automation
VMware Automation
AWS Automation
Azure Automation
Backup Automation
Compliance Auditing
Advantages
Agentless
Simple YAML Syntax
SSH Based
Idempotent Execution
Easy Learning Curve
Highly Scalable
Secure
Modular
Cross Platform
Open Source
Enterprise Supported
Installation
Supported Operating Systems
Red Hat Enterprise Linux
Rocky Linux
AlmaLinux
CentOS Stream
Ubuntu Server
Debian
SUSE Linux Enterprise
Controller Requirements
Python Installed
OpenSSH Client
SSH Key Pair
Internet Repository Access
Sudo Privileges
Install on RHEL
sudo dnf install ansible-core
Install on Ubuntu
sudo apt update
sudo apt install ansible
Verify Installation
ansible --version
which ansible
ansible-config dump
Important Binary Locations
/usr/bin/ansible
/usr/bin/ansible-playbook
/usr/bin/ansible-config
/usr/bin/ansible-doc
/usr/bin/ansible-galaxy
/usr/bin/ansible-vault
/usr/bin/ansible-inventory
/usr/bin/ansible-console
/usr/bin/ansible-pull
Python Packages
python3
python3-pip
python3-jinja2
python3-yaml
Architecture
Overview
Push Architecture
Agentless Architecture
SSH Based Communication
One Controller Multiple Managed Nodes
Control Node
Definition
Machine where Ansible is installed
Responsibilities
Executes Playbooks
Stores Inventory
Stores Roles
Stores Variables
Stores Templates
Stores SSH Keys
Connects to Remote Systems
Enterprise Example
ansible-controller.example.com
Managed Nodes
Definition
Remote Linux Servers Managed by Ansible
Requirements
SSH Server Running
Python Installed
Reachable over Network
Valid User Account
Sudo Access if Required
Enterprise Examples
Web Servers
Database Servers
Application Servers
DNS Servers
Load Balancers
Monitoring Servers
SSH Communication
Default Port
22
Authentication
Password Authentication
SSH Key Authentication
Enterprise Best Practice
SSH Keys
Disable Root Login
Use Dedicated Automation User
Generate SSH Key
ssh-keygen
Copy SSH Key
ssh-copy-id
user@server
Test SSH
ssh
user@server
SSH Configuration File
~/.ssh/config
Known Hosts File
~/.ssh/known_hosts
Private Key
~/.ssh/id_rsa
Public Key
~/.ssh/id_rsa.pub
Python Requirement
Why Python
Modules execute through Python
Verify Python
python3 --version
Locate Python
which python3
Common Path
/usr/bin/python3
Inventory
Definition
List of Managed Hosts
Inventory Types
Static Inventory
Dynamic Inventory
Inventory Location
/etc/ansible/hosts
inventory/hosts.ini
Inventory Formats
INI
YAML
Example Host
web01 ansible_host=192.168.1.10
Host Parameters
ansible_host
ansible_user
ansible_port
ansible_connection
ansible_python_interpreter
ansible_ssh_private_key_file
ansible_become
Groups
Definition
Collection of Hosts
Enterprise Groups
webservers
dbservers
appservers
monitoring
backup
development
testing
production
loadbalancer
Nested Groups
Definition
Group inside another Group
Example
linux_servers
webservers
dbservers
appservers
group_vars
Purpose
Variables Shared by Entire Group
Location
group_vars/
Example Files
all.yml
webservers.yml
dbservers.yml
production.yml
host_vars
Purpose
Variables for Individual Host
Location
host_vars/
Example Files
web01.yml
db01.yml
app01.yml
Configuration
ansible.cfg
Definition
Main Configuration File
Search Order
ANSIBLE_CONFIG Environment Variable
./ansible.cfg
~/.ansible.cfg
/etc/ansible/ansible.cfg
Important Parameters
inventory
remote_user
private_key_file
host_key_checking
forks
timeout
log_path
roles_path
collections_paths
retry_files_enabled
gathering
become
become_method
become_user
inventory
Specifies Inventory File Path
remote_user
Default SSH User
private_key_file
Default SSH Private Key
host_key_checking
Verify SSH Fingerprint
forks
Number of Parallel Connections
timeout
SSH Timeout
log_path
Log File Path
roles_path
Default Role Directory
become
Enable Privilege Escalation
become_method
sudo
su
become_user
root
Enterprise Directory Structure
ansible/
ansible.cfg
inventory/
hosts.ini
group_vars/
host_vars/
playbooks/
roles/
templates/
files/
collections/
logs/
scripts/
Ad-hoc Commands
Definition
One-time Commands Executed Without Playbooks
General Syntax
ansible HOST_PATTERN MODULE OPTIONS
Host Pattern
all
webservers
dbservers
appservers
production
development
web01
Common Modules
ping
command
shell
copy
file
fetch
yum
dnf
apt
package
service
systemd
user
group
setup
stat
reboot
hostname
lineinfile
replace
Enterprise Examples
ansible all -m ping
ansible webservers -m command -a "hostname"
ansible all -m shell -a "uptime"
ansible all -m copy -a "src=test.txt dest=/tmp/test.txt"
ansible all -m yum -a "name=httpd state=present"
ansible all -m dnf -a "name=httpd state=present"
ansible all -m apt -a "name=apache2 state=present"
ansible all -m package -a "name=httpd state=present"
ansible all -m service -a "name=httpd state=started"
ansible all -m systemd -a "name=sshd state=restarted"
ansible all -m user -a "name=testuser state=present"
ansible all -m group -a "name=developers state=present"
ansible all -m setup
ansible all -m reboot
ansible all -m file -a "path=/data state=directory mode=0755"
ansible all -m fetch -a "src=/etc/hosts dest=backup/"
ansible all -m stat -a "path=/etc/passwd"
Enterprise Security
SSH Keys Only
Disable Password Authentication
Disable Root SSH Login
Dedicated Automation User
Sudo Principle of Least Privilege
Ansible Vault
Inventory Protection
Playbook Version Control
Audit Logs
RBAC with AWX or Automation Controller
Troubleshooting
ansible --version
ansible-config dump
ansible-inventory --list
ansible all -m ping
ansible all -m setup
ansible all -m ping -vvv
ssh
user@server
systemctl status sshd
journalctl -u sshd
which ansible
which python3
Important Enterprise Paths
/etc/ansible/
/etc/ansible/hosts
/etc/ansible/ansible.cfg
~/.ansible.cfg
~/.ssh/
~/.ssh/id_rsa
~/.ssh/id_rsa.pub
~/.ssh/known_hosts
/usr/bin/ansible
/usr/bin/ansible-playbook
/usr/bin/ansible-config
/usr/bin/ansible-doc
/usr/bin/ansible-galaxy
/usr/bin/ansible-vault
/usr/bin/ansible-inventory
/var/log/ansible.log
Enterprise Best Practices
Use Git for Version Control
Store Inventories Separately
Separate Development Testing Production
Use Group Variables
Use Host Variables Sparingly
Use SSH Keys
Never Store Passwords in Plain Text
Use Ansible Vault for Secrets
Keep Playbooks Idempotent
Use Roles for Reusability
Test in Development Before Production
Enable Logging
Document Every Inventory and Playbook