50 SECTIONS · 1449 TOPICS
Ansible Roadmap
Installing and Configuring Ansible
- 1. Installing Ansible
- Example: Install Ansible using pip
- 2. Verifying Installation
- Example: Check Ansible version
- 3. Understanding ansible.cfg
- Example: Basic ansible.cfg
- 4. Configuring Default Settings
- Example: Setting Default User in ansible.cfg
- 5. Setting Up SSH Keys
- Example: SSH Key Setup Script
- 6. Configuring SSH Connection
- Example: SSH Configuration in Inventory
- 7. Disabling Host Key Checking
- Example: Disabling host key checking in ansible.cfg
- 8. Setting Default Inventory
- Example: Default Inventory File (hosts.ini)
- Example: YAML Inventory File (hosts.yaml)
- 9. Configuring Log Path
- Example: Setting Log Path in ansible.cfg
- 10. Understanding Configuration Precedence
Understanding Ansible Core Concepts
- 1. Understanding Control Node
- Example: Basic Inventory File
- Example: Simple Playbook
- 2. Understanding Managed Nodes
- Example: Inventory configuration for managed nodes
- 3. Understanding Modules
- Example: Using the copy module to deploy a config file
- Example: Using the shell module to run a command
- 4. Understanding Plugins
- Example: Using a Custom Filter Plugin
- Example: Using the Filter in a Playbook
- 5. Understanding Collections
- Example: Using a Collection in a Playbook
- Key Features of Collections
- 6. Understanding Inventory
- Example: Basic Inventory File
- Example: Using Groups
- Inventory Types
- 7. Understanding Playbooks
- Example: Basic Playbook Structure
- 8. Understanding Tasks
- Example: Creating a Directory
- Example: Conditional Task Execution
- Example: Looping Over a List
- 9. Understanding Handlers
- Example: Restarting a Service
- 10. Understanding Facts
- Example: Using Facts in a Playbook
- 11. Understanding Push vs Pull
- Push vs Pull Comparison
- 12. Understanding Idempotency
- Example: Idempotent Package Installation
Managing Inventory Files
- 1. Creating Static Inventory
- Example: Using Static Inventory
- 2. Creating YAML Inventory
- Example: Basic YAML Inventory
- Example: Inventory with Variables
- 3. Defining Hosts and Groups
- Example: Basic Inventory File
- Example: Group Inheritance
- 4. Using Inventory Patterns
- Example: Using host patterns in a playbook
- 5. Creating Child Groups
- Example: Defining child groups
- 6. Listing Inventory Hosts
- Example: List all hosts in inventory
- Example: Show variables for a specific host
- Example: Show variables for a specific group
- 7. Graphing Inventory
- Example: Visualizing inventory with graphviz
- Graphing Inventory Summary
- 8. Verifying Inventory
- Example: Basic inventory verification
- 9. Using Multiple Inventory Sources
- Example: Combining Static and Dynamic Inventory
- Static vs Dynamic Inventory
- 10. Organizing Inventory Directory Structure
- Example: Standard Inventory Directory Layout
- Best Practices for Inventory Organization
Working with Host and Group Variables
- 1. Defining Host Variables
- Example: Setting Host Variables in Inventory
- Example: Using Host Variables in Playbook
- 2. Defining Group Variables
- Example: Defining Group Variables in YAML
- Example: Defining Group Variables in JSON
- 3. Setting Connection Variables
- Example: Setting SSH connection variables for a group
- Example: Using become with a different user
- 4. Using Behavioral Parameters
- Example: Setting behavioral parameters in inventory
- Example: Using behavioral parameters in group vars
- 5. Setting Privilege Escalation
- Example: Using become with sudo
- 6. Understanding Variable Precedence
- Example: Variable Precedence in Playbook
- 7. Using all and ungrouped Groups
- Example: Defining variables for all hosts
- Example: Defining variables for ungrouped hosts
- 8. Setting Group Priority
- Example: Setting Group Priority in Inventory
- 9. Merging Variables
- Example: Merging Host and Group Variables
- 10. Organizing Variable Files
- Example: Directory Structure for Variables
- Best Practices
Working with Dynamic Inventory
- 1. Understanding Dynamic Inventory
- Example: Dynamic Inventory Script
- Key Benefits of Dynamic Inventory
- 2. Using AWS EC2 Plugin
- Example: Basic AWS EC2 Inventory Configuration
- Example: Using AWS EC2 with Custom Tags
- 3. Using Azure Plugin
- Example: Basic Azure Inventory Configuration
- Example: Using Environment Variables for Authentication
- 4. Using GCP Plugin
- Example: GCP Inventory Configuration
- 5. Configuring Inventory Plugins
- Example: Using the AWS EC2 Inventory Plugin
- Example: Using the Azure Inventory Plugin
- 6. Setting Plugin Options
- Example: Configuring AWS EC2 Plugin with Filters
- 7. Caching Inventory Data
- Example: Configure caching in
- 8. Creating Custom Inventory Scripts
- Example: Simple Custom Inventory Script (Python)
- Key Points
- 9. Using Constructed Inventory
- Example: Constructed Inventory Configuration
- 10. Testing Dynamic Inventory
- Example: Test dynamic inventory script
Running Ad-Hoc Commands
- 1. Executing Ad-Hoc Commands
- Example: Ping all hosts
- Example: List files in /tmp
- 2. Using Module Arguments
- Example: Running a shell command with arguments
- Example: Using copy module with arguments
- 3. Specifying Module
- Example: Running a command with shell module
- Example: Targeting Multiple Groups
- Example: Excluding Hosts
- 5. Setting Parallelism
- Example: Running tasks with limited parallelism
- 6. Checking Connectivity
- 7. Running Shell Commands
- Example: Running a shell command
- Example: Running a shell command with arguments
- 8. Copying Files
- Example: Copying a File
- Example: Copying a Directory
- 9. Gathering Facts
- Example: Gathering Facts with Ad-Hoc Command
- Example: Limiting Facts Collection
- 10. Managing Packages
- Example: Install a package with apt
- Example: Install a package with yum
- Example: Install a package with dnf
- Example: Install a package with pacman
- 11. Managing Services
- Example: Start and Enable a Service
- Example: Stop and Disable a Service
- 12. Using Privilege Escalation
- Example: Running a command with privilege escalation
Creating Ansible Playbooks
- 1. Understanding Playbook Structure
- Example: Basic Playbook Structure
- 2. Defining Plays
- Example: Basic Play Definition
- 3. Specifying Target Hosts
- Example: Hosts and Groups
- Example: Using Inventory File
- 4. Setting Remote User
- Example: Setting remote user for a task
- Example: Using become to switch user
- 5. Enabling Privilege Escalation
- Example: Using become to run as root
- 6. Configuring Become Method
- Example: Using become with sudo
- 7. Defining Tasks
- Example: Installing a Package
- Example: Conditional Task Execution
- Example: Looping Over a List
- 8. Setting Gather Facts
- Example: Disabling Fact Gathering
- 9. Using Proper YAML Syntax
- Example: Basic Playbook Structure
- 10. Validating Playbook Syntax
- Example: Basic syntax check
Working with Tasks
- 1. Defining Task Structure
- Example: Basic Task Definition
- Example: Task with Loop and Condition
- 2. Using Module Arguments
- Example: Using
- Example: Using
- Example: Using
- 3. Setting Task State
- 4. Registering Task Results
- Example: Registering a command result
- Example: Registering a file lookup result
- 5. Adding Task Conditions
- Example: Using when with multiple conditions
- 6. Controlling Task Execution
- Example: Using when to conditionally execute a task
- Example: Using loop to iterate over a list
- Example: Using until to retry a task
- 7. Ignoring Errors
- Example: Using ignore_errors
- 8. Delegating Tasks
- Example: Delegating a task to a different host
- Example: Delegating task and storing facts
- 9. Running Tasks Once
- Example: Using run_once
- Example: Using delegate_to
- 10. Setting Task Environment
- Example: Setting Environment Variables
- Example: Using vars to Set Variables
- 11. Adding Task Tags
- Example: Applying Tags to a Task
- Example: Running Specific Tags
- 12. Using Task Timeout
- Example: Setting a Task Timeout
Working with Variables
- 1. Defining Playbook Variables
- Example: Defining Variables in a Playbook
- 2. Using Variable Files
- Example: vars.yml content
- Example: Using vars file in playbook
- 3. Setting Host Variables
- Example: Setting Host Variables in Inventory
- 4. Setting Group Variables
- Example: Setting Group Variables in group_vars
- Example: Using Group Variables in Playbook
- 5. Using Extra Variables
- Example: Setting Variables from CLI
- Example: Using JSON File for Extra Vars
- 6. Registering Variables
- Example: Using Registered Variables
- 7. Setting Facts
- Example: Setting a Fact in a Playbook
- 8. Accessing Variables
- Example: Accessing Host Variables
- Example: Using Facts
- Example: Loop with Item Variable
- 9. Using Variable Syntax
- Example: Using Host Variables
- Example: Using Facts
- Example: Using Registered Variables
- 10. Accessing Nested Variables
- Example: Accessing Nested Variables in a Playbook
- 11. Understanding Variable Precedence
- Example: Variable Precedence in Playbook
- 12. Providing Default Values
- Example: Setting Default Values in a Playbook
Working with Magic Variables
- 1. Using hostvars
- Example: Accessing host-specific variables
- 2. Using inventory_hostname
- Example: Using inventory_hostname in a task
- Example: Using inventory_hostname_short in a task
- 3. Using inventory_hostname_short
- Example: Using inventory_hostname_short in a task
- 4. Using group_names
- Example: Using group_names in a Playbook
- 5. Using groups
- Example: Accessing group members
- Example: Using group names in conditionals
- 6. Using ansible_play_hosts
- Example: Looping over all hosts in a play
- Example: Check if a host is part of the play
- 7. Using ansible_play_batch
- Example: Using ansible_play_batch in a Playbook
- 8. Using playbook_dir
- Example: Reading playbook_dir in a task
- 9. Using role_path
- Example: Accessing role_path in a task
- 10. Using ansible_version
- Example: Display Ansible Version
Working with Facts
- 1. Gathering Facts
- Example: Using gathered facts in a task
- 2. Accessing Ansible Facts
- Example: Using Facts in a Playbook
- Example: Using Facts in a Template
- 3. Using Hardware Facts
- Example: Using Hardware Facts in a Playbook
- 4. Using Network Facts
- Example: Gathering Network Facts
- Example: Using Interface Facts
- 5. Using OS Facts
- Example: Using OS Facts in a Playbook
- 6. Filtering Facts
- Example: Filtering Facts by OS Family
- Example: Using Facts to Determine Memory Usage
- Example: Filtering by Network Interface
- 7. Creating Custom Facts
- Example: Setting a Custom Fact in a Playbook
- Example: Using Facts in Templates
- 8. Caching Facts
- Example: Configure Redis caching
- 9. Disabling Fact Gathering
- Example: Disabling fact gathering for a playbook
- 10. Using Local Facts
- Example: Setting Local Facts
- Example: Reading Local Facts
- 11. Refreshing Facts Mid-Playbook
- Example: Refreshing Facts Mid-Playbook
Using Conditionals
- 1. Using When Statements
- Example: Conditional Task Execution
- Example: Multiple Conditions
- 2. Comparing Variables
- Example: Comparing Variables in a Loop
- Example: Using 'in' Operator
- 3. Checking Variable Existence
- Example: Using
- Example: Using
- 4. Testing Boolean Values
- Example: Using Boolean Tests in Conditionals
- 5. Using Logical Operators
- Example: Combining Conditions with Logical Operators
- Example: Complex Condition with Nested Logical Operators
- 6. Checking String Content
- 7. Using Jinja2 Tests
- Example: Using Jinja2 Tests in Conditionals
- 8. Evaluating Registered Results
- Example: Using Registered Results in Conditionals
- 9. Checking File States
- Example: Check File State
- Example: Delete a File if It Exists
- 10. Using Complex Conditionals
- Example: Complex conditional in a task
- Example: Using variables with complex conditionals
- 11. Applying Conditionals to Blocks
- Example: Conditional block with loop
Implementing Loops
- 1. Using Simple Loops
- Example: Looping over a list of files
- Example: Using loop with a variable
- 2. Looping with Lists
- Example: Looping over a list of packages
- Example: Using loop_var to access item index
- 3. Looping with Dictionaries
- Example: Looping Through a Dictionary
- Example: Looping Through Dictionary Keys
- 4. Using Loop Control
- Example: Loop Control with Label
- Example: Loop Control with Index
- 5. Setting Loop Variable Name
- Example: Using loop_var in a task
- 6. Adding Loop Labels
- Example: Using loop_control.label
- 7. Using Loop Index
- Example: Using loop.index in a task
- Example: Using loop.revindex in a task
- 8. Pausing Between Iterations
- Example: Pausing Between Loop Iterations
- 9. Looping Until Condition
- Example: Looping Until a File Exists
- Example: Looping Until a Service is Running
- 10. Using Legacy Loops
- 11. Flattening Nested Lists
- Example: Flattening nested lists in a task
- Example: Flattening with multiple levels
- 12. Using Loop with Conditionals
- Example: Loop with Conditional Filter
Working with Jinja2 Templates
- 1. Creating Template Files
- Example: Basic Template File Creation
- Example: Using Variables in Templates
- 2. Using Template Module
- Example: Basic Template Module Usage
- Example: Template with Variables
- 3. Accessing Variables
- Example: Accessing Host Variables
- Example: Using Group Variables
- 4. Using Filters
- 5. Implementing Conditionals
- Example: Using when with variables
- Example: Using failed_when to check output
- Example: Using changed_when to control task state
- 6. Implementing Loops
- Example: Looping Over a List
- Example: Nested Loops with Index Tracking
- 7. Setting Template Variables
- Example: Using hostvars in a template
- Example: Conditional variable usage
- 8. Using Comments
- Example: Using Inline Comments in Jinja2
- 9. Including Templates
- Example: Including a Template
- Example: Importing Macros
- 10. Using Macros
- Example: Defining and Using a Macro
- Key Points About Macros
- 11. Escaping Variables
- Example: Escaping HTML in Templates
- 12. Controlling Whitespace
- Example: Controlling Whitespace in Templates
Using Jinja2 Filters
- 1. Transforming Strings
- Example: Using replace filter
- 2. Working with Lists
- Example: Using join filter
- 3. Formatting Data
- Example: Using format filter
- 4. Providing Defaults
- Example: Using default filter
- 5. Combining Data
- Example: Using combine filter
- 6. Selecting Items
- Example: Using selectattr filter
- 7. Extracting Values
- Example: Using map filter
- 8. Filtering Unique
- Example: Using uniqueby filter
- 9. Sorting Data
- Example: Using sort filter
- 10. Working with IP Addresses
- Example: Using ipaddr filter
- 11. Hashing Values
- Example: Using md5 filter
- 12. Manipulating Paths
- Example: Using basename filter
Working with Handlers
- 1. Defining Handlers
- Example: Basic Handler Definition
- 2. Notifying Handlers
- Example: Notifying a Handler
- 3. Executing Handlers Immediately
- Example: Notify Handler from Task
- Example: Handler Definition
- 4. Listening to Topics
- Example: Listening to a Topic
- 5. Forcing Handler Execution
- Example: Using notify to trigger handler
- Example: Forcing handler execution with always_run
- 6. Controlling Handler Order
- Example: Using listen and notify
- Handler Execution Rules
- 7. Using Handler Names
- Example: Using Handler Names
- 8. Notifying Multiple Handlers
- Example: Notifying Multiple Handlers
- 9. Preventing Handler Execution
- Example: Using
- 10. Importing Handlers
- Example: Importing Handlers from a Role
- Example: Including Handlers from a File
- 11. Including Handlers
- Example: Including Handlers from a File
Using Blocks
- 1. Defining Blocks
- Example: Basic Block Definition
- 2. Grouping Tasks
- Example: Using Blocks with Loop and Rescue
- 3. Implementing Error Handling
- Example: Using rescue and always blocks
- Error Handling Best Practices
- 4. Setting Block Variables
- Example: Setting Block Variables
- 5. Applying Block Conditions
- Example: Using when with block conditions
- 6. Using Block Tags
- Example: Using block tags in a playbook
- 7. Setting Block Delegation
- Example: Delegating a block to localhost
- 8. Executing Rescue Tasks
- Example: Rescue task execution flow
- 9. Ensuring Cleanup
- Example: Using block with cleanup
- Block Execution Flow
- 10. Nesting Blocks
- Example: Nested Block Usage
- 11. Using any_errors_fatal
- Example: Using any_errors_fatal at playbook level
Handling Errors
- 1. Ignoring Errors
- Example: Using ignore_errors
- 2. Defining Failure Conditions
- Example: Using
- Example: Using
- 3. Defining Success Conditions
- Example: Using
- Example: Using
- 4. Using Block Error Handling
- Example: Basic Block with Rescue
- Block Error Handling Summary
- 5. Catching Errors
- Example: Using rescue and always blocks
- 6. Running Cleanup
- Example: Cleanup with Ansible
- Cleanup Best Practices
- 7. Using any_errors_fatal
- Example: Using any_errors_fatal in a Playbook
- 8. Setting Max Fail Percentage
- Example: Setting max_fail_percentage to 25%
- 9. Retrying Tasks
- Example: Retry configuration
- 10. Aborting on First Failure
- Example: Using any_errors_fatal
- 11. Handling Connection Errors
- Example: Setting Connection Timeout
Working with Common Modules
- 1. Managing Files
- Example: Copying a file
- Example: Fetching a file from remote
- Example: Setting file permissions
- 2. Executing Commands
- Example: Basic command execution
- Example: Conditional command execution
- 3. Managing Packages
- 4. Managing Services
- Example: Start and Enable a Service
- Example: Stop and Disable a Service
- 5. Managing Users
- Example: Create a user with specific group and shell
- Example: Remove a user
- 6. Working with Git
- Example: Clone a Git Repository
- Example: Clone with Specific Branch and Force Update
- 7. Managing Archives
- Example: Create a tar.gz archive
- Example: Extract an archive to a directory
- 8. Checking File Stats
- Example: Check file stats
- 9. Setting Variables
- Example: Setting Variables in Playbook
- Example: Using
- 10. Managing Cron Jobs
- Example: Create a Cron Job
- Example: Remove a Cron Job
- 11. Pausing Execution
- Example: Pause for 5 seconds
- Example: Pause with custom message
- 12. Asserting Conditions
- Example: Basic Assertion
- Example: Complex Assertion with Variables
Managing Files and Directories
- 1. Copying Files
- Example: Copying a file from controller to managed node
- Example: Copying a file with different permissions
- 2. Creating Directories
- Example: Create a directory with specific permissions and ownership
- 3. Creating Symlinks
- Example: Creating a symlink
- 4. Setting Permissions
- Example: Setting File Permissions
- Example: Setting Directory Permissions
- 5. Setting Ownership
- Example: Setting Ownership of a File
- Example: Setting Ownership Recursively
- 6. Removing Files
- Example: Remove a file
- Example: Remove a directory recursively
- 7. Creating Empty Files
- Example: Creating an empty file
- 8. Using Templates
- Example: Basic Template Usage
- Example: Template with Variables
- Example: Template with Loop
- Example: Template with Conditionals
- 9. Synchronizing Files
- Example: Synchronizing Files
- 10. Finding Files
- Example: Find all .log files in /var/log
- 11. Replacing Content
- Example: Replace file content from local source
- Example: Replace content with literal string
- 12. Modifying Lines
- Example: Ensure a line exists in a config file
- Example: Insert a line before a specific pattern
Managing Packages
- 1. Installing Packages
- Example: Install a package
- Example: Install latest version of a package
- 2. Using Apt Module
- Example: Install a package
- Example: Install multiple packages
- Example: Update cache and install package
- 3. Using Yum Module
- Example: Install a package with Yum
- Example: Install a package with update_cache enabled
- Example: Remove a package with Yum
- 4. Using DNF Module
- Example: Install a package using DNF
- Example: Remove a package using DNF
- Example: Update package cache and install latest version
- 5. Updating Package Cache
- Example: Updating Package Cache with YUM
- Example: Updating Package Cache with APT
- 6. Removing Packages
- Example: Remove nginx package
- 7. Installing Specific Versions
- Example: Install specific version of a package
- 8. Installing Multiple Packages
- Example: Installing Multiple Packages
- 9. Using Pip Module
- Example: Install a Python Package
- Example: Install Specific Version of Package
- Example: Use Virtual Environment
- 10. Managing Repositories
- Example: Adding a Debian APT Repository
- Example: Adding a YUM Repository with GPG Key
- 11. Adding APT Keys
- Example: Adding an APT key from a URL
- Example: Adding an APT key from a keyserver
- 12. Installing from URLs
- Example: Installing a Debian package from URL
Managing Services
- 1. Starting Services
- Example: Starting a service
- 2. Stopping Services
- Example: Stopping a service
- 3. Restarting Services
- Example: Restarting Nginx Service
- Example: Restarting Apache Service with systemctl
- 4. Reloading Services
- Example: Reloading a service
- 5. Enabling Services at Boot
- Example: Enabling Nginx at Boot
- 6. Disabling Services at Boot
- Example: Disable a service at boot
- 7. Using Systemd Module
- Example: Start and Enable a Service
- Example: Restart a Service
- 8. Masking Services
- Example: Masking a Service
- 9. Checking Service Status
- Example: Check if nginx is running
- Example: Check service status with pattern matching
- 10. Managing Service Dependencies
- Example: Using notify to manage service dependencies
- Managing Service Dependencies
- 11. Using service vs systemd
- Example: Starting a service with
- Example: Starting a service with
- Comparison:
Managing Users and Groups
- 1. Creating Users
- Example: Create a user with custom group and shell
- Example: Create a user with encrypted password
- 2. Setting User Password
- Example: Setting a User Password
- 3. Setting User Shell
- Example: Setting User Shell
- 4. Creating Home Directory
- Example: Create User with Home Directory
- 5. Setting User Groups
- Example: Create a group
- Example: Remove a group
- 6. Removing Users
- Example: Remove a user with home directory
- Example: Remove a user without home directory
- 7. Managing SSH Keys
- Example: Add SSH key to user
- Example: Remove SSH key from user
- 8. Creating Groups
- Example: Create a group with a specific GID
- Example: Create a system group
- 9. Setting Group GID
- Example: Creating a Group with Specific GID
- 10. Managing Sudo Access
- Example: Configure Sudo Access for a User
- Example: Define Sudoers Content
- 11. Locking and Unlocking Users
- Example: Locking a User Account
- Example: Unlocking a User Account
Executing Commands
- 1. Using Command Module
- Example: Basic command execution
- Example: Command with environment variables
- 2. Using Shell Module
- Example: Running a shell command
- Example: Conditional execution
- 3. Using Raw Module
- Example: Running a raw command
- Example: Conditional execution
- 4. Setting Working Directory
- Example: Setting Working Directory
- 5. Creating Files Before Command
- Example: Creating a file with content
- 6. Removing Files After Command
- Example: Remove a file after command execution
- 7. Running Scripts
- Example: Running a Bash Script
- Example: Conditional Script Execution
- 8. Changing Command Status
- Example: Using changed status in a task
- 9. Capturing Output
- Example: Using Registered Variables
- Example: Capturing Output from a Script
- 10. Setting Environment Variables
- Example: Setting environment variables in a task
- 11. Running as Different User
- Example: Running a Task as Root
- Example: Using Different Privilege Escalation Method
- 12. Understanding Command vs Shell
- Example: Using the
- Example: Using the
Working with Tags
- 1. Adding Task Tags
- Example: Adding tags to a task
- Example: Using tags with a loop
- 2. Running Specific Tags
- Example: Running Playbook with Specific Tags
- Example: Skipping Tags
- 3. Skipping Tags
- Example: Skipping Tags During Playbook Run
- Example: Including Specific Tags Only
- 4. Listing Available Tags
- Example: Listing Tags in a Playbook
- 5. Using Multiple Tags
- Example: Using Multiple Tags
- Example: Running Playbooks with Multiple Tags
- 6. Using Special Tags
- Example: Using
- Example: Using
- Example: Using
- 7. Tagging Plays
- Example: Basic Play with Tags
- Example: Skip Tags in Play
- 8. Tagging Roles
- Example: Using Tags in Roles
- Example: Skipping Tags
- 9. Tagging Blocks
- Example: Using tags to control task execution
- Example: Conditional execution using tags
- 10. Understanding Tag Inheritance
- Example: Tag Inheritance in Playbook
- 11. Using Tag Patterns
- Example: Using Tag Patterns in Playbook
- Example: Running Playbook with Tag Patterns
Working with Includes and Imports
- 1. Understanding Static vs Dynamic
- Example: Static Include
- Example: Dynamic Import
- 2. Including Tasks
- Example: Using include_tasks
- Example: Using import_tasks
- 3. Importing Tasks
- Example: Importing tasks from a file
- Example: Including tasks dynamically
- 4. Including Playbooks
- Example: Including a Playbook
- 5. Importing Playbooks
- Example: Importing a Playbook
- 6. Including Roles
- Example: Including a Role
- Example: Including Multiple Roles
- 7. Importing Roles
- Example: Using import_role
- Example: Using include_role with vars
- Key Differences
- 8. Passing Variables
- Example: Passing Variables to a Task
- Example: Using Extra Vars in Playbook
- 9. Using Conditionals
- Example: Using when with a variable
- Example: Using when with a complex condition
- 10. Using Tags
- Example: Using Tags in Playbook
- Example: Running Tasks with Specific Tags
- Example: Skipping Tasks with Specific Tags
- 11. Looping Over Includes
- Example: Looping Over Include Files
- 12. Understanding Precedence
- Example: Precedence in Playbook
Creating and Managing Roles
- 1. Understanding Role Structure
- Example: Basic role directory structure
- 2. Creating Roles
- Example: Basic Role Structure
- Example: tasks/main.yml
- Example: meta/main.yml
- 3. Defining Role Tasks
- Example: Basic Role Task
- Example: Conditional Task with Loop
- 4. Setting Role Defaults
- Example: Setting Role Defaults
- 5. Setting Role Variables
- Example: Setting Role Variables in defaults/main.yml
- Example: Using Role Variables in tasks/main.yml
- 6. Creating Role Handlers
- Example: Basic Handler Definition
- Example: Handler with Variable
- Handler Best Practices
- 7. Managing Role Files
- Example: Using templates in a role
- Example: Including variables in a role
- 8. Managing Role Templates
- Example: Using a Jinja2 Template in a Role
- Template Variables
- 9. Setting Role Dependencies
- Example: Role Dependencies Configuration
- 10. Using Roles in Playbooks
- Example: Including a Role in a Playbook
- Example: Including a Role with Variables
- 11. Passing Variables to Roles
- Example: Passing Variables to a Role
- Example: Using Role Defaults
- Example: Using Host Variables
- 12. Controlling Role Execution
- Example: Using when with role execution
Implementing Role Patterns
- 1. Including Roles Dynamically
- Example: Including a Role with Variables
- 2. Importing Roles Statically
- Example: Importing a Static Role
- Example: Importing a Specific Task File from a Role
- 3. Passing Variables to Roles
- Example: Setting Variables in Role
- Example: Using Extra Vars
- 4. Setting Role Tags
- Example: Defining tags in meta/main.yml
- Example: Applying tags in tasks
- 5. Using Role Conditionals
- Example: Conditional Role Execution
- Example: Delegating to Localhost
- 6. Setting Role Privilege Escalation
- Example: Using become in a role
- 7. Understanding Static vs Dynamic
- Example: Using Dynamic Variables in a Playbook
- 8. Using Role Collections
- Example: Installing a Collection
- 10. Creating Reusable Roles
- Example: Basic Role Structure
- Example: Using Variables in a Role
- 11. Organizing Role Libraries
- Example: Role Library Structure
- Best Practices
Working with Ansible Galaxy
- 1. Installing Roles
- Example: Install a role
- Example: Install a role to a specific path
- 2. Creating Roles
- Example: Basic Role Structure
- Example: Defining Variables in defaults/main.yml
- Example: Using Templates in a Role
- 3. Listing Installed Roles
- Example: Listing installed roles
- Example: Listing roles in a specific path
- 4. Removing Roles
- Example: Removing a Role
- 5. Using Requirements File
- Example: requirements.yml file
- 6. Installing from Requirements
- Example: requirements.yml content
- Example: Installing from requirements.yml
- 7. Searching Galaxy
- Example: Search for collections
- 9. Installing Collections
- Example: Installing a collection from Ansible Galaxy
- Example: Installing a specific version of a collection
- 10. Specifying Versions
- Example: Installing a specific version from Ansible Galaxy
- Example: Using Git for version control
- 11. Installing from Git
- Example: Installing from Git
- 12. Setting Install Path
- Example: Setting Galaxy Install Path in ansible.cfg
Working with Collections
- 1. Understanding Collections
- 2. Installing Collections
- Example: Installing a collection
- 3. Using Collection Modules
- Example: Using a collection module
- 4. Setting Collection Path
- Example: Setting collection path in ansible.cfg
- 5. Creating Custom Collections
- Example: Creating a minimal collection structure
- 6. Defining Collection Dependencies
- Example: Defining dependencies in meta/main.yml
- 7. Using Collections in Playbooks
- Example: Using a collection in a playbook
- 8. Listing Collections
- Example: Listing collections
- 9. Upgrading Collections
- Example: Upgrading a collection
- 10. Verifying Collections
- Example: Verifying a collection
- 11. Building Collections
- Example: Building a collection
- 12. Publishing Collections
- Example: Publishing a collection
Working with Ansible Vault
- 1. Creating Encrypted Files
- Example: Creating an encrypted file
- 2. Encrypting Existing Files
- Example: Encrypting an existing file
- 3. Decrypting Files
- Example: Decrypting a file
- 4. Editing Encrypted Files
- Example: Editing an encrypted file
- 5. Viewing Encrypted Files
- Example: Viewing an encrypted file
- 6. Changing Vault Password
- Example: Changing the vault password
- 7. Using Vault in Playbooks
- Example: Using vault in a playbook
- 8. Using Vault Password File
- Example: Using a vault password file
- 9. Using Multiple Vault IDs
- Example: Using multiple vault IDs
- 10. Encrypting Variables
- Example: Encrypting a variable string
- 11. Using Inline Vault Variables
- Example: Using inline vault variables
- 12. Setting Vault ID Default
- Example: Setting default vault ID in ansible.cfg
Using Ansible Playbook Command
- 1. Running Playbooks
- Example: Running a playbook with inventory
- 2. Checking Syntax
- Example: Syntax Check
- 3. Performing Dry Run
- Example: Running a playbook with dry-run
- 4. Showing Differences
- Example: Using --diff flag
- 5. Limiting Hosts
- Example: Limiting to a specific host
- Example: Limiting to a host group
- Example: Using pattern matching
- 6. Using Tags
- Example: Tagging Tasks
- Example: Running Specific Tags
- 7. Starting at Task
- Example: Starting at a Specific Task
- 8. Setting Verbosity
- Example: Running a playbook with verbose output
- 9. Listing Tasks
- Example: Listing Tasks in a Playbook
- 10. Listing Hosts
- Example: Listing hosts in a playbook
- 11. Using Extra Variables
- Example: Setting a variable with
- Example: Loading variables from a file
- 12. Setting Inventory
- Example: Static Inventory File (hosts.ini)
- Example: Dynamic Inventory Script
Debugging Playbooks
- 1. Using Debug Module
- Example: Displaying a Message
- Example: Displaying Variable Value
- 2. Printing Variables
- Example: Debugging Variables in a Playbook
- Example: Using the debug module to print a variable
- 3. Using Verbosity Levels
- Example: Running a playbook with verbose output
- 4. Enabling Debug Mode
- Example: Using debug mode in a playbook
- 5. Checking Task Output
- Example: Using debug module to display task output
- Example: Debugging with custom message
- 6. Using Playbook Debugger
- Example: Using debug module in playbook
- Workflow: Using debug in Ansible Playbook
- 7. Setting Breakpoints
- Example: Using debug module with breakpoints
- 8. Inspecting Variables
- Example: Debugging Variables with debug module
- Example: Print all facts
- 9. Checking Task Status
- Example: Displaying Variable Value
- Example: Conditional Debug Output
- 10. Continuing Execution
- Example: Using
- Workflow: Debugging with Step Mode
- 11. Logging Output
- Example: Setting up logging in ansible.cfg
- Example: Using debug module to log output
- 12. Using Assert Module
- Example: Asserting Command Success
Working with Lookup Plugins
- 1. Understanding Lookup Plugins
- Example: Using lookup plugin to read a file
- Example: Using lookup plugin to get environment variable
- 2. Reading Files
- Example: Reading a File
- Example: Reading a File with Line-by-Line Processing
- 3. Using Environment Variables
- Example: Retrieving Environment Variables
- 4. Reading Templates
- Example: Reading a Jinja2 Template
- Example: Using Template Variables
- 5. Querying Passwords
- Example: Using passwordstore lookup
- Example: Using vault lookup
- 6. Using Key-Value Stores
- Example: Using Vault Lookup Plugin
- 7. Reading URLs
- Example: Fetching JSON from a URL
- 8. Using Pipe Lookup
- Example: Using Pipe Lookup to Get Hostname
- Example: Using Pipe Lookup with Complex Command
- 9. Querying DNS
- Example: Querying A Records
- Example: Querying MX Records
- 10. Reading CSV Files
- Example: Reading CSV Data
- Example: Using CSV Data in a Loop
- 11. Using Sequence Lookup
- Example: Basic sequence usage
- Example: Generate a range of numbers
- Example: Create a sequence with custom step
- 12. Using ini Lookup
- Example: Reading a database host from an INI file
Working with Callback Plugins
- 1. Understanding Callback Plugins
- Example: Enabling a Callback Plugin
- Example: Configuring Callback Plugin Settings
- 2. Using JSON Callback
- Example: Using JSON Callback Plugin
- 3. Using YAML Callback
- Example: YAML Callback Configuration
- 4. Using Timer Plugin
- Example: Timer Plugin Configuration
- Timer Plugin Features
- 5. Creating Custom Callbacks
- Example: Custom Callback Plugin Structure
- Key Methods in Callback Plugins
- 6. Enabling Multiple Callbacks
- Example: Configuring Multiple Callbacks
- 7. Using Oneline Callback
- Example: Using Oneline Callback
- 8. Configuring Callbacks
- Example: Enabling custom callback plugin
- 9. Sending Notifications
- Example: Slack Notification Configuration
- 10. Logging Results
- Example: Configuring JSON logging
Working with Plugin Types
- 1. Understanding Plugin Types
- Example: Using a Custom Action Plugin
- 2. Using Filter Plugins
- Example: Using filter plugins in a task
- Example: Using regex_replace filter
- 3. Using Test Plugins
- Example: Using test plugins in a playbook
- Key Features of Test Plugins
- 4. Using Action Plugins
- Example: Using the copy action plugin
- Example: Using the command action plugin
- 5. Using Connection Plugins
- Example: Using connection plugins in a playbook
- Common Connection Plugins
- 6. Using Cache Plugins
- Example: Configuring Redis Cache Plugin
- Example: Using Cache in Playbook
- Cache Plugin Types
- 7. Configuring Plugin Paths
- Example: Setting plugin paths in ansible.cfg
- 8. Creating Custom Plugins
- Example: Creating a Custom Filter Plugin
- Example: Using the Custom Filter in a Playbook
- 9. Using Inventory Plugins
- Example: YAML Inventory with Groups
- Example: EC2 Inventory Plugin Configuration
- 10. Using Vars Plugins
- Example: Using vars plugin to load from YAML file
Implementing Strategy Plugins
- 1. Understanding Strategy Plugins
- Example: Setting Strategy in Playbook
- Key Concepts
- 2. Using Linear Strategy
- Example: Using Linear Strategy in a Playbook
- 3. Using Free Strategy
- Example: Using Free Strategy in Playbook
- 4. Using Debug Strategy
- Example: Using Debug Strategy in Playbook
- 5. Using Host Pinned Strategy
- Example: Using host_pinned strategy in a playbook
- 6. Configuring Strategy Options
- Example: Setting Strategy in Playbook
- 7. Setting Serial Execution
- Example: Serial Execution in Playbook
- 8. Using Forks
- Example: Setting forks in playbook
- 9. Combining Strategy and Serial
- Example: Using
- 10. Creating Custom Strategies
- Example: Basic Custom Strategy Plugin
Implementing Asynchronous Tasks
- 1. Setting Async Tasks
- Example: Running an async task with polling
- 2. Setting Poll Interval
- Example: Setting Poll Interval
- 3. Using Fire and Forget
- Example: Fire and Forget Task
- Example: Checking Async Task Status
- 4. Checking Async Status
- Example: Checking Async Status
- 5. Registering Async Job ID
- Example: Registering Async Job ID
- 6. Waiting for Completion
- Example: Waiting for Async Task Completion
- Key Points
- 7. Setting Async Timeout
- Example: Setting Async Timeout
- 8. Using Async with Loops
- Example: Using async with loop
- 9. Running Long Tasks
- Example: Running a long task asynchronously
- Example: Background task with status check
- 10. Handling Async Failures
- Example: Async Task with Failure Handling
- Async Failure Handling Best Practices
- 11. Cleaning Up Async Jobs
- Example: Cleaning Up Async Jobs
Optimizing Ansible Performance
- 1. Increasing Parallelism
- Example: Setting forks in playbook
- Example: Using serial for large inventories
- 2. Enabling Pipelining
- Example: Enabling Pipelining in a Playbook
- 3. Using Fact Caching
- Example: Enable fact caching with JSON file
- 4. Disabling Fact Gathering
- Example: Disabling facts for a playbook
- 5. Using Async Tasks
- Example: Running an async task
- Example: Checking async task status
- 6. Implementing Strategy Plugins
- Example: Using the
- 7. Reducing SSH Overhead
- Example: SSH Control Master Configuration
- 8. Using Mitogen Plugin
- Example: Enabling Mitogen Plugin
- 9. Optimizing Template Rendering
- Example: Using template_cache
- Example: Custom Jinja2 extensions
- 10. Batching Tasks
- Example: Using batch_size in a playbook
- 11. Using Persistent Connections
- Example: Configuring persistent connections in inventory
- Example: Using persistent connections in a playbook
- 12. Minimizing Privilege Escalation
- Example: Disabling privilege escalation
- Example: Using become with specific user
Testing and Validating Playbooks
- 1. Performing Syntax Check
- Example: Basic syntax check command
- 2. Running Check Mode
- Example: Running a playbook in check mode
- Example: Running a playbook in check mode with diff
- 3. Using Diff Mode
- Example: Enabling diff mode in a playbook
- 4. Testing with Molecule
- Example: Basic Molecule Configuration
- Example: Test Playbook with Molecule
- Key Features of Molecule
- 5. Creating Test Scenarios
- Example: Basic Test Scenario Structure
- Example: Testing with Mock Data
- Best Practices for Test Scenarios
- 6. Using Docker Driver
- Example: Running Ansible tests with Docker driver
- 7. Running Ansible Lint
- Example: Running ansible-lint
- 8. Validating YAML
- Example: Validating playbook syntax
- 9. Testing Idempotence
- Example: Idempotent File Creation
- Example: Idempotent Package Installation
- Idempotency Best Practices
- 10. Using Assert Module
- Example: Basic Assert Usage
- Example: Assert with Variable
- 11. Verifying Results
- Example: Check Task Results
- Example: Validate Configuration Files
- 12. Running Verify Phase
- Example: Using ansible-playbook with verify
Implementing Advanced Patterns
- 1. Using Delegation Strategies
- 2. Implementing Rolling Updates
- Example: Rolling Update with Batch Size
- Example: Rolling Update with Delay
- 3. Implementing Blue-Green Deployments
- Example: Blue-Green Deployment Setup
- Example: Switching Traffic to Green
- Benefits of Blue-Green Deployment
- Blue-Green vs Other Deployment Strategies
- 4. Using Canary Deployments
- Example: Canary Deployment Playbook
- Canary Deployment Steps
- 5. Implementing Zero-Downtime Deployments
- Example: Rolling Update with Load Balancer
- Example: Blue-Green Deployment
- Best Practices for Zero-Downtime Deployment
- 6. Using Pre and Post Tasks
- Example: Using pre_task and post_task
- Key Points
- 7. Implementing Health Checks
- Example: HTTP Health Check
- Example: TCP Port Check
- Example: File Existence Check
- Example: Command Execution Check
- 8. Using Smoke Tests
- Example: Smoke Test Playbook
- 9. Implementing Rollback Strategies
- Example: Rollback using tags
- 10. Using Configuration Drift Detection
- Example: Detecting Configuration Drift with Ansible
Implementing Security Best Practices
- 1. Using Ansible Vault
- Example: Encrypting a Variables File
- Example: Using Vault in Playbook
- 2. Managing SSH Keys
- Example: Using SSH Key for Authentication
- Best Practices for SSH Key Management
- 3. Setting Become Password
- Example: Using become_password in a playbook
- 4. Disabling Root Login
- Example: Disabling Root Login via SSH
- 5. Validating Module Sources
- Example: Verifying Collection Integrity
- 6. Setting File Permissions
- Example: Setting File Permissions with Ansible
- Example: Setting Directory Permissions with Ansible
- Key Points for File Permissions
- 7. Limiting Privilege Escalation
- Example: Using become with sudo
- 8. Using Separate Vault Files
- Example: Encrypting a Vault File
- Example: Using Vault File in Playbook
- 9. Auditing Playbook Runs
- Example: Enable Verbose Logging
- Example: Run with Diff and Check Mode
- 10. Implementing RBAC
- Example: Role Assignment in Ansible Tower
- 11. Using Jump Hosts
- Example: Using Jump Host in Inventory
- Example: Using Proxy Command in Playbook
- 12. Validating Input
- Example: Validating User Input in Playbook
Managing AWS Infrastructure
- 1. Using AWS Collection
- Example: Configure AWS credentials
- Example: Launch EC2 instance
- 2. Configuring AWS Credentials
- Example: Using Environment Variables
- 3. Managing EC2 Instances
- Example: Launching EC2 Instances
- Example: Tagging EC2 Instances
- 4. Managing S3 Buckets
- Example: Create S3 Bucket
- Example: Delete S3 Bucket
- 5. Managing VPCs
- Example: Create a VPC
- Example: Delete a VPC
- 6. Managing Security Groups
- Example: Create a Security Group
- Example: Add Ingress Rule to Security Group
- Example: Remove a Rule from Security Group
- 7. Managing IAM Resources
- Example: Create an IAM User
- Example: Attach Policy to IAM Group
- Example: Create IAM Role with Trust Policy
- 8. Managing RDS Instances
- Example: Create an RDS Instance
- Example: Modify RDS Instance Storage
- 9. Using Dynamic Inventory
- Example: Basic Dynamic Inventory Configuration
- Example: Using Dynamic Inventory with Groups
- 10. Managing Load Balancers
- Example: Create an ELB with HTTP listener
- Example: Update an existing ELB with new listeners
- Example: Create a target group for an ALB
Managing Azure and GCP Infrastructure
- 1. Using Azure Collection
- Example: Create a Resource Group
- Example: Create a Virtual Machine
- 2. Configuring Azure Credentials
- Example: Setting up Azure credentials in a playbook
- 3. Managing Azure VMs
- Example: Create an Azure VM
- Example: Scale VM Size
- Example: Start/Stop VM
- 4. Managing Azure Resources
- Example: Create an Azure Resource Group
- Example: Create an Azure Virtual Machine
- Example: Create an Azure Storage Account
- 5. Using Azure Dynamic Inventory
- Example: Basic Azure Dynamic Inventory Configuration
- Example: Using Azure CLI Authentication
- Example: Using Managed Identity Authentication
- 6. Using GCP Collection
- Example: Creating a GCP Compute Instance
- Example: Creating a GCP Storage Bucket
- 7. Configuring GCP Credentials
- Example: Setting GCP Credentials via Environment Variables
- Example: Using GCP Credentials in Ansible Playbook
- 8. Managing GCE Instances
- Example: Create GCE Instance
- Example: Delete GCE Instance
- 9. Managing GCP Resources
- Example: Create a GCP Compute Instance
- Example: Create a GCP Storage Bucket
- Example: Create a GCP SQL Instance
- Example: Create a GKE Cluster
- 10. Using GCP Dynamic Inventory
- Example: GCP Dynamic Inventory Configuration
- Key Features
Working with Container Platforms
- 1. Managing Docker Containers
- Example: Start a Docker Container
- Example: Stop and Remove a Container
- 2. Building Docker Images
- Example: Building a Docker Image
- 3. Managing Docker Networks
- Example: Create a Docker Network
- Example: Remove a Docker Network
- 4. Managing Docker Volumes
- Example: Creating a Docker Volume
- Example: Removing a Docker Volume
- 5. Using Docker Login
- Example: Docker Login Configuration
- 6. Managing Kubernetes Resources
- Example: Deploying a Kubernetes Deployment
- Example: Creating a Kubernetes Service
- Key Features
- 7. Using Helm Charts
- Example: Deploying a Helm Chart
- 8. Managing Pods
- Example: Create a Pod
- Example: Delete a Pod
- Example: Scale Pod Replicas
- 9. Managing Deployments
- Example: Deploying a Kubernetes Deployment
- Example: Managing Docker Container Deployment
- 10. Managing ConfigMaps and Secrets
- Example: Creating a ConfigMap
- Example: Creating a Secret
- Example: Using ConfigMap in a Pod
- Example: Using Secret in a Pod
Managing Network Devices
- 1. Understanding Network Modules
- Example: Using network modules to gather facts
- 2. Configuring Cisco IOS
- Example: Configure a Cisco IOS device using CLI
- Example: Configure interface on Cisco IOS
- 3. Configuring Juniper Devices
- Example: Configure a Juniper device with basic settings
- Example: Apply configuration from a file
- 4. Using Network CLI Connection
- Example: Basic Network CLI Connection Configuration
- 5. Using NETCONF Connection
- Example: Configure a Network Device via NETCONF
- 6. Backing Up Configurations
- Example: Backup Configuration Using network_cli
- Example: Backup Configuration Using napalm
- 7. Validating Configurations
- Example: Validate configuration using NETCONF
- 8. Using Command Module
- Example: Execute a command on a network device
- Example: Execute command with prompt and answer
- 9. Managing VLANs
- Example: Create a VLAN
- Example: Assign Interface to VLAN
- 10. Managing Interfaces
- Example: Configure Interface
- 11. Managing Static Routes
- Example: Configure Static Route on Cisco IOS
- Example: Ansible Playbook for Static Route
Managing Windows Hosts
- 1. Configuring WinRM
- Example: Basic WinRM Configuration
- 2. Setting Windows Connection
- Example: Playbook using Windows connection
- 3. Using Windows Modules
- Example: Running a PowerShell Script
- Example: Managing a Windows Service
- 4. Managing Windows Services
- Example: Start a Windows Service
- Example: Stop and Disable a Windows Service
- 5. Managing Windows Packages
- Example: Install a Windows Package
- Example: Remove a Windows Package
- 6. Managing Windows Files
- Example: Copying a file to Windows host
- Example: Creating a directory on Windows host
- Example: Removing a file from Windows host
- 7. Executing PowerShell
- Example: Executing a PowerShell script
- Example: Executing a PowerShell script with arguments
- 8. Managing Windows Users
- Example: Create a Windows User
- Example: Delete a Windows User
- 9. Managing Windows Features
- 10. Managing Windows Registry
- Example: Setting a Windows Registry Value
- Example: Removing a Windows Registry Key
- 11. Managing Windows Updates
- Example: Install Windows Updates
- Example: Check for Available Updates
Integrating with CI/CD Pipelines
- 1. Using Ansible in Jenkins
- Example: Jenkins Pipeline Script
- 2. Using Ansible in GitLab CI
- Example: Basic GitLab CI Pipeline with Ansible
- 3. Using Ansible in GitHub Actions
- Example: GitHub Actions Workflow
- 4. Using Ansible in CircleCI
- Example: Basic CircleCI Configuration
- Key Configuration Points
- 5. Managing Secrets in CI
- Example: Using Vault in CI Pipeline
- 6. Running Tests in CI
- Example: Running Tests in GitHub Actions
- 7. Deploying from CI
- Example: Deploying to Production
- 8. Using Ansible Pull
- Example: Running Ansible Pull
- 9. Scheduling Playbooks
- Example: Scheduling a playbook with cron
- 10. Using AWX Tower API
- Example: Triggering a Job via AWX API
- API Integration Summary
Working with AWX and Ansible Tower
- 1. Understanding AWX Architecture
- Example: AWX Component Interaction
- Key Points
- 2. Installing AWX
- Example: Installing AWX using Docker
- Installation Steps
- Prerequisites
- 3. Creating Organizations
- Example: Creating an Organization via API
- 4. Managing Users and Teams
- Example: Create a new user with admin privileges
- Example: Update user permissions
- Example: Delete a user
- Example: Create a new team
- Example: Add user to team
- Example: Remove user from team
- 5. Creating Inventories
- Example: Creating a Smart Inventory
- Example: Creating a Constructed Inventory
- 6. Creating Projects
- Example: Creating a Project via API
- 7. Creating Job Templates
- Example: Creating a Job Template via API
- 8. Creating Workflows
- Example: Basic Workflow Job Template
- Steps to Create a Workflow
- Workflow Job Template Components
- 9. Managing Credentials
- Example: Creating an AWS Credential
- 10. Using Surveys
- Example: Survey Configuration in Job Template
- 11. Scheduling Jobs
- Example: Create a Scheduled Job
- 12. Using AWX API
- Example: Launching a Job Template via API
Troubleshooting Ansible Issues
- 1. Debugging Connection Issues
- Example: Verifying SSH connectivity
- Workflow: Troubleshooting Steps
- 2. Resolving Authentication Errors
- Example: SSH Key Authentication Setup
- Example: Inventory Configuration with SSH Key
- 3. Troubleshooting Module Errors
- Example: Module not found error
- Example: Invalid parameter error
- Example: Permission denied error
- Common Troubleshooting Steps
- 4. Debugging Variable Issues
- Example: Debugging undefined variable
- Example: Inspecting all variables
- 5. Resolving Template Errors
- Example: Undefined Variable Handling
- Example: Template with Error Handling
- 6. Debugging Inventory Issues
- Example: Validate Inventory
- Example: List All Hosts
- Example: Inspect Host Variables
- 7. Resolving Privilege Escalation
- Example: Using become to run a task as root
- 8. Debugging Performance Issues
- Example: Profiling playbook execution
- Example: Limiting forks to reduce memory usage
- 9. Troubleshooting Idempotence
- Example: Idempotent Task
- Example: Non-Idempotent Task
- 10. Resolving Python Dependency Issues
- Example: Setting Python Interpreter
- 11. Debugging Custom Modules
- Example: Using debug module to inspect variables
- Example: Using debug to print message
- 12. Using Ansible Logs
- Example: Enabling verbose logging
- Example: Setting log file in configuration
- Example: Filtering logs by host