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

inventory/aws_ec2 - support jinja2 filters in hostnames option #2427

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

abikouo
Copy link
Contributor

@abikouo abikouo commented Dec 19, 2024

SUMMARY

Closes #2402

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

inventory/aws_ec2

Copy link

Docs Build 📝

Thank you for contribution!✨

The docsite for this PR is available for download as an artifact from this run:
https://github.com/ansible-collections/amazon.aws/actions/runs/12417428688

You can compare to the docs for the main branch here:
https://ansible-collections.github.io/amazon.aws/branch/main

File changes:

  • M collections/amazon/aws/aws_ec2_inventory.html
Click to see the diff comparison.

NOTE: only file modifications are shown here. New and deleted files are excluded.
See the file list and check the published docs to see those files.

diff --git a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/aws_ec2_inventory.html b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/aws_ec2_inventory.html
index fbdce97..4c0b9e6 100644
--- a/home/runner/work/amazon.aws/amazon.aws/docsbuild/base/collections/amazon/aws/aws_ec2_inventory.html
+++ b/home/runner/work/amazon.aws/amazon.aws/docsbuild/head/collections/amazon/aws/aws_ec2_inventory.html
@@ -409,6 +409,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-aws-ec2-
 <p>Can be one of the options specified in <a class="reference external" href="http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options">http://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html#options</a>.</p>
 <p>If value provided does not exist in the above options, it will be used as a literal string.</p>
 <p>To use tags as hostnames use the syntax <a class="reference external" href="tag:Name=Value">tag:Name=Value</a> to use the hostname Name_Value, or <a class="reference external" href="tag:Name">tag:Name</a> to use the value of the Name tag.</p>
+<p>Jinja2 filters can be added to the hostnames string. Added in version 9.2.0.</p>
 <p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">[]</span></code></p>
 </div></td>
 </tr>
@@ -878,6 +879,15 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-aws-ec2-
 <span class="w">  </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">us-east-1</span>
 <span class="nt">hostvars_prefix</span><span class="p">:</span><span class="w"> </span><span class="s">&#39;aws_&#39;</span>
 <span class="nt">hostvars_suffix</span><span class="p">:</span><span class="w"> </span><span class="s">&#39;_ec2&#39;</span>
+
+<span class="nn">---</span>
+
+<span class="c1"># Define hostnames variables with jinja2 filters.</span>
+<span class="nt">plugin</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">amazon.aws.aws_ec2</span>
+<span class="nt">regions</span><span class="p">:</span>
+<span class="w">  </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">us-east-1</span>
+<span class="nt">hostnames</span><span class="p">:</span>
+<span class="w">  </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="s">&quot;tag:Name</span><span class="nv"> </span><span class="s">|</span><span class="nv"> </span><span class="s">replace(&#39;test&#39;,</span><span class="nv"> </span><span class="s">&#39;prod&#39;)&quot;</span>
 </pre></div>
 </div>
 <section id="authors">

Copy link
Contributor

Build succeeded.
https://ansible.softwarefactory-project.io/zuul/buildset/f8cf6103e04e498ab9b034e8a85c9d37

✔️ ansible-galaxy-importer SUCCESS in 5m 08s
✔️ build-ansible-collection SUCCESS in 10m 34s
✔️ ansible-test-splitter SUCCESS in 4m 12s
✔️ integration-amazon.aws-1 SUCCESS in 21m 06s
Skipped 43 jobs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support jinja2 filters in hostname
1 participant