DevOps Bootcamp · Lesson

Provision Then Configure in One Flow

Hand off new hosts to config plays.

Lesson 4 of 413 steps

Provision Then Configure in One Flow is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 4 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.

Two Jobs, One Playbook

Provisioning makes a server exist. Configuring makes it useful. The real power is doing both in a single, smooth play. 🔗

Provision on the Control Node

Cloud creation tasks run locally against the AWS API, so the provisioning play targets localhost, not the new server.

- hosts: localhost
  gather_facts: false
  tasks:
    - amazon.aws.ec2_instance: { name: web-01 }

Capture the New Host

You cannot SSH to a box you do not know about yet. register the ec2_instance result to grab its fresh public IP.

- amazon.aws.ec2_instance:
    name: web-01
  register: ec2

Add It to Inventory in Memory

The add_host module injects the new server into the running inventory, so a later play can target it without a static file.

- add_host:
    name: "{{ ec2.instances[0].public_ip_address }}"
    groups: launched

Wait Until SSH Is Ready

A booting instance is not instantly reachable. wait_for pauses until port 22 answers before you try to connect.

- wait_for:
    host: "{{ ec2.instances[0].public_ip_address }}"
    port: 22

Start a Second Play

Now open a new play that targets the launched group you just built. This play runs on the cloud server itself.

- hosts: launched
  become: true
  tasks:
    - ping:

Configure the Fresh Host

With the host in inventory, ordinary modules take over. Install packages, copy configs, and start services exactly as on any node.

- hosts: launched
  tasks:
    - package:
        name: nginx
        state: present

Pass the Right SSH User

Cloud images use specific logins, like ubuntu or ec2-user. Set ansible_user so the config play connects correctly.

add_host:
  name: "{{ ec2.instances[0].public_ip_address }}"
  groups: launched
  ansible_user: ubuntu

One File, End to End

The result is a single playbook: play one creates infrastructure, play two configures it. Run it once and a working server appears.

Idempotent All the Way

Both halves are idempotent. Re-running matches the existing instance and converges the config, so the flow is safe to repeat.

Skip Host Key Prompts

A brand-new host has an unknown SSH key. Set host_key_checking off for the launched group so the first connection does not stall.

add_host:
  name: "{{ ec2.instances[0].public_ip_address }}"
  groups: launched
  ansible_ssh_common_args: "-o StrictHostKeyChecking=no"

Quick Check

You just launched an EC2 box and want the next play to configure it, with no static inventory entry. What bridges the gap?

Recap

You linked provision and configure: create on localhost, register the IP, add_host, wait for SSH, then configure in a second play. ✨

Free to start

Learn DevOps Bootcamp with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
142
Lessons
568

Frequently Asked Questions

Is the “Provision Then Configure in One Flow” lesson free?

Yes — any 3 lessons of the DevOps Bootcamp learning path, including “Provision Then Configure in One Flow”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.

What will I learn in “Provision Then Configure in One Flow”?

Hand off new hosts to config plays. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start DevOps Bootcamp?

No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 4 of 4.

How long does the “Provision Then Configure in One Flow” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Cloud Collections & Authentication
  2. Launch EC2 Instances Declaratively
  3. Networking: VPCs, Subnets & Security Groups
  4. Provision Then Configure in One Flow
← Back to DevOps Bootcamp