1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-27 09:25:10 +03:00
awx/docs/overview.md

142 lines
5.6 KiB
Markdown
Raw Normal View History

2019-09-17 22:49:01 +03:00
# AWX
AWX provides a web interface and distributed task engine for scheduling and
running Ansible playbooks. As such, it relies heavily on the interfaces
provided by Ansible. This document provides a birds-eye view of the notable
2019-09-17 22:49:01 +03:00
touchpoints between AWX and Ansible.
## Terminology
2019-09-17 22:49:01 +03:00
AWX has a variety of concepts which map to components of Ansible, or
which further abstract them to provide functionality on top of Ansible. A few
of the most notable ones are:
2019-09-17 22:49:01 +03:00
### Projects
2019-09-17 22:49:01 +03:00
Projects represent a collection of Ansible playbooks. Most AWX users create
2020-12-01 22:06:34 +03:00
Projects that import periodically from source control systems (such as git
or subversion repositories). This import is accomplished via an
2019-09-17 22:49:01 +03:00
Ansible playbook included with AWX (which makes use of the various source
control management modules in Ansible).
2019-09-17 22:49:01 +03:00
### Inventories
2019-09-17 22:49:01 +03:00
AWX manages Inventories, Groups, and Hosts, and provides a RESTful interface
that maps to static and dynamic Ansible inventories. Inventory data can
2019-09-17 22:49:01 +03:00
be entered into AWX manually, but many users perform Inventory Syncs to import
inventory data from a variety of external sources.
2019-09-17 22:49:01 +03:00
### Job Templates
2019-09-17 22:49:01 +03:00
A Job Template is a definition and set of parameters for running
`ansible-playbook`. If defines metadata about a given playbook run, such as:
* a named identifier
* an associated inventory to run against
* the project and `.yml` playbook to run
2019-09-17 22:49:01 +03:00
* a variety of other options which map directly to `ansible-playbook`
arguments (`extra_vars`, verbosity, forks, limit, etc...)
### Credentials
2019-09-17 22:49:01 +03:00
AWX stores sensitive credential data which can be attached to `ansible-playbook`
processes that it runs. This data can be oriented towards SSH connection
2019-09-23 16:46:54 +03:00
authentication (usernames, passwords, SSH keys and passphrases),
2019-09-17 22:49:01 +03:00
Ansible-specific prompts (such as Vault passwords), or environmental
authentication values which various Ansible modules depend on (such as setting
`AWS_ACCESS_KEY_ID` in an environment variable, or specifying
`ansible_ssh_user` as an extra variable).
2019-09-17 22:49:01 +03:00
## Canonical Example
2019-09-17 22:49:01 +03:00
Bringing all of this terminology together, a "Getting Started Using AWX" might
involve:
2019-09-17 22:49:01 +03:00
* Creating a new Project that imports playbooks from, for example, a remote git repository
* Manually creating or importing an Inventory which defines where the playbook(s) will run
* Optionally, saving a Credential which contains SSH authentication details for
the host(s) where the playbook will run
* Creating a Job Template that specifies which Project and playbook to run and
2019-09-17 22:49:01 +03:00
where to run it (Inventory), and any necessary Credentials (*e.g.*, SSH
authentication)
* Launching the Job Template and viewing the results
2019-09-17 22:49:01 +03:00
## AWX's Interaction with Ansible
The touchpoints between AWX and Ansible are mostly encompassed by
everything that happens *after* a job is started in AWX. Specifically, this
includes:
* Any time a Job Template is launched
* Any time a Project Update is performed
* Any time an Inventory Sync is performed
* Any time an Adhoc Command is run
2019-09-17 22:49:01 +03:00
### Spawning Ansible Processes
2019-09-17 22:49:01 +03:00
AWX relies on a handful of stable interfaces in its interaction with Ansible.
The first of these are the actual CLI for `ansible-playbook` and
`ansible-inventory`.
2019-09-17 22:49:01 +03:00
When a Job Template or Project Update is run in AWX, an actual
`ansible-playbook` command is composed and spawned in a pseudoterminal on one
2019-09-17 22:49:01 +03:00
of the servers/containers that make up the AWX installation. This process runs
until completion (or until a configurable timeout), and the return code,
2019-09-17 22:49:01 +03:00
`stdout`, and `stderr` of the process are recorded in the AWX database. Ad hoc
commands work the same way, though they spawn `ansible` processes instead of
`ansible-playbook`.
Similarly, when an Inventory Sync runs, an actual `ansible-inventory` process
2019-09-17 22:49:01 +03:00
runs, and its output is parsed and persisted into the AWX database as Hosts and
Groups.
2019-09-17 22:49:01 +03:00
AWX relies on stability in CLI behavior to function properly across Ansible
releases; this includes the actual CLI arguments _and_ the behavior of task
2019-09-17 22:49:01 +03:00
execution and prompts (such as password, `become`, and Vault prompts).
### Capturing Event Data
2019-09-17 22:49:01 +03:00
AWX applies an Ansible callback plugin to all `ansible-playbook` and `ansible`
processes it spawns. This allows Ansible events to be captured and persisted
2019-09-17 22:49:01 +03:00
into the AWX database; this process is what drives the "streaming" web UI
you'll see if you launch a job from the AWX web interface and watch its results
appears on the screen. AWX relies on stability in this plugin interface, the
heirarchy of emitted events based on strategy, and _especially_ the structure
of event data to work across Ansible releases:
![Event Data Diagram](https://user-images.githubusercontent.com/722880/35641610-ae7f1dea-068e-11e8-84fb-0f96043d53e4.png)
2019-09-17 22:49:01 +03:00
### Fact Caching
2019-09-17 22:49:01 +03:00
AWX provides a custom fact caching implementation that allows users to store
facts for playbook runs across subsequent Job Template runs. Specifically, AWX
makes use of the `jsonfile` fact cache plugin; after `ansible-playbook` runs
2019-09-17 22:49:01 +03:00
have exited, AWX consumes the entire `jsonfile` cache and persists it in the
AWX database. On subsequent Job Template runs, prior `jsonfile` caches are
restored to the local file system so the new `ansible-playbook` process makes
use of them.
2019-09-17 22:49:01 +03:00
### Environment-Based Configuration
2019-09-17 22:49:01 +03:00
AWX injects credentials and module configuration for a number of Ansible
modules via environment variables. Examples include:
* `ANSIBLE_NET_*` and other well-known environment variables for network device authentication
* API keys and other credential values which are utilized
(`AWS_ACCESS_KEY_ID`, `GCE_EMAIL`, etc...)
* SSH-oriented configuration flags, such as `ANSIBLE_SSH_CONTROL_PATH`
2019-09-17 22:49:01 +03:00
AWX relies on stability in these configuration options to reliably support
credential injection for supported Ansible modules.