-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PR #6546/c76af60a backport][stable-7] ini_file: Don't creates new fi…
…le instead of following symlink (#6598) ini_file: Don't creates new file instead of following symlink (#6546) * ini_file: Don't creates new file instead of following symlink This is a bug fix that address a situation where `community.general.ini_file` was destroying symlinks instead of updating of updating their targets. Closes: #6470 * ini_file: add the follow parameter If `poth` points on a symlink and `follow` is true, the `ini_file` plugin will preserve the symlink and modify the target file. * adjust the documentation of the new key - yes/no -> true/false. - new key will be introduced in 7.1.0. - clean up the `state=link` part. (cherry picked from commit c76af60) Co-authored-by: Gonéri Le Bouder <[email protected]>
- Loading branch information
1 parent
5cec315
commit c4ebd48
Showing
3 changed files
with
86 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
bugfixes: | ||
- "ini_file - add the ``follow`` paramter to follow the symlinks instead of replacing them (https://github.com/ansible-collections/community.general/pull/6546)." |
This file contains 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
59 changes: 59 additions & 0 deletions
59
tests/integration/targets/ini_file/tasks/tests/04-symlink.yml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
# Copyright (c) Ansible Project | ||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
- block: &prepare | ||
- name: Create the final file | ||
ansible.builtin.copy: | ||
content: | | ||
[main] | ||
foo=BAR | ||
dest: my_original_file.ini | ||
- name: Clean up symlink.ini | ||
ansible.builtin.file: | ||
path: symlink.ini | ||
state: absent | ||
- name: Create a symbolic link | ||
ansible.builtin.file: | ||
src: my_original_file.ini | ||
dest: symlink.ini | ||
state: link | ||
|
||
- name: Set the proxy key on the symlink which will be converted as a file | ||
community.general.ini_file: | ||
path: symlink.ini | ||
section: main | ||
option: proxy | ||
value: 'http://proxy.myorg.org:3128' | ||
- name: Set the proxy key on the final file that is still unchanged | ||
community.general.ini_file: | ||
path: my_original_file.ini | ||
section: main | ||
option: proxy | ||
value: 'http://proxy.myorg.org:3128' | ||
register: result | ||
- ansible.builtin.assert: | ||
that: | ||
- result is changed | ||
|
||
# With follow | ||
- block: *prepare | ||
- name: Set the proxy key on the symlink which will be preserved | ||
community.general.ini_file: | ||
path: symlink.ini | ||
section: main | ||
option: proxy | ||
value: 'http://proxy.myorg.org:3128' | ||
follow: true | ||
register: result | ||
- name: Set the proxy key on the target directly that was changed in the previous step | ||
community.general.ini_file: | ||
path: my_original_file.ini | ||
section: main | ||
option: proxy | ||
value: 'http://proxy.myorg.org:3128' | ||
register: result | ||
- ansible.builtin.assert: | ||
that: | ||
- "not (result is changed)" |