docs: link slide 26 dynamic inventory to Terraform state
- dynamic example now uses cloud.terraform.terraform_state plugin reading the .tfstate from the earlier Terraform slides - notes explain the Terraform -> Ansible handoff (single source of truth) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
17
index.html
17
index.html
@@ -1054,7 +1054,7 @@ Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
|
|||||||
<h2>Who runs where? The inventory.</h2>
|
<h2>Who runs where? The inventory.</h2>
|
||||||
<ul>
|
<ul>
|
||||||
<li><strong>Static</strong> — a hand-written INI/YAML file of hosts & groups. Simple, versioned, ideal for stable fleets.</li>
|
<li><strong>Static</strong> — a hand-written INI/YAML file of hosts & groups. Simple, versioned, ideal for stable fleets.</li>
|
||||||
<li><strong>Dynamic</strong> — an inventory plugin queries a source at runtime (OpenStack, AWS, OVHcloud…). Hosts discovered automatically — built for cloud & autoscaling.</li>
|
<li><strong>Dynamic</strong> — a plugin builds the host list at runtime. Best source here: <strong>the Terraform state we just wrote</strong> — Ansible configures exactly what Terraform provisioned.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div style="display:flex; gap:1.5em; margin-top:0.3em; text-align:left;">
|
<div style="display:flex; gap:1.5em; margin-top:0.3em; text-align:left;">
|
||||||
<div style="flex:1;">
|
<div style="flex:1;">
|
||||||
@@ -1069,12 +1069,12 @@ webservers:
|
|||||||
</code></pre>
|
</code></pre>
|
||||||
</div>
|
</div>
|
||||||
<div style="flex:1;">
|
<div style="flex:1;">
|
||||||
<p class="filename"># openstack.yml — dynamic</p>
|
<p class="filename"># terraform.yml — dynamic (from TF state)</p>
|
||||||
<pre><code class="language-yaml" data-trim>
|
<pre><code class="language-yaml" data-trim>
|
||||||
plugin: openstack.cloud.openstack
|
plugin: cloud.terraform.terraform_state
|
||||||
expand_hostvars: true
|
backend_type: local
|
||||||
groups:
|
backend_config:
|
||||||
webservers: "'web' in name"
|
path: ../terraform/terraform.tfstate
|
||||||
</code></pre>
|
</code></pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1082,8 +1082,9 @@ groups:
|
|||||||
<ul>
|
<ul>
|
||||||
<li>The <code>-i</code> flag on the next slide points here — Ansible needs to know which hosts to target.</li>
|
<li>The <code>-i</code> flag on the next slide points here — Ansible needs to know which hosts to target.</li>
|
||||||
<li><strong>Static</strong>: explicit list checked into Git. Predictable, but you maintain it by hand.</li>
|
<li><strong>Static</strong>: explicit list checked into Git. Predictable, but you maintain it by hand.</li>
|
||||||
<li><strong>Dynamic</strong>: the plugin runs at playbook time and queries the cloud API, so hosts auto-appear/disappear with the fleet. <code>groups</code>/<code>keyed_groups</code> build groups from tags or metadata.</li>
|
<li><strong>This is the Terraform → Ansible handoff</strong>: Terraform creates the instance and records it in <code>.tfstate</code> (remember slide 16); the <code>cloud.terraform.terraform_state</code> plugin reads that same state and turns each resource into an Ansible host. One source of truth — no second host list to keep in sync.</li>
|
||||||
<li><code>-i</code> accepts a static file, a directory (mixing several sources), or a plugin config like the one on the right.</li>
|
<li>Other dynamic sources exist too — cloud plugins like <code>openstack.cloud.openstack</code> or AWS/OVHcloud query the provider API directly. <code>keyed_groups</code> build groups from tags/metadata.</li>
|
||||||
|
<li>Provision with Terraform, then immediately configure with Ansible against the freshly-created hosts — that's the combined workflow we land on at the end.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</aside>
|
</aside>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user