Skip to content

Remove default ansible.cfg configuration option ansible_managed as it's deprecated#4553

Merged
cidrblock merged 1 commit intoansible:mainfrom
ziegenberg:remove-ansible_managed-default
Sep 16, 2025
Merged

Remove default ansible.cfg configuration option ansible_managed as it's deprecated#4553
cidrblock merged 1 commit intoansible:mainfrom
ziegenberg:remove-ansible_managed-default

Conversation

@ziegenberg
Copy link
Copy Markdown
Contributor

With a current ansible (2.19.2) we get the following deprecation warning:

[DEPRECATION WARNING]: DEFAULT_MANAGED_STR option. Reason: The
`ansible_managed` variable can be set just like any other variable, or a
different variable can be used.  Alternatives: Set the `ansible_managed`
variable, or use any custom variable in templates. This feature will be
removed from ansible-core version 2.23.

With a current ansible (2.19.2) we get the following deprecation warning:

```
[DEPRECATION WARNING]: DEFAULT_MANAGED_STR option. Reason: The
`ansible_managed` variable can be set just like any other variable, or a
different variable can be used.  Alternatives: Set the `ansible_managed`
variable, or use any custom variable in templates. This feature will be
removed from ansible-core version 2.23.
```

Signed-off-by: Daniel Ziegenberg <[email protected]>
@cidrblock cidrblock merged commit a75761e into ansible:main Sep 16, 2025
21 of 22 checks passed
@cidrblock
Copy link
Copy Markdown

thx

-brad

@ziegenberg ziegenberg deleted the remove-ansible_managed-default branch January 15, 2026 17:16
jkirk added a commit to jkirk/ansible-role-base that referenced this pull request Feb 21, 2026
The local development system was updated from Debian/bullseye to
Debian/bookworm. Podman works well, so we switched Ansible Molecule
from docker to podman.

We now also use a custom podman container with ansible-core v2.16.14, so
we use this version for the default Ansible Molecule configuration.

Ansible-core does not come with the community.general collection which
is included in Ansible only. See Ansible 9 Release Notes which contains
ansible-core 2.16.14:
* https://docs.ansible.com/projects/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-community-changelogs
* https://github.com/ansible-community/ansible-build-data/blob/main/9/CHANGELOG-v9.rst#ansible-core

This role needs community.general.alternatives, so we have to add a
"community.general" collection dependency in requirements.yml.

It was also a bad idea to not set an ansible(-core) version in the
requirements.txt as the user always gets the latest ansible(-core) +
molecule version when calling "make install" or "make upgrade", which
might lead to unexpected results.

For instance, Ansible Molecule dropped their default `ansible_managed`
value because it's deprecated in ansible since v2.19.

This causes "molecule verify" to fail:

  TASK [Deploy chrony with server configuration] *********************************
  --- before: /etc/chrony/chrony.conf
  +++ after: /home/jkirk/projects/ansible/ansible-role-base/molecule/default/files/chrony.bookworm.example.conf
  @@ -1,4 +1,4 @@
  -# Ansible managed
  +# Ansible managed: Do NOT edit this file manually!
   # Welcome to the chrony configuration file. See chrony.conf(5) for more
   # information about usable directives.

  changed: [instance]

  TASK [Assert generated default chrony with server configuration] ***************
  [ERROR]: Task failed: Action failed: Unexpected change in /etc/chrony/chrony.conf
  Origin: /home/jkirk/projects/ansible/ansible-role-base/molecule/default/verify.yml:19:5

  17     diff: true
  18
  19   - name: Assert generated default chrony with server configuration
         ^ column 5

  fatal: [instance]: FAILED! => {
      "assertion": "not chrony_server_example_conf.changed",
      "changed": false,
      "evaluated_to": false,
      "msg": "Unexpected change in /etc/chrony/chrony.conf"
  }

This happened in Ansible Molecule v25.11, see:

- ansible/molecule#4553
- ansible/molecule@a75761e

There are now (since Ansible Molecule v25) two ways to set
`ansible_managed` in ansible.cfg:

- Ansible-Native configuration, see: https://docs.ansible.com/projects/molecule/ansible-native/
- Pre ansible-native configuration: see:
  https://docs.ansible.com/projects/molecule/configuration/#provisioner-pre-ansible-native

To be backward compatible to Ansible Molecule v24 which is the last
version which works with ansible-core 2.14 (which ships in
Debian/bookworm), we set `ansible_managed` in the provisioner
configuration.

Also decided to drop ansible-lint and yamllint, as it is not called
automatically.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants