RousselTMLEARNING

TP · Vagrant: From Discovery to Expertise

Lab: Ansible provisioning and snapshots

What you will learn in this TP
  • Write a provisioning playbook
  • Use ansible_local
  • Protect experiments with a snapshot

Local Ansible #

What you will learn in this section
  • Write a provisioning playbook
  • Use ansible_local
  • Protect experiments with a snapshot

Context. Shell provisioning scripts quickly become unreadable. Using Ansible as the provisioner provides a declarative language, reusable later in production, and snapshots let you experiment without fear of breaking everything.

Prerequisites: Previous labs, Ansible basics  ·  Estimated time: 40 min

Provision without installing Ansible on the host.
  1. 1. Write a playbook

    Why? A playbook describes the desired state (nginx installed and started) rather than commands: it can be reread and replayed without side effects.

    Create provision/site.yml that installs nginx and publishes a home page.
  2. 2. Wire the provisioner

    Why? Local mode installs Ansible inside the VM: no host prerequisites, so it works the same on Linux, macOS and Windows.

    Use the ansible_local provisioner (Ansible is installed inside the VM).
  3. 3. Snapshots before a risky change

    Why? A snapshot is a near-instant restore point: it lets you test a risky operation and return in seconds.

    Take a snapshot, deliberately break nginx then restore.
  4. 4. Check idempotency

    Why? A second run with no change must show changed=0; that is the criterion proving the playbook is idempotent.

    Re-run provisioning: how many tasks are changed?

Difficulty level : ●●●○○ (3/5)

My progress

  • ⏱ Estimated time : ≈ 40 min

Sign in to track your progress and take notes. Sign in

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

Recommended Articles

Vagrant best practices: reproducible and fast environments

Vagrant best practices: versioned Vagrantfile, pinned boxes, idempotent provisioning, multi-machi...

Vagrant plugins: extending providers, provisioners and commands

Understand Vagrant's plugin system: what a plugin can add (provider, provisioner, command, capabi...

Vagrant: overview and vocabulary (box, provider, provisioner, Vagrantfile)

The essential notions for following the Vagrant course: what Vagrant is for, the lifecycle of an ...

Vagrant multi-machine: deploying a ready-to-use Docker Swarm cluster

Use a single Vagrantfile to build a three-node Docker Swarm cluster (one manager, two workers) wi...

Sharing a Vagrant environment: ngrok and the vagrant-share plugin

Make an application running in a Vagrant machine accessible to a colleague or a client: port forw...

Grafana provisioning: automate the management of your dashboards and data sources

Learn how to use Grafana provisioning to manage your configuration (dashboards, data sources, not...

Ansible: the inventory (static, dynamic, groups and variables)

Understand and master the Ansible inventory: INI and YAML files, groups, host and group variables...

Ansible: ad-hoc commands

Run immediate actions on a fleet of servers with ansible: the ping, command, shell, copy, apt, se...

Ansible: structuring your code with roles

Create, organize and reuse Ansible roles: directory layout, defaults, tasks, handlers, templates,...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!