9.1 Automation, Orchestration & Configuration Management (Ansible, Puppet, OpenTofu)

Key Takeaways

  • Use Ansible inventory and modules to manage a defined target set. A handler depends on a reported change and the play’s execution context.

  • Puppet agents apply catalogs compiled for their nodes. OpenTofu providers manage infrastructure and record resource identity in state.

  • Use Kickstart for an applicable installer and cloud-init for a supported image and datasource. Verify unattended update policy separately.

  • Test changes early, review release evidence, and check actual rollout state. GitOps continuously reconciles versioned desired state.

  • Inspect the appropriate units of work and networking for Compose projects, Swarm tasks or Kubernetes Pods.

Last updated: November 2026

Automation, Orchestration and Configuration Management

Automation makes a task repeatable. Orchestration coordinates tasks and dependencies, such as draining traffic, updating a service, checking readiness and returning it to rotation. An automation task can target many hosts. Choose the mechanism by the resources it owns, how it communicates and how it reports failures.

A declarative resource specifies the intended state. An imperative task specifies an operation. Idempotence means a repeated operation has the same intended effect once it has converged. A playbook can combine idempotent modules with commands that make a change on every run. Review each task and test a second run against the same initial result.

SituationSuitable starting point
Install a package and reconcile files from a control hostAnsible inventory, modules and playbooks
Have enrolled hosts periodically converge on a compiled configurationPuppet agent and server
Provision resources and track their identity across provider API callsOpenTofu configuration, providers and state
Install an operating system with repeatable installer inputsKickstart for the applicable Anaconda-based installer
Configure an instance from image and platform metadata at bootcloud-init with the image’s supported datasource
Start a multi-container lab from one project definitionDocker Compose or a supported Podman Compose provider
Maintain service replicas across multiple nodesKubernetes Deployment or Docker Swarm service

Ansible inventory, modules and playbooks

Ansible commonly pushes tasks to Linux hosts over SSH from a control node. The targets typically need a supported Python for most modules. Agentless here means they do not need a resident Ansible agent. Connection plugins can use other transports or run locally, and ansible.builtin.raw can run without target Python. Pull arrangements also exist. Check host identity and authorized credentials independently of reachability.

An inventory defines host and group names, connection variables and other settings. It can combine multiple sources, including INI, YAML and dynamic plugins. For example:

[webservers]
web1.example.test ansible_host=192.0.2.10
web2.example.test ansible_host=192.0.2.11

[webservers:vars]
ansible_user=lab-admin

Use an ad hoc command for a single module call. With the intended inventory and a matching connection plugin, ansible webservers -i inventory.ini -m ansible.builtin.ping verifies login and a usable Python for that module. It does not send an ICMP probe. ansible.builtin.setup collects system facts. A play can gather facts, and service state requires distinct evidence such as ansible.builtin.service_facts. On supported DNF hosts, ansible webservers -i inventory.ini -m ansible.builtin.dnf -a 'name=nginx state=present' --become requests package installation; escalation depends on the configured method, identity and authorization.

A playbook maps plays to target hosts and tasks. In this lab, the remote account can write inside its home directory and no privilege escalation is needed:

---
- name: Set the lab reporting format
  hosts: webservers
  tasks:
    - name: Write the lab configuration
      ansible.builtin.copy:
        content: "report_format=json\n"
        dest: "{{ ansible_facts['user_dir'] }}/linuxplus-report.conf"
        mode: "0600"
      notify: Report configuration change

  handlers:
    - name: Report configuration change
      ansible.builtin.debug:
        msg: Reporting configuration changed

The copy task should report a change on an empty target and no change on a second run when the content and permissions match. Ansible notifies the handler when the task reports a change and normally runs notified handlers at defined points in the play. A later failure can skip pending handlers on that host. A service restart handler should follow review and validation of the configuration. Syntax-check with ansible-playbook -i inventory.ini site.yml --syntax-check. Preview supported tasks with --check, review tasks explicitly overriding check mode, then prove convergence on a disposable host.

Roles organize related tasks, files, variables and handlers. Collections distribute namespaced modules, plugins and roles such as ansible.posix. Use the documented fully qualified collection name and pin reviewed dependencies. Ansible Vault protects variables and files at rest. Programs that use the decrypted values can still reveal them in logs or diffs. Scope access and avoid publishing secret-bearing artifacts.

Puppet catalogs and OpenTofu state

In a Puppet agent/server deployment, Facter collects values such as OS and network facts. The agent requests a catalog using the configured certificate identity and sends facts. The server compiles Puppet manifests and classes, facts and other data into a catalog for the node. Entries in the catalog describe resources and their relationships. The agent applies it and can report outcomes. Review certificate issuance and trust, and check the actual run schedule. puppet apply compiles and applies locally without a central server. Puppet's Bolt offers agentless remote task orchestration.

A manifest commonly has a .pp suffix. A class groups related resources, and a module can package classes, templates and files. On a disposable Puppet lab node, the following class manages the directory before the file:

class lab_report {
  file { '/var/tmp/lab-report':
    ensure => directory,
    mode   => '0750',
  }

  file { '/var/tmp/lab-report/format':
    ensure  => file,
    content => "json\n",
    require => File['/var/tmp/lab-report'],
  }
}
include lab_report

require is an ordering dependency. A notification relationship such as subscribe can also trigger a refresh on a change; the receiving resource's type and provider determine how it responds. Compare Puppet’s no-op result with a lab apply.

OpenTofu providers implement resource types and interact with systems such as cloud or virtualization APIs. A resource block declares a managed instance, while state associates that instance with the actual object. The local backend’s default is terraform.tfstate. Some operations use a remote backend and may lock when that backend supports locking. Use access control and concurrency protections appropriate to the backend. State and saved plans can include sensitive values.

A lab can demonstrate the plan lifecycle with the built-in terraform_data resource, which requires no external provider plugin:

resource "terraform_data" "report_format" {
  input = "json"
}

In a disposable directory, tofu init prepares the configuration and backend. Run tofu plan to review the proposed resource addition. An ordinary plan can consult provider APIs and does not execute the planned create, update or delete. A speculative plan can change as infrastructure and inputs change. A reviewed tofu plan -out=lab.plan can be applied with tofu apply lab.plan subject to authorization and current state. In this fixture, a second plan should report no change after a successful apply with the same inputs. In a real environment, review dependency impact and state scope before applying a plan or issuing tofu destroy.

Unattended provisioning and package updates

On RHEL 9, Kickstart supplies Anaconda installer settings, including locale, storage and packages. A boot option such as inst.ks=https://install.example.test/lab.ks can locate the Kickstart file. %packages lists packages and groups. %pre runs before installation, and %post runs after installation in the target chroot by default. Validate the release-specific file, explicitly scope disks and test in a disposable VM. Partition operations can erase existing data.

Cloud-init reads user data and metadata from a datasource supported by the image and platform. A standalone cloud-config payload starts with #cloud-config. MIME multipart can identify a part by its media type. Module stage and frequency determine which settings run during boot and when a new instance triggers them again. For an image with cloud-init, a small data-only lab payload is:

#cloud-config
write_files:
  - path: /var/lib/cloud/linuxplus-lab.marker
    permissions: "0644"
    content: "report_format=json"

Validate the payload with the installed cloud-init schema tooling and verify the marker and cloud-init status inside the test VM. Avoid storing secrets in user data or logs. An unattended package update mechanism is a separate control after provisioning. For example, Ubuntu Server uses unattended-upgrades with APT policy and timers. RHEL 9 documents dnf-automatic and timer variants that can only notify, download, or install. Inspect the actual policy, approved origins, update result and reboot handling for that distribution.

Delivery, deployment and reconciliation

Continuous integration runs repeatable checks against integrated changes. Continuous delivery keeps a release eligible for deployment and can include an approval. Continuous deployment automatically releases passing changes under the configured policy. A useful pipeline validates syntax, tests behavior and scans configuration and artifacts early, then proceeds to approved rollout and post-deployment checks. Shift-left testing moves evidence collection earlier. DevSecOps integrates security work throughout this lifecycle, including dependency review, provenance and operational follow-up.

In GitOps, operators declare desired state in a versioned store. Agents pull it and continuously reconcile actual state to it. A CI job can build an image and propose a desired-state change. The reconciliation controller then owns rollout, observes divergence and reports failures. For example, test an image in CI, review an immutable image reference in the desired-state repository, then check rollout and user-facing health. A passing pipeline is evidence about its tests.

Container orchestration

PlatformDesired state and inspection
KubernetesA Pod is the deployable unit for one or more containers. A Deployment manages replicas through ReplicaSets and coordinates rollouts. A Service provides stable access to a set of endpoints. Use labels and selectors to connect the objects.
Docker SwarmA service defines the workload. Managers schedule tasks on nodes, and workers execute them. For a replicated service, scaling changes the desired task count. An overlay network can connect workloads across nodes.
Docker or Podman ComposeA Compose file defines a project’s services, volumes and networks. A CLI creates the project and reports its logs. With podman compose, an installed external provider determines supported commands and flags.

In Kubernetes, create a ConfigMap for nonconfidential configuration and a Secret for approved sensitive data. Workloads can consume values as environment variables or mounted files. Secret data encoding alone provides no encryption; use least-privilege access and appropriate at-rest encryption. Volumes have a lifecycle and storage backend that depends on the volume type. For example, use a Deployment for three interchangeable reporting Pods, a Service to reach the ready endpoints and a persistent claim only when the workload needs persistent storage. Check kubectl rollout status deployment/report and inspect Pods and Service endpoints before declaring success.

In a Swarm lab, use a manager to run docker service scale report=3 for an existing replicated service. Inspect task state with docker service ps report. A pending task can signal placement, capacity or registry access problems. A replacement task gets a new scheduling decision. Check whether storage is node-local before relying on data across rescheduling.

In a Compose lab, inspect the rendered file with docker compose config. docker compose up -d starts the defined project, docker compose logs worker reads output for its worker service, and docker compose down removes project containers and applicable networks. Docker Compose ordinarily preserves named volumes on down; down -v can remove project volumes. For a matching Podman provider, verify equivalent behavior and options with its help. Use logs and a lab health check to verify the application after starting.

Test Your Knowledge

An Ansible controller can reach the RHEL 9 hosts in the webservers group in inventory.ini. These hosts have the supported DNF module dependencies and approved become access. Which ad hoc command requests Nginx to be installed for that group?

A

ansible webservers -i inventory.ini -a "systemctl start nginx"

B

ansible webservers -i inventory.ini -m ansible.builtin.dnf -a "name=nginx state=present" --become

C

ansible-playbook webservers -m dnf -e "name=nginx state=present"

D

ansible all -i inventory.ini -m ansible.builtin.dnf -a "name=nginx state=present"

Test Your Knowledge

An initialized OpenTofu workspace has reviewed provider settings. An engineer wants to preview proposed create, update, and delete actions without executing them or saving a plan artifact. Which command is appropriate?

A

tofu plan

B

tofu apply -auto-approve

C

tofu init -upgrade

D

tofu refresh

Test Your Knowledge

An image supports cloud-init. You will provide one standalone user-data file as cloud-config YAML, without a multipart MIME wrapper. Which first line identifies that format?

A

#!/bin/bash

B

%packages --ignoremissing

C

#cloud-config

D

---

Sections you finish are checked off in the contents.