Ansible
Last updated
Was this helpful?
Last updated
Was this helpful?
Blogs:
Open-source tool for automation and configuration management
Agentless: Uses SSH or WinRM for communication
YAML-based playbooks for defining configurations
Idempotent: Applies changes without unintended side effects
Modular: Offers built-in modules for various tasks
Roles: Organizes tasks for better reuse and collaboration
Strong community support and extensive documentation
Terminology
Control Node: The system running Ansible, typically on Linux/Unix
Managed Nodes: Target systems controlled by Ansible, requiring SSH and Python (2.6+/3.5+). Supports various OS types, including Windows
Inventory: A file listing managed hosts. Can be static (.ini) or dynamic (JSON output) for project-specific management
Tasks: Units of work executed on managed nodes, either ad-hoc or within playbooks
Playbook: An ordered list of tasks specifying target hosts and execution details, written in YAML
Handlers: Special tasks for managing services, triggered by other tasks and run after all tasks are completed
Roles: Structured collections of playbooks and files for reusable automation packages, streamlining specific deployments
Generate ansible.cfg
file
Even if you do not define any groups in your inventory file, Ansible creates two default groups: all
and ungrouped
. The all
group contains every host. The ungrouped
group contains all hosts that donβt have another group aside from all
.
Semaphore is a powerful open-source tool for managing Ansible tasks through a web-based interface. This guide demonstrates how to install Semaphore on an Ubuntu Desktop VM using Snap (β) and configure it for SSH-based Ansible playbooks.
β As per Semaphore docs Snap install is deprecated (but still works).
I need to do some testing to integrate Package manager and/or Docker installation documentation.
Install via DockerNot tested
Follow the steps outlined in the official Semaphore documentation for Docker-based deployment. Use the container configurator to get the ideal Docker configuration for Semaphore.
Here is a summary for convenience to deploy via docker with data persistence:
Log In
Access Semaphore at http://localhost:3000
Use the admin credentials set during the setup process
Keystore Configuration
Add the SSH keys + passphrases for secure connections
Repository Configuration
Link the Git repository using SSH credentials
e.g. - git@github.com:syselement/ansibletest.git
Environment
Set up an empty environment
Static Inventory Configuration
Define an inventory file with host and group details
e.g.
Task templates in Semaphore point to Ansible playbooks stored in the repository. Hereβs how to set them up:
Organize the repository
Structure the repository to store playbooks logically.
e.g.
Create a template in Semaphore
Add a new Task Template in Semaphore
e.g.
Name - AptUpdateUbuntu
Playbook Path - Relative path to the playbook - ansible/playbooks/updatelinux.yaml