Skip to content

Allow disabling of the deprecated tags host variable in the AWS EC2 inventory plugin - #3030

Open
oraNod wants to merge 8 commits into
ansible-collections:mainfrom
oraNod:issue-3028/ec2-inventory
Open

Allow disabling of the deprecated tags host variable in the AWS EC2 inventory plugin#3030
oraNod wants to merge 8 commits into
ansible-collections:mainfrom
oraNod:issue-3028/ec2-inventory

Conversation

@oraNod

@oraNod oraNod commented Jul 14, 2026

Copy link
Copy Markdown
Contributor
SUMMARY

Resolves #3028

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME
plugins/inventory/aws_ec2.py

Note that the plugins/inventory/aws_rds.py plugin also likely needs the same treatment but I thought it might be better as a separate PR. I can do that as a follow up.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

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/29334649506

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 50237b9..7f1f19b 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
@@ -691,6 +691,21 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-aws-ec2-
 </div></td>
 </tr>
 <tr class="row-even"><td><div class="ansible-option-cell">
+<div class="ansibleOptionAnchor" id="parameter-use_deprecated_tags"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-aws-ec2-inventory-parameter-use-deprecated-tags"><strong>use_deprecated_tags</strong></p>
+<a class="ansibleOptionLink" href="#parameter-use_deprecated_tags" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
+<p><em class="ansible-option-versionadded">added in amazon.aws 12.0.0</em></p>
+</div></td>
+<td><div class="ansible-option-cell"><p>Whether to include the deprecated <code class="docutils literal notranslate"><span class="pre">tags</span></code> host variable alongside <code class="docutils literal notranslate"><span class="pre">ec2_tags</span></code>.</p>
+<p>Set to <code class="ansible-value docutils literal notranslate"><span class="pre">false</span></code> to stop the plugin from adding the <code class="docutils literal notranslate"><span class="pre">tags</span></code> host variable, which also disables this plugin’s <code class="docutils literal notranslate"><span class="pre">tags</span></code> deprecation warning and Ansible’s reserved variable name warning for <code class="docutils literal notranslate"><span class="pre">tags</span></code>.</p>
+<p>The use of this feature is deprecated and will be removed in a release after 2026-12-01. Use the <code class="docutils literal notranslate"><span class="pre">ec2_tags</span></code> structure instead.</p>
+<p class="ansible-option-line"><strong class="ansible-option-choices">Choices:</strong></p>
+<ul class="simple">
+<li><p><code class="ansible-option-choices-entry docutils literal notranslate"><span class="pre">false</span></code></p></li>
+<li><p><code class="ansible-option-default-bold docutils literal notranslate"><strong><span class="pre">true</span></strong></code> <span class="ansible-option-choices-default-mark">← (default)</span></p></li>
+</ul>
+</div></td>
+</tr>
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-use_extra_vars"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-aws-ec2-inventory-parameter-use-extra-vars"><strong>use_extra_vars</strong></p>
 <a class="ansibleOptionLink" href="#parameter-use_extra_vars" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
 <p><em class="ansible-option-versionadded">added in ansible-core 2.11</em></p>
@@ -713,7 +728,7 @@ see <a class="reference internal" href="#ansible-collections-amazon-aws-aws-ec2-
 </ul>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-use_ssm_inventory"></div><p class="ansible-option-title" id="ansible-collections-amazon-aws-aws-ec2-inventory-parameter-use-ssm-inventory"><strong>use_ssm_inventory</strong></p>
 <a class="ansibleOptionLink" href="#parameter-use_ssm_inventory" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
 <p><em class="ansible-option-versionadded">added in amazon.aws 6.0.0</em></p>
@@ -743,7 +758,7 @@ For example, an ansible.cfg entry (further up in the list) is overwritten by an
 <p class="admonition-title">Note</p>
 <ul class="simple">
 <li><p>If no credentials are provided and the control node has an associated IAM instance profile then the role will be used for authentication.</p></li>
-<li><p>The <code class="docutils literal notranslate"><span class="pre">tags</span></code> host variable is deprecated and will be removed in a release after 2026-12-01. Use <code class="docutils literal notranslate"><span class="pre">ec2_tags</span></code> instead to avoid conflicts with Ansible reserved variable names.</p></li>
+<li><p>The <code class="docutils literal notranslate"><span class="pre">tags</span></code> host variable is deprecated and will be removed in a release after 2026-12-01. Use <code class="docutils literal notranslate"><span class="pre">ec2_tags</span></code> instead to avoid conflicts with Ansible reserved variable names. Set <code class="ansible-option-value docutils literal notranslate"><a class="reference internal" href="#ansible-collections-amazon-aws-aws-ec2-inventory-parameter-use-deprecated-tags"><span class="std std-ref"><span class="pre">use_deprecated_tags=false</span></span></a></code> to disable the <code class="docutils literal notranslate"><span class="pre">tags</span></code> host variable, and this warning, before then.</p></li>
 <li><p>The <code class="docutils literal notranslate"><span class="pre">ec2_tags</span></code> host variable was added in version 11.2.0.</p></li>
 <li><p>The <code class="docutils literal notranslate"><span class="pre">use_contrib_script_compatible_ec2_tag_keys</span></code> option is deprecated and will be removed in a release after 2026-12-01. Use the <code class="docutils literal notranslate"><span class="pre">ec2_tags</span></code> structure instead (e.g. use <code class="docutils literal notranslate"><span class="pre">ec2_tags.TAGNAME</span></code> rather than <code class="docutils literal notranslate"><span class="pre">ec2_tag_TAGNAME</span></code>).</p></li>
 <li><p>The <code class="docutils literal notranslate"><span class="pre">use_contrib_script_compatible_sanitization</span></code> option is deprecated and will be removed in a release after 2026-12-01. Use Ansible’s default group name sanitization instead.</p></li>

@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

@sonarqubecloud

Copy link
Copy Markdown

@tremble tremble left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @oraNod,

A few suggestions based on the SonarCloud feedback, but I think the deprecation/removal timeframe for the new feature needs to be rethought.

Comment thread plugins/inventory/aws_ec2.py
Comment thread plugins/inventory/aws_ec2.py Outdated
Comment thread plugins/inventory/aws_ec2.py Outdated
Comment thread plugins/inventory/aws_ec2.py Outdated
inventory._add_ssm_information(connection, instances)
assert expected == instances

assert 2 == m_get_ssm_information.call_count

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SonarCloud is complaining about the order of these two.

It expects actual_value == expected_value.

I think we ignore this for now. Some people prefer it this way around because 2 = call_count will result in an error if you make the mistake of single =. I don't think it's worth poking right now and certainly not for this PR.

- Set to V(false) to stop the plugin from adding the C(tags) host variable, which also
disables this plugin's C(tags) deprecation warning and Ansible's reserved variable
name warning for C(tags).
- The use of this feature is deprecated and will be removed in a release after 2026-12-01.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alinabuzachis @GomathiselviS When are you currently planning for 12.0.0 release? If we're aiming for early November, then we could swap the release dates for versions, and the wording becomes a little less clunky.

Suggested change
- The use of this feature is deprecated and will be removed in a release after 2026-12-01.
- This parameter will be ignored when the deprecated C(tags) host variable is removed
(in a release after 2026-12-01).

If we remove this in 2026-12-01 there's no way to ensure consistent behaviour between 12.0.0 and 13.0.0.

Setting this flag to False will trigger the new behaviour in 12.0.0, but cause failures in 13.0.0. This causes problems for people who need to run a mixed environment (and is an example of why we normally use a 2 year deprecation cycle)

What we've done in the past is add a 2 year deprecation to the feature flag after ignoring it. This means that people can turn off the deprecated feature in advance. Make sure everything's working. They can then run both 12 and 13 while they migrate to 13, followed by dropping the parameter once they finish their migrations. It's a smoother path and doesn't result in multiple breakages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @tremble I wasn't sure at all tbh, based this on similar bits, and made some assumptions. I agree that a 2 year deprecation would be a smoother path but will wait for @alinabuzachis and @GomathiselviS

Use the C(ec2_tags) structure instead.
type: bool
default: true
version_added: 12.0.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to back port this to 11?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason that I'm aware of. I still need to learn the release process and versions around here.

@tremble tremble Jul 14, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general main is "future" (the major we've not released yet, currently 12.0.0). Most non-breaking changes get backported into the "current" stable-X branch (stable-11 at the minute), bugfixes to both the current and the previous stable (stable-11 and stable-10) branch, and security fixes sometimes get pulled back even further.

https://github.com/ansible-collections/amazon.aws/blob/main/docs/docsite/rst/dev_guidelines.rst#release-policy-and-backporting-merged-prs

We have patchback configured and a workflow that reads the changelog fragment to estimate which releases it should be backported for (backport tags are added when mergeit is set)

The actual release process is also documented https://github.com/ansible-collections/amazon.aws/blob/main/docs/docsite/rst/collection_release.rst

We also have a workflow which keeps https://github.com/ansible-collections/amazon.aws/releases up to date.

Last release was 11.4.0, so if this is backported it would be 11.5.0.

@oraNod

oraNod commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review @tremble

I've also opened #3031 for the integration test failure which I think is unrelated to these changes.

@oraNod
oraNod force-pushed the issue-3028/ec2-inventory branch from 9bf408a to d585ac1 Compare July 14, 2026 12:56
Co-authored-by: Mark Chappell <mchappel@redhat.com>
@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

@centosinfra-prod-github-app

Copy link
Copy Markdown
Contributor

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.

ec2 inventory plugin always throws 'tags' deprecation warning

2 participants