Spec-Zone.ru › Ansible 2.10

User Guide

Welcome to the Ansible User Guide! This guide covers how to work with Ansible, including using the command line, working with inventory, interacting with data, writing tasks, plays, and playbooks; executing playbooks, and reference materials. This page outlines the most common situations and questions that bring readers to this section. If you prefer a traditional table of contents, you can find one at the bottom of the page.

Getting started

  • I’d like an overview of how Ansible works. Where can I find:

    • a quick video overview
    • a text introduction
  • I’m ready to learn about Ansible. What Ansible concepts do I need to learn?
  • I want to use Ansible without writing a playbook. How do I use ad-hoc commands?

Writing tasks, plays, and playbooks

  • I’m writing my first playbook. What should I know before I begin?
  • I have a specific use case for a task or play:

    • Executing tasks with elevated privileges or as a different user with become
    • Repeating a task once for each item in a list with loops
    • Executing tasks on a different machine with delegation
    • Running tasks only when certain conditions apply with conditionals and evaluating conditions with tests
    • Grouping a set of tasks together with blocks
    • Running tasks only when something has changed with handlers
    • Changing the way Ansible handles failures
    • Setting remote environment values
  • I want to leverage the power of re-usable Ansible artifacts. How do I create re-usable files and roles?
  • I need to incorporate one file or playbook inside another. What is the difference between including and importing?
  • I want to run selected parts of my playbook. How do I add and use tags?

Working with inventory

  • I have a list of servers and devices I want to automate. How do I create inventory to track them?
  • I use cloud services and constantly have servers and devices starting and stopping. How do I track them using dynamic inventory?
  • I want to automate specific sub-sets of my inventory. How do I use patterns?

Interacting with data

  • I want to use a single playbook against multiple systems with different attributes. How do I use variables to handle the differences?
  • I want to retrieve data about my systems. How do I access Ansible facts?
  • I need to access sensitive data like passwords with Ansible. How can I protect that data with Ansible vault?
  • I want to change the data I have, so I can use it in a task. How do I use filters to transform my data?
  • I need to retrieve data from an external datastore. How do I use lookups to access databases and APIs?
  • I want to ask playbook users to supply data. How do I get user input with prompts?
  • I use certain modules frequently. How do I streamline my inventory and playbooks by setting default values for module parameters?

Executing playbooks

Once your playbook is ready to run, you may need to use these topics:

  • Executing “dry run” playbooks with check mode and diff
  • Running playbooks while troubleshooting with start and step
  • Correcting tasks during execution with the Ansible debugger
  • Controlling how my playbook executes with strategies and more
  • Running tasks, plays, and playbooks asynchronously

Advanced features and reference

  • Using advanced syntax
  • Manipulating complex data
  • Using plugins
  • Using playbook keywords
  • Using command-line tools
  • Rejecting specific modules
  • Module maintenance

Traditional Table of Contents

If you prefer to read the entire User Guide, here’s a list of the pages in order:

  • Ansible Quickstart Guide
  • Ansible concepts
    • Control node
    • Managed nodes
    • Inventory
    • Collections
    • Modules
    • Tasks
    • Playbooks
  • Getting Started
    • Selecting machines from inventory
    • Connecting to remote nodes
    • Copying and executing modules
    • Resources
    • Next steps
  • Introduction to ad-hoc commands
    • Why use ad-hoc commands?
    • Use cases for ad-hoc tasks
  • Working with playbooks
    • Templating (Jinja2)
    • Advanced playbooks features
    • Playbook Example: Continuous Delivery and Rolling Upgrades
  • Intro to playbooks
    • Playbook syntax
    • Playbook execution
    • Ansible-Pull
    • Verifying playbooks
  • Tips and tricks
    • General tips
    • Playbook tips
    • Inventory tips
    • Execution tricks
  • Understanding privilege escalation: become
    • Using become
    • Risks and limitations of become
    • Become and network automation
    • Become and Windows
  • Loops
    • Comparing loop and with_*
    • Standard loops
    • Registering variables with a loop
    • Complex loops
    • Ensuring list input for loop: using query rather than lookup
    • Adding controls to loops
    • Migrating from with_X to loop
  • Controlling where tasks run: delegation and local actions
    • Tasks that cannot be delegated
    • Delegating tasks
    • Delegating facts
    • Local playbooks
  • Conditionals
    • Basic conditionals with when
    • Commonly-used facts
  • Tests
    • Test syntax
    • Testing strings
    • Vault
    • Testing truthiness
    • Comparing versions
    • Set theory tests
    • Testing if a list contains a value
    • Testing if a list value is True
    • Testing paths
    • Testing size formats
    • Testing task results
  • Blocks
    • Grouping tasks with blocks
    • Handling errors with blocks
  • Handlers: running operations on change
    • Handler example
    • Controlling when handlers run
    • Using variables with handlers
  • Error handling in playbooks
    • Ignoring failed commands
    • Ignoring unreachable host errors
    • Resetting unreachable hosts
    • Handlers and failure
    • Defining failure
    • Defining “changed”
    • Ensuring success for command and shell
    • Aborting a play on all hosts
    • Controlling errors in blocks
  • Setting the remote environment
    • Setting the remote environment in a task
  • Working with language-specific version managers
  • Re-using Ansible artifacts
    • Creating re-usable files and roles
    • Re-using playbooks
    • Re-using files and roles
    • Re-using tasks as handlers
  • Roles
    • Role directory structure
    • Storing and finding roles
    • Using roles
    • Running a role multiple times in one playbook
    • Using role dependencies
    • Embedding modules and plugins in roles
    • Sharing roles: Ansible Galaxy
  • Including and importing
  • Tags
    • Adding tags with the tags keyword
    • Special tags: always and never
    • Selecting or skipping tags when you run a playbook
  • How to build your inventory
    • Inventory basics: formats, hosts, and groups
    • Adding variables to inventory
    • Assigning a variable to one machine: host variables
    • Assigning a variable to many machines: group variables
    • Organizing host and group variables
    • How variables are merged
    • Using multiple inventory sources
    • Connecting to hosts: behavioral inventory parameters
    • Inventory setup examples
  • Working with dynamic inventory
    • Inventory script example: Cobbler
    • Inventory script example: OpenStack
    • Other inventory scripts
    • Using inventory directories and multiple inventory sources
    • Static groups of dynamic groups
  • Patterns: targeting hosts and groups
    • Using patterns
    • Common patterns
    • Limitations of patterns
    • Advanced pattern options
    • Patterns and ansible-playbook flags
  • Connection methods and details
    • ControlPersist and paramiko
    • Setting a remote user
    • Setting up SSH keys
    • Running against localhost
    • Managing host key checking
    • Other connection methods
  • Working with command line tools
    • ansible
    • ansible-config
    • ansible-console
    • ansible-doc
    • ansible-galaxy
    • ansible-inventory
    • ansible-playbook
    • ansible-pull
    • ansible-vault
  • Using Variables
    • Creating valid variable names
    • Simple variables
    • When to quote variables (a YAML gotcha)
    • List variables
    • Dictionary variables
    • Registering variables
    • Referencing nested variables
    • Transforming variables with Jinja2 filters
    • Where to set variables
    • Variable precedence: Where should I put a variable?
    • Using advanced variable syntax
  • Discovering variables: facts and magic variables
    • Ansible facts
    • Information about Ansible: magic variables
  • Encrypting content with Ansible Vault
    • Managing vault passwords
    • Encrypting content with Ansible Vault
    • Using encrypted variables and files
    • Configuring defaults for using encrypted content
    • When are encrypted files made visible?
    • Speeding up Ansible Vault
    • Format of files encrypted with Ansible Vault
  • Using filters to manipulate data
    • Handling undefined variables
    • Defining different values for true/false/null (ternary)
    • Managing data types
    • Formatting data: YAML and JSON
    • Combining and selecting data
    • Randomizing data
    • Managing list variables
    • Selecting from sets or lists (set theory)
    • Calculating numbers (math)
    • Managing network interactions
    • Encrypting and checksumming strings and passwords
    • Manipulating text
    • Manipulating strings
    • Managing UUIDs
    • Handling dates and times
    • Getting Kubernetes resource names
  • Lookups
    • Using lookups in variables
  • Interactive input: prompts
    • Encrypting values supplied by vars_prompt
    • Allowing special characters in vars_prompt values
  • Module defaults
    • Module defaults groups
  • Validating tasks: check mode and diff mode
    • Using check mode
    • Using diff mode
  • Executing playbooks for troubleshooting
    • start-at-task
    • Step mode
  • Debugging tasks
    • Enabling the debugger
    • Resolving errors in the debugger
    • Available debug commands
    • How the debugger interacts with the free strategy
  • Controlling playbook execution: strategies and more
    • Selecting a strategy
    • Setting the number of forks
    • Using keywords to control execution
  • Asynchronous actions and polling
    • Asynchronous ad-hoc tasks
    • Asynchronous playbook tasks
  • Advanced Syntax
    • Unsafe or raw strings
    • YAML anchors and aliases: sharing variable values
  • Data manipulation
    • Loops and list comprehensions
    • Complex Type transformations
  • Blacklisting modules
  • Sample Ansible setup
    • Sample directory layout
    • Alternative directory layout
    • Sample group and host variables
    • Sample playbooks organized by function
    • Sample task and handler files in a function-based role
    • What the sample setup enables
    • Organizing for deployment or configuration
    • Using local Ansible modules
  • Working With Modules
    • Introduction to modules
    • Module Maintenance & Support
    • Return Values
  • Working With Plugins
    • Action Plugins
    • Become Plugins
    • Cache Plugins
    • Callback Plugins
    • Cliconf Plugins
    • Connection Plugins
    • Httpapi Plugins
    • Inventory Plugins
    • Lookup Plugins
    • Netconf Plugins
    • Shell Plugins
    • Strategy Plugins
    • Vars Plugins
    • Using filters to manipulate data
    • Tests
    • Blacklisting modules
  • Playbook Keywords
    • Play
    • Role
    • Block
    • Task
  • Ansible and BSD
    • Connecting to BSD nodes
    • Bootstrapping BSD
    • Setting the Python interpreter
    • Which modules are available?
    • Using BSD as the control node
    • BSD facts
    • BSD efforts and contributions
  • Windows Guides
    • Setting up a Windows Host
    • Windows Remote Management
    • Using Ansible and Windows
    • Desired State Configuration
    • Windows performance
    • Windows Frequently Asked Questions
  • Using collections
    • Installing collections
    • Downloading collections
    • Listing collections
    • Verifying collections
    • Using collections in a Playbook
    • Simplifying module names with the collections keyword

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.10/user_guide/index.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API