Remove default ansible.cfg configuration option ansible_managed as it's deprecated#4553
Merged
cidrblock merged 1 commit intoansible:mainfrom Sep 16, 2025
Merged
Conversation
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]>
400ac5c to
575745a
Compare
cidrblock
approved these changes
Sep 16, 2025
|
thx -brad |
1 task
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With a current ansible (2.19.2) we get the following deprecation warning: