Helion


Szczegóły ebooka

Mastering Ansible - Fourth Edition

Mastering Ansible - Fourth Edition


Ansible is a modern, YAML-based automation tool (built on top of Python, one of the world's most popular programming languages) with a massive and ever-growing user base. Its popularity and Python underpinnings make it essential learning for all in the DevOps space.

This fourth edition of Mastering Ansible provides complete coverage of Ansible automation, from the design and architecture of the tool and basic automation with playbooks to writing and debugging your own Python-based extensions.

You'll learn how to build automation workflows with Ansible's extensive built-in library of collections, modules, and plugins. You'll then look at extending the modules and plugins with Python-based code and even build your own collections -- ultimately learning how to give back to the Ansible community.

By the end of this Ansible book, you'll be confident in all aspects of Ansible automation, from the fundamentals of playbook design to getting under the hood and extending and adapting Ansible to solve new automation challenges.

  • Mastering Ansible Fourth Edition
  • Contributors
  • About the author
  • About the reviewer
  • Preface
    • Who this book is for
    • What this book covers
    • To get the most out of this book
    • Download the example code files
    • Code in Action
    • Download the color images
    • Conventions used
    • Get in touch
    • Share Your Thoughts
  • Section 1: Ansible Overview and Fundamentals
  • Chapter 1: The System Architecture and Design of Ansible
    • Technical requirements
    • Ansible versions and configurations
    • Inventory parsing and data sources
      • Static inventories
      • Inventory ordering
      • Inventory variable data
      • Dynamic inventories
      • Runtime inventory additions
      • Inventory limiting
    • Playbook parsing
      • The order of operations
      • Relative path assumptions
      • Play behavior directives
      • Execution strategies
      • The host selection for plays and tasks
      • Play and task names
    • Module transport and execution
      • The module reference
      • Module arguments
      • Module blacklisting
      • Module transport and execution
    • Variable types and location
      • Variable types
      • Magic variables
    • Accessing external data
    • Variable precedence
      • Precedence order
      • Variable group priority ordering
      • Merging hashes
    • Summary
    • Questions
  • Chapter 2: Migrating from Earlier Ansible Versions
    • Technical requirements
    • Changes in Ansible 4.3
      • Ansible Content Collections
    • Upgrading from earlier Ansible installations
      • Uninstalling Ansible 3.0 or older
    • Installing Ansible from scratch
    • What are Ansible Collections?
      • The anatomy of an Ansible collection
    • Installing additional modules with ansible-galaxy
    • How to port legacy playbooks to Ansible 4.3 (a primer)
    • Summary
    • Questions
  • Chapter 3: Protecting Your Secrets with Ansible
    • Technical requirements
    • Encrypting data at rest
      • Vault IDs and passwords
      • Things Vault can encrypt
    • Creating and editing encrypted files
      • Encrypting existing files
      • Editing encrypted files
      • Password rotation on encrypted files
      • Decrypting encrypted files
    • Executing ansible-playbook with encrypted files
    • Mixing encrypted data with plain YAML
    • Protecting secrets while operating
      • Secrets transmitted to remote hosts
      • Secrets logged to remote or local files
    • Summary
    • Questions
  • Chapter 4: Ansible and Windows Not Just for Linux
    • Technical requirements
    • Running Ansible from Windows
      • Checking your build
      • Enabling WSL
      • Installing Linux under WSL
    • Setting up Windows hosts for Ansible control using WinRM
      • System requirements for automation with Ansible using WinRM
      • Enabling the WinRM listener
      • Connecting Ansible to Windows using WinRM
    • Handling Windows authentication and encryption when using WinRM
      • Authentication mechanisms
      • A note on accounts
      • Certificate validation over WinRM
    • Setting up Windows hosts for Ansible control using OpenSSH
    • Automating Windows tasks with Ansible
      • Picking the right module
      • Installing software
      • Extending beyond modules
    • Summary
    • Questions
  • Chapter 5: Infrastructure Management for Enterprises with AWX
    • Technical requirements
    • Getting AWX up and running
    • Integrating AWX with your first playbook
      • Defining a project
      • Defining an inventory
      • Defining credentials
      • Defining a template
    • Going beyond the basics
      • Role-based access control (RBAC)
      • Organizations
      • Scheduling
      • Auditing
      • Surveys
      • Workflow templates
      • Notifications
      • Using the API
    • Summary
    • Questions
  • Section 2: Writing and Troubleshooting Ansible Playbooks
  • Chapter 6: Unlocking the Power of Jinja2 Templates
    • Technical requirements
    • Control structures
      • Conditionals
      • Loops
      • Macros
    • Data manipulation
      • Syntax
      • Useful built-in filters
      • Useful Ansible provided custom filters
      • Omitting undefined arguments
      • Python object methods
    • Comparing values
      • Comparisons
      • Logic
      • Tests
    • Summary
    • Questions
  • Chapter 7: Controlling Task Conditions
    • Technical requirements
    • Defining a failure
      • Ignoring errors
      • Defining an error condition
    • Defining a change
      • Special handling of the command family
      • Suppressing a change
    • Error recovery
      • Using the rescue section
      • Using the always section
      • Handling unreliable environments
    • Iterative tasks with loops
    • Summary
    • Questions
  • Chapter 8: Composing Reusable Ansible Content with Roles
    • Technical requirements
    • Task, handler, variable, and playbook inclusion concepts
      • Including tasks
      • Task inclusions with loops
      • Including handlers
      • Including variables
      • Including playbooks
    • Roles (structures, defaults, and dependencies)
      • Role structure
      • Role dependencies
      • Role application
      • Role sharing
    • Summary
    • Questions
  • Chapter 9: Troubleshooting Ansible
    • Technical requirements
    • Playbook logging and verbosity
      • Verbosity
      • Logging
    • Variable introspection
      • Variable subelements
    • Debugging code execution
      • Playbook debugging
      • Debugging local code
    • Summary
    • Questions
  • Chapter 10: Extending Ansible
    • Technical requirements
    • Developing modules
      • The basic module construct
      • Custom modules
      • Example simple module
    • Developing plugins
      • Connection-type plugins
      • Shell plugins
      • Lookup plugins
      • Vars plugins
      • Fact-caching plugins
      • Filter plugins
      • Callback plugins
      • Action plugins
      • Distributing plugins
    • Developing dynamic inventory plugins
      • Listing hosts
      • Listing host variables
      • Simple inventory plugin
    • Contributing to the Ansible project
      • Contribution submissions
    • Summary
    • Questions
  • Section 3: Orchestration with Ansible
  • Chapter 11: Minimizing Downtime with Rolling Deployments
    • Technical requirements
    • In-place upgrades
    • Expanding and contracting
    • Failing fast
      • The any_errors_fatal option
      • The max_fail_percentage option
      • Forcing handlers
    • Minimizing disruptions
      • Delaying a disruption
      • Running destructive tasks only once
    • Serializing single tasks
    • Summary
    • Questions
  • Chapter 12: Infrastructure Provisioning
    • Technical requirements
    • Managing an on-premise cloud infrastructure
      • Creating servers
      • Using OpenStack inventory sources
    • Managing a public cloud infrastructure
    • Interacting with Docker containers
      • Building images
      • Building containers without a Dockerfile
      • Docker inventory
    • Building containers with Ansible
    • Summary
    • Questions
  • Chapter 13: Network Automation
    • Technical requirements
    • Ansible for network management
      • Cross-platform support
      • Configuration portability
      • Backup, restore, and version control
      • Automated change requests
    • Handling multiple device types
      • Researching your modules
      • Configuring your modules
      • Writing your playbooks
    • Working with the cli_command module
    • Configuring Arista EOS switches with Ansible
    • Configuring Cumulus Networks switches with Ansible
      • Defining our inventory
      • Practical examples
    • Best practices
    • Summary
    • Questions
    • Why subscribe?
  • Other Books You May Enjoy
    • Packt is searching for authors like you
    • Share Your Thoughts