-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PUBLISHER] Publish from Obsidian #7
* PUSH NOTE : Linux.md * PUSH NOTE : Secure Shell.md * PUSH NOTE : 01 Ansible Architecture.md * PUSH NOTE : Ansible.md * PUSH NOTE : Ansible Semaphore.md
- Loading branch information
1 parent
4927c9a
commit f58eb35
Showing
4 changed files
with
1,130 additions
and
125 deletions.
There are no files selected for viewing
214 changes: 107 additions & 107 deletions
214
content/Expeditions/Ansible/Learning Ansible/01 Ansible Architecture.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,112 @@ | ||
--- | ||
title: 01 Ansible Architecture | ||
title: Ansible Architecture | ||
description: | ||
tags: | ||
publish: true | ||
--- | ||
|
||
Ansible follows a client-server architecture, but it's important to note that Ansible is agentless, meaning it doesn't require any software agents to be installed on the nodes managed by ansible. | ||
|
||
## Send Nodes | ||
|
||
There are two types of nodes in ansible | ||
1. **Control Node** | ||
- The control node is where Ansible is installed and from where automation tasks are managed. | ||
- This can be a personal computer, a dedicated server running on premises or even a cloud machine running with a cloud service provider. | ||
- The control node contains the code essential to manage the remote machines. | ||
2. **Managed Node** | ||
- Managed nodes are the systems or devices that Ansible manages. | ||
- They can be servers, virtual machines, networking devices, cloud instances, or any other infrastructure component that can be SSH'ed into and python can be installed. | ||
- Ansible communicates with managed nodes over SSH (for Linux/Unix) or PowerShell Remoting (for Windows). | ||
- There is no persistent agent running on managed nodes; Ansible connects to them temporarily to execute tasks and then disconnects. | ||
|
||
## Managing the Machines | ||
|
||
Managed Nodes in ansible are governed with the help of the `inventory file`. An inventory file is usually written in the `INI` or `YAML` syntax, however formats like `JSON` is also supported. | ||
|
||
The file is generally named `hosts` (just hosts without extension) and is usually found at `/etc/ansible/hosts` on a Unix/Linux file system. Custom inventory files can be passed to ansible by using `-i` or `--inventory` flag. Generally inventory files group the nodes managed into logical groups on the basis of functionality, environment, location or role | ||
|
||
Ansible also takes in per-host variables in the inventory file. This allows to manage hosts with varied configuration. | ||
|
||
Ansible supports dynamic inventories generated by external scripts or plugins. Dynamic inventories fetch host information from sources such as cloud providers, virtualization platforms, or external databases, allowing dynamic scaling and management of infrastructure. | ||
|
||
```ini | ||
# Inventory file for Ansible | ||
|
||
# Grouping hosts into categories | ||
[web_servers] | ||
web1 ansible_host=192.168.1.101 ansible_user=admin ansible_ssh_private_key=~/.ssh/id_rsa | ||
|
||
[db_servers] | ||
db1 ansible_host=192.168.1.102 ansible_user=admin ansible_ssh_private_key=~/.ssh/id_rsa | ||
db2 ansible_host=192.168.1.103 ansible_user=admin ansible_ssh_private_key=~/.ssh/id_rsa | ||
|
||
# Grouping hosts by attributes | ||
[linux_servers] | ||
web1 | ||
db1 | ||
db2 | ||
|
||
[windows_servers] | ||
win1 ansible_host=192.168.1.104 ansible_user=administrator ansible_password=Pa$$w0rd! | ||
win2 ansible_host=192.168.1.105 ansible_user=administrator ansible_password=Pa$$w0rd! | ||
``` | ||
|
||
```yaml | ||
# Inventory file for Ansible | ||
|
||
# All hosts definition | ||
all: | ||
hosts: | ||
|
||
# Linux Servers | ||
web1: | ||
ansible_host: 192.168.1.101 | ||
ansible_user: admin | ||
ansible_ssh_private_key: ~/.ssh/id_rsa | ||
db1: | ||
ansible_host: 192.168.1.102 | ||
ansible_user: admin | ||
ansible_ssh_private_key: ~/.ssh/id_rsa | ||
db2: | ||
ansible_host: 192.168.1.103 | ||
ansible_user: admin | ||
ansible_ssh_private_key: ~/.ssh/id_rsa | ||
|
||
# Windows Servers | ||
win1: | ||
ansible_host: 192.168.1.104 | ||
ansible_user: administrator | ||
ansible_password: Pa$$w0rd! | ||
win2: | ||
ansible_host: 192.168.1.105 | ||
ansible_user: administrator | ||
ansible_password: Pa$$w0rd! | ||
|
||
# Children Section - Grouping of hosts | ||
children: | ||
|
||
# Grouping of Web Servers | ||
web_servers: | ||
hosts: | ||
web1: | ||
|
||
# Grouping of Database Servers | ||
db_servers: | ||
hosts: | ||
db1: | ||
db2: | ||
|
||
# Grouping of Linux Servers | ||
linux_servers: | ||
hosts: | ||
web1: | ||
db1: | ||
db2: | ||
|
||
# Grouping of Windows Servers | ||
windows_servers: | ||
hosts: | ||
win1: | ||
win2: | ||
``` | ||
|
||
Ansible follows a client-server architecture, but it's important to note that Ansible is agentless, meaning it doesn't require any software agents to be installed on the nodes managed by ansible. | ||
|
||
## Send Nodes | ||
|
||
There are two types of nodes in ansible | ||
1. **Control Node** | ||
- The control node is where Ansible is installed and from where automation tasks are managed. | ||
- This can be a personal computer, a dedicated server running on premises or even a cloud machine running with a cloud service provider. | ||
- The control node contains the code essential to manage the remote machines. | ||
2. **Managed Node** | ||
- Managed nodes are the systems or devices that Ansible manages. | ||
- They can be servers, virtual machines, networking devices, cloud instances, or any other infrastructure component that can be SSH'ed into and python can be installed. | ||
- Ansible communicates with managed nodes over SSH (for Linux/Unix) or PowerShell Remoting (for Windows). | ||
- There is no persistent agent running on managed nodes; Ansible connects to them temporarily to execute tasks and then disconnects. | ||
|
||
## Managing the Machines | ||
|
||
Managed Nodes in ansible are governed with the help of the `inventory file`. An inventory file is usually written in the `INI` or `YAML` syntax, however formats like `JSON` is also supported. | ||
|
||
The file is generally named `hosts` (just hosts without extension) and is usually found at `/etc/ansible/hosts` on a Unix/Linux file system. Custom inventory files can be passed to ansible by using `-i` or `--inventory` flag. Generally inventory files group the nodes managed into logical groups on the basis of functionality, environment, location or role | ||
|
||
Ansible also takes in per-host variables in the inventory file. This allows to manage hosts with varied configuration. | ||
|
||
Ansible supports dynamic inventories generated by external scripts or plugins. Dynamic inventories fetch host information from sources such as cloud providers, virtualization platforms, or external databases, allowing dynamic scaling and management of infrastructure. | ||
|
||
```ini | ||
# Inventory file for Ansible | ||
|
||
# Grouping hosts into categories | ||
[web_servers] | ||
web1 ansible_host=192.168.1.101 ansible_user=admin ansible_ssh_private_key=~/.ssh/id_rsa | ||
|
||
[db_servers] | ||
db1 ansible_host=192.168.1.102 ansible_user=admin ansible_ssh_private_key=~/.ssh/id_rsa | ||
db2 ansible_host=192.168.1.103 ansible_user=admin ansible_ssh_private_key=~/.ssh/id_rsa | ||
|
||
# Grouping hosts by attributes | ||
[linux_servers] | ||
web1 | ||
db1 | ||
db2 | ||
|
||
[windows_servers] | ||
win1 ansible_host=192.168.1.104 ansible_user=administrator ansible_password=Pa$$w0rd! | ||
win2 ansible_host=192.168.1.105 ansible_user=administrator ansible_password=Pa$$w0rd! | ||
``` | ||
|
||
```yaml | ||
# Inventory file for Ansible | ||
|
||
# All hosts definition | ||
all: | ||
hosts: | ||
|
||
# Linux Servers | ||
web1: | ||
ansible_host: 192.168.1.101 | ||
ansible_user: admin | ||
ansible_ssh_private_key: ~/.ssh/id_rsa | ||
db1: | ||
ansible_host: 192.168.1.102 | ||
ansible_user: admin | ||
ansible_ssh_private_key: ~/.ssh/id_rsa | ||
db2: | ||
ansible_host: 192.168.1.103 | ||
ansible_user: admin | ||
ansible_ssh_private_key: ~/.ssh/id_rsa | ||
|
||
# Windows Servers | ||
win1: | ||
ansible_host: 192.168.1.104 | ||
ansible_user: administrator | ||
ansible_password: Pa$$w0rd! | ||
win2: | ||
ansible_host: 192.168.1.105 | ||
ansible_user: administrator | ||
ansible_password: Pa$$w0rd! | ||
|
||
# Children Section - Grouping of hosts | ||
children: | ||
|
||
# Grouping of Web Servers | ||
web_servers: | ||
hosts: | ||
web1: | ||
|
||
# Grouping of Database Servers | ||
db_servers: | ||
hosts: | ||
db1: | ||
db2: | ||
|
||
# Grouping of Linux Servers | ||
linux_servers: | ||
hosts: | ||
web1: | ||
db1: | ||
db2: | ||
|
||
# Grouping of Windows Servers | ||
windows_servers: | ||
hosts: | ||
win1: | ||
win2: | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.