Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EE docs #18

Merged
merged 35 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3be2946
Add EE documents
Andersson007 Jun 22, 2023
44a8719
Add Getting started with EE and Building and testing EE guide
Andersson007 Jun 22, 2023
0bae5cd
add to another toctree
Andersson007 Jun 22, 2023
efd310e
separate ee getting started
oraNod Jun 23, 2023
f42e6d8
Misc fixes
Andersson007 Jun 26, 2023
3909182
Fix
Andersson007 Jun 26, 2023
7693e36
Update docs/docsite/rst/getting_started_ee/index.rst
Andersson007 Jun 26, 2023
6fe13b8
Update docs/docsite/rst/getting_started_ee/introduction.rst
Andersson007 Jun 26, 2023
3a93058
Update docs/docsite/rst/getting_started_ee/introduction.rst
Andersson007 Jun 26, 2023
68b4a22
Update docs/docsite/rst/getting_started_ee/introduction.rst
Andersson007 Jun 28, 2023
a36372a
Update docs/docsite/rst/getting_started_ee/introduction.rst
Andersson007 Jun 28, 2023
d11e287
Update docs/docsite/rst/getting_started_ee/introduction.rst
Andersson007 Jun 28, 2023
c1aeb21
Update docs/docsite/rst/getting_started_ee/introduction.rst
Andersson007 Jun 28, 2023
6a48a54
Update docs/docsite/rst/getting_started_ee/introduction.rst
Andersson007 Jun 28, 2023
e603362
Update docs/docsite/rst/getting_started_ee/introduction.rst
Andersson007 Jun 28, 2023
ebf06b3
Update docs/docsite/rst/getting_started_ee/introduction.rst
Andersson007 Jun 28, 2023
9cb50ec
Update docs/docsite/rst/getting_started_ee/introduction.rst
Andersson007 Jun 28, 2023
6947795
Update docs/docsite/rst/getting_started_ee/setup_environment.rst
Andersson007 Jun 28, 2023
1b88b46
Update docs/docsite/rst/getting_started_ee/introduction.rst
Andersson007 Jun 28, 2023
23f3ed6
Update docs/docsite/rst/getting_started_ee/introduction.rst
Andersson007 Jun 28, 2023
14f1bb0
Update docs/docsite/rst/getting_started_ee/build_execution_environmen…
Andersson007 Jun 28, 2023
fd97b55
Update docs/docsite/rst/getting_started_ee/build_execution_environmen…
Andersson007 Jun 28, 2023
9a567ea
Remove doc reporting note
Andersson007 Jun 28, 2023
db3f04a
Change header style
Andersson007 Jun 28, 2023
c788908
Remove upgrading pip; add ansible-builder installation command
Andersson007 Jun 28, 2023
bb3b898
Bulding EE: add a link to builder doc
Andersson007 Jun 28, 2023
28ea7c7
Add list of tools for ee link
Andersson007 Jun 28, 2023
935dfa4
Add a note that there are other tools you can run EE with
Andersson007 Jun 28, 2023
a52ff4c
Update docs/docsite/rst/getting_started_ee/introduction.rst
Andersson007 Jun 28, 2023
95b21a4
Remove hundreds of collections
Andersson007 Jun 28, 2023
1d3a823
Change wording
Andersson007 Jun 28, 2023
88dd8f3
Change headers
Andersson007 Jun 28, 2023
2dfb113
Update docs/docsite/rst/core_index.rst
oraNod Jul 10, 2023
d118acc
orphan for core index
oraNod Jul 10, 2023
1f35777
sphinx_conf/core_[lang_]conf.py: Add the files to exclude section
Andersson007 Jul 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/docsite/rst/ansible_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Ansible releases a new major release approximately twice a year. The core applic
:caption: Ansible getting started

getting_started/index
getting_started_ee/index

.. toctree::
:maxdepth: 2
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.. _building_execution_environments:

Building your first EE
======================

We are going to build an EE that represents an Ansible control node containing standard packages such as ``ansible-core`` and Python in addition to
an Ansible collection (``community.postgresql``) and its dependency (the ``psycopg2-binary`` Python connector).

To build your first EE:

1. Create a project folder on your filesystem.

.. code-block:: bash

mkdir my_first_ee && cd my_first_ee

2. Create a ``execution-environment.yml`` file that specifies dependencies to include in the image.

.. code-block:: yaml

cat > execution-environment.yml<<EOF
---
version: 3

dependencies:
galaxy:
collections:
- name: community.postgresql
EOF

.. note::

The ``psycopg2-binary`` Python package is included in the ``requirements.txt`` file for the collection.
For collections that do not include ``requirements.txt`` files, you need to specify Python dependencies explicitly.
See the `Ansible Builder documentation <https://ansible-builder.readthedocs.io/en/stable/definition/>`_ for details.

3. Build a EE container image called ``postgresql_ee``. If you use docker, add the ``--container-runtime docker`` argument.

.. code-block:: bash

ansible-builder build --tag postgresql_ee

4. List container images to verify that you built it successfully.

.. code-block:: bash

podman image list

localhost/postgresql_ee latest 2e866777269b 6 minutes ago 1.11 GB

You can verify the image you created by inspecting the ``Containerfile`` or ``Dockerfile`` in the ``context`` directory to view its configuration.

.. code-block:: bash

less context/Containerfile

You can also use Ansible Navigator to view detailed information about the image.

Run the ``ansible-navigator`` command, type ``:images`` in the TUI, and then choose ``postgresql_ee``.

Proceed to :ref:`Running your EE<running_execution_environments>` and test the EE you just built.
33 changes: 33 additions & 0 deletions docs/docsite/rst/getting_started_ee/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
:orphan:

.. _getting_started_ee_index:

*******************************************
Getting started with Execution Environments
*******************************************

You can run Ansible automation in containers, like any other modern software application.
Ansible uses container images known as execution environments (EE) that act as control nodes.

An execution environment image contains the following packages as standard:

* ``ansible-core``
* ``ansible-runner``
* Python
* Ansible content dependencies

In addition to the standard packages, an EE can also contain:

* one or more Ansible collections and their dependencies
* other custom components

This getting started guide shows you how to build and test a simple execution environment.
The resulting container image represents an Ansible control node that contains the standard EE packages plus the ``community.postgresql`` collection and the ``psycopg2-binary`` Python package.

.. toctree::
:maxdepth: 1

introduction
setup_environment
build_execution_environment
run_execution_environment
64 changes: 64 additions & 0 deletions docs/docsite/rst/getting_started_ee/introduction.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.. _introduction_execution_environments:

Introduction to execution environments
======================================

Ansible execution environments aim to resolve complexity issues and provide all the benefits you can get from containerization.

Reducing complexity
-------------------

There are three main areas where EEs can reduce complexity: software dependencies, portability, and content separation.

Dependencies
^^^^^^^^^^^^

Software applications typically have dependencies, and Ansible is no exception.
These dependencies can include software libraries, configuration files or other services, to name a few.

Traditionally, administrators install application dependencies on top of an operating system using packaging management tools such as RPM or Python-pip.

The major drawback of such an approach is that an application might require versions of dependencies different from those provided by default.

For Ansible, a typical installation consists of ``ansible-core`` and a set of Ansible collections.
Many of them have dependencies for the plugins, modules, roles and playbooks they provide.

The Ansible collections can depend on the following pieces of software and their versions:

* ``ansible-core``
* Python
* Python packages
* System packages
* Other Ansible collections

The dependencies have to be installed and sometimes can conflict with each other.

One way to **partially** resolve dependency issue is to use Python virtual environments on Ansible control nodes.
However, applied to Ansible, virtual environments have drawbacks and natural limitations.

Portability
^^^^^^^^^^^

An Ansible user writes content for Ansible locally and wants to leverage the container technology to make their automation runtimes portable, shareable and easily deployable to testing and production environments.

Content separation
^^^^^^^^^^^^^^^^^^

In situations when there is an Ansible control node or a tool such as Ansible AWX/Controller used by several users, they might want separate their content to avoid configuration and dependency conflicts.

.. _ansible_tooling_for_ee:

Ansible tooling for EEs
-----------------------

Projects in the Ansible ecosystem also provide lots of tooling that you can use with EEs, such as:

* `Ansible Builder <https://ansible-builder.readthedocs.io/en/stable/>`_
* `Ansible Navigator <https://ansible-navigator.readthedocs.io/>`_
* `Ansible AWX <https://docs.ansible.com/automation-controller/latest/html/userguide/execution_environments.html#use-an-execution-environment-in-jobs>`_
* `Automation controller <https://docs.ansible.com/automation-controller/latest/html/userguide/execution_environments.html#use-an-execution-environment-in-jobs>`_
* `Ansible Runner <https://ansible-runner.readthedocs.io/en/stable/>`_
* VS Code `Ansible <https://marketplace.visualstudio.com/items?itemName=redhat.ansible>`_ and `Dev Containers <https://code.visualstudio.com/docs/devcontainers/containers>`_ extensions

Ready to get started with EEs?
Proceed to :ref:`Setting up your environment<setting_up_environment>`.
94 changes: 94 additions & 0 deletions docs/docsite/rst/getting_started_ee/run_execution_environment.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
.. _running_execution_environments:

Running your EE
===============

You can run your EE on the command line against ``localhost`` or a remote target
using ``ansible-navigator``.

.. note::

There are other tools besides ``ansible-navigator`` you can run EEs with.

Run against localhost
---------------------

1. Create a ``test_localhost.yml`` playbook.

.. code-block:: yaml

cat > test_localhost.yml<<EOF
---
- hosts: localhost
become: yes
gather_facts: yes
tasks:
- name: Print facts
ansible.builtin.debug:
msg: '{{ ansible_facts }}'
EOF

2. Run the playbook inside the ``postgresql_ee`` EE.

.. code-block:: bash

ansible-navigator run test_localhost.yml --execution-environment-image postgresql_ee --mode stdout --pull-policy missing

You may notice the facts being gathered are about the container and not the developer machine.
This is because the ansible playbook was run inside the container.

Run against a remote target
---------------------------

In this example, you execute a playbook inside the ``postgresql_ee`` EE against a remote host machine.
Before you start, ensure you have the following:

* At least one IP address or resolvable hostname for a remote target.
* Valid credentials for the remote host.
* A user with ``sudo`` permissions on the remote host.

1. Create a directory for inventory files.

.. code-block:: yaml

mkdir inventory

2. Create the ``hosts.yml`` inventory file in the ``inventory`` directory.

.. code-block:: yaml

cat > inventory/hosts.yml<<EOF
---
all:
hosts:
192.168.0.2 # Replace with the IP of your target host
EOF

3. Create a ``test_remote.yml`` playbook.

.. code-block:: yaml

cat > test_remote.yml<<EOF
---
- hosts: all
become: yes
gather_facts: yes
tasks:
- name: Print facts
ansible.builtin.debug:
msg: '{{ ansible_facts }}'
EOF

4. Run the playbook inside the ``postgresql_ee`` EE. Replace ``student`` with the appropriate user name.

.. code-block:: bash

ansible-navigator run test_remote.yml -i inventory --execution-environment-image postgresql_ee:latest --mode stdout --pull-policy missing --enable-prompts -u student -k -K

What to read next
-----------------

* More about the `EE definition file <https://ansible-builder.readthedocs.io/en/stable/definition/>`_ and available options.
* `Ansible Builder CLI usage <https://ansible-builder.readthedocs.io/en/stable/usage/>`_.
* `Ansible Navigator official documentation <https://ansible-navigator.readthedocs.io/>`_.
* :ref:`The list of tools for EE<ansible_tooling_for_ee>`
42 changes: 42 additions & 0 deletions docs/docsite/rst/getting_started_ee/setup_environment.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.. _setting_up_environment:

Setting up your environment
===========================

Complete the following steps to set up a local environment for your first execution environment:

1. Ensure the following packages are installed on your system:

* ``podman`` or ``docker``
* ``python3``

If you use the DNF package manager, install these prerequisites as follows:

.. code-block:: bash

sudo dnf install -y podman python3

2. Install ``ansible-navigator``:

.. code-block:: bash

pip3 install ansible-navigator

Installing ``ansible-navigator`` lets you run EEs on the command line.
It includes the ``ansible-builder`` package to build EEs.

If you want to build EEs without testing, install only ``ansible-builder``:

.. code-block:: bash

pip3 install ansible-builder

3. Verify your environment with the following commands:

.. code-block:: bash

ansible-navigator --version
ansible-builder --version

Ready to build your first EE?
Proceed to :ref:`Building your first EE<building_execution_environments>`
5 changes: 5 additions & 0 deletions docs/docsite/sphinx_conf/core_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@
'dev_guide/platforms/ovirt_dev_guide.rst',
'dev_guide/platforms/vmware_guidelines.rst',
'dev_guide/platforms/vmware_rest_guidelines.rst',
'getting_started_ee/build_execution_environment.rst',
'getting_started_ee/index.rst',
'getting_started_ee/introduction.rst',
'getting_started_ee/run_execution_environment.rst',
'getting_started_ee/setup_environment.rst',
'porting_guides/porting_guides.rst',
'porting_guides/porting_guide_[1-9]*',
'roadmap/index.rst',
Expand Down
5 changes: 5 additions & 0 deletions docs/docsite/sphinx_conf/core_lang_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@
'dev_guide/platforms/ovirt_dev_guide.rst',
'dev_guide/platforms/vmware_guidelines.rst',
'dev_guide/platforms/vmware_rest_guidelines.rst',
'getting_started_ee/build_execution_environment.rst',
'getting_started_ee/index.rst',
'getting_started_ee/introduction.rst',
'getting_started_ee/run_execution_environment.rst',
'getting_started_ee/setup_environment.rst',
'porting_guides/porting_guides.rst',
'porting_guides/porting_guide_[1-9]*',
'roadmap/index.rst',
Expand Down