# Find deprecated modules  in playbooks

**URL:** <https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048>\
**Category:** Get Help\
**Tags:** module, ansible-lint\
**Created:** [May 28, 2025, 10:40am UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048 "2025-05-28T10:40:19Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![sven](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sven/32/4237_2.png) [@sven](https://forum.ansible.com/u/sven)\
**Post date:** [May 28, 2025, 10:40am UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048/1 "2025-05-28T10:40:19Z")

</div>

I have a bunch of playbooks which usually are triggered by an API. So any warning about deprecated modules are hidden for me.  
Usually, I read the changelog when updating a collection. But sometimes a miss a deprecated module. Is where a way to find any deprecated module ansible-lint or something else?

What I’ve found so far is, that ansible-lint knows only 20 or so deprecated modules, which are hardcoded.

---

<div class="post-metadata">

**Author:** ![mariolenz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mariolenz/32/108_2.png) [@mariolenz](https://forum.ansible.com/u/mariolenz)\
**Post date:** [May 28, 2025, 3:28pm UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048/2 "2025-05-28T15:28:08Z")

</div>

I think a linter usually checks very static things, like the type of indentation (spaces vs tabs) or if there are spaces before and after the `=` in a variable assignment.

So I’m not sure if ansible-lint is the right tool to implement this, because what you’re trying to achieve is more _dynamic_ in nature: It depends on the collections your currently using.

I might be completely wrong about this, and ansible-lint would be the right tool to check this. But I don’t know how to do it. Anyway, whether I’m right or wrong I think this is a very good question! I guess a solution to this problem would be helpful for a lot of people.

Just to make this clear: I guess you want to run this check automatically in some kind of CI pipeline, right? And this would inform you about deprecated modules… or how do you want to be informed? I guess this information would help others to suggest a solution.

---

<div class="post-metadata">

**Author:** ![sven](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sven/32/4237_2.png) [@sven](https://forum.ansible.com/u/sven)\
**Post date:** [May 28, 2025, 3:38pm UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048/3 "2025-05-28T15:38:00Z")

</div>

CI/CD would be nice, when some deprecated module has been found, the pipeline should raise an error.  
We’re using [renovate](https://docs.renovatebot.com/) to update the modules, so this would be triggered when renovate creates a new merge request.

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [May 28, 2025, 3:39pm UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048/4 "2025-05-28T15:39:45Z")

</div>

since you run them automated, can’t you also automate checking the output for DEPRECATED and sending a message if so? I assume you already have the same for errors, it should not be hard to include warnings.

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [May 28, 2025, 3:50pm UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048/5 "2025-05-28T15:50:57Z")

</div>

`ansible-lint` has a static list of deprecated modules that it will check against, so it could be run in CI/CD to catch those. It doesn’t dynamically catch newly deprecated modules, and there’s no way to add to that list via config. So that list would need to be updated via PR’s. If there’s a programmatic way to detect deprecations, someone needs to make a PR for it for `ansible-lint`.

On the other hand, there is also `ansible-policy`. It has the same problem as ansible-lint in that it would only be able to check a static list of deprecated modules, but _you_ as the end-user can create and maintain a deprecation policy definition. Then you could run `ansible-policy` in your CI/CD pipeline, and it would throw policy violations for any deprecated code detected that you have added to the list.

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [May 28, 2025, 5:32pm UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048/6 "2025-05-28T17:32:15Z")

</div>

I’m wondering why ansible-lint only has a static list of deprecated things, since it is very easy to read the routing information for all collections and use that to figure out what’s deprecated (you’d have to do some routing yourself, but that’s also pretty simple). (I know since antsibull-docs is basically doing that to figure out what is deprecated, and to create redirection stubs 🙂 )

---

<div class="post-metadata">

**Author:** ![sven](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sven/32/4237_2.png) [@sven](https://forum.ansible.com/u/sven)\
**Post date:** [May 28, 2025, 6:03pm UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048/7 "2025-05-28T18:03:25Z")

</div>

It could be a solution, but this has some problems:

- I would appreciate it if we could an information which modules are deprecated before we merge the new requirements.yml
- some playbooks are only triggered once a month or even less

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [May 28, 2025, 6:20pm UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048/8 "2025-05-28T18:20:47Z")

</div>

deprecated only means they will be removed in the future, it does not normally require immediate action, it is just a warning that this module/plugin will go away, not that it is failing right now.

---

<div class="post-metadata">

**Author:** ![dbrennand](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dbrennand/32/7830_2.png) [@dbrennand](https://forum.ansible.com/u/dbrennand)\
**Post date:** [May 29, 2025, 3:42pm UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048/9 "2025-05-29T15:42:51Z")

</div>

Ansible Lint does follow the plugin routing defined in the collection `meta/runtime.yml`, but I believe it does this only when you use the autofix (`--fix`) functionality. It will follow them and correct each task module FQCN. Seen this behaviour very recently with the [`dellemc.os10`](https://github.com/ansible-collections/dellemc.os10/blob/master/meta/runtime.yml) collection.

---

<div class="post-metadata">

**Author:** ![Denney-tech](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/denney-tech/32/1556_2.png) [@Denney-tech](https://forum.ansible.com/u/Denney-tech)\
**Post date:** [May 29, 2025, 7:52pm UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048/10 "2025-05-29T19:52:01Z")

</div>

When searching the ansible-lint repo for “deprecat\*”, the only thing I noticed was [src/ansiblelint/rules/deprecated\_module](https://github.com/ansible/ansible-lint/blob/main/src/ansiblelint/rules/deprecated_module.py), which only seems to have a static list it uses for reference.

Obviously there could be logic defined elsewhere, but I’m not sure where it would be.

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [May 29, 2025, 7:53pm UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048/11 "2025-05-29T19:53:48Z")

</div>

simplest change, logic goes there and generates that list by using `ansible-doc` for installed plugins

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [May 29, 2025, 8:17pm UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048/12 "2025-05-29T20:17:31Z")

</div>

That’s missing some parts, since redirects can also be deprecated (which isn’t part of the documentation); and it doesn’t really work for other things than actions, since you’d have to do the routing manually.

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [May 29, 2025, 8:19pm UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048/13 "2025-05-29T20:19:50Z")

</div>

> [@felixfontein](#):
>
> irects can also be deprecated (which isn’t part of the documentation); and it doesn’t really work for other things than actions, since you’d have to do the routing manually.

loading via the redirect will give you a deprecation message, that can also be captured

also, I would go farther, ‘deprecated plugin’.

---

<div class="post-metadata">

**Author:** ![rfc2549](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/rfc2549/32/197_2.png) [@rfc2549](https://forum.ansible.com/u/rfc2549)\
**Post date:** [June 1, 2025, 7:10pm UTC](https://forum.ansible.com/t/find-deprecated-modules-in-playbooks/43048/14 "2025-06-01T19:10:17Z")

</div>

This might not be the answer you are looking for but I have been thinking about this 😛

The upcoming ansible-core 2.19 changes a lot of things, including clearer exceptions and deprecations. For example:

```console
TASK [smoke-tests : Add dynamically templated labels to this playbook] ****************************************************************************************************************************************************************************************
[DEPRECATION WARNING]: Jinja constant strings should not contain embedded templates. This feature will be removed in version 2.23.
Origin: /home/user/dev/sandbox/ara/ara/tests/integration/roles/smoke-tests/tasks/ara-ops.yaml:194:9

192 state: present
193 labels:
194 - "git:{{ lookup('pipe', 'git -C {{ playbook_dir }} rev-parse HEAD') }}"
            ^ column 9

[DEPRECATION WARNING]: Top-level facts are deprecated, use `ansible_facts` instead. This feature will be removed in version 2.22.
Origin: /home/user/dev/sandbox/ara/ara/tests/integration/roles/smoke-tests/tasks/ara-ops.yaml:195:9

193 labels:
194 - "git:{{ lookup('pipe', 'git -C {{ playbook_dir }} rev-parse HEAD') }}"
195 - "os:{{ ansible_distribution }}-{{ ansible_distribution_version }}"
            ^ column 9

```

If you wanted to capture these exceptions and deprecations programmatically, it turns out that [ara](https://github.com/ansible-community/ara) will record them:

 ![exception](https://us1.discourse-cdn.com/ansible/original/2X/0/0fd4ad3b765c19f51ff7e30b01785765b3c1b660.png)

This requires running the playbook (with 2.19) vs running ansible-lint before running the playbook, but it’s something.

ara doesn’t do anything special with exceptions or deprecations (yet) but the data would be available via API 🤷‍♂️

2.19 is still in pre-release for a while, but it is available for testing.
