Created
October 11, 2019 13:00
-
-
Save acataluddi/19f82f6165fc01706fa1453a311039fa to your computer and use it in GitHub Desktop.
Modify a symlinked INI file avoiding the Ansible's bug replacing the symlink with a copy of the target file
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
- stat: | |
path: /etc/example.ini | |
register: example_ini_stats | |
# Defining the variable "actual_example_ini" containing the actual target file to be processed by ini_file | |
- set_fact: | |
actual_example_ini: "{{ example_ini_stats.stat.lnk_target }}" | |
when: example_ini_stats.stat.islnk is defined and example_ini_stats.stat.islnk | |
- set_fact: | |
actual_example_ini: "{{ example_ini_stats.stat.path }}" | |
when: example_ini_stats.stat.islnk is defined and example_ini_stats.stat.islnk == false | |
- name: "Trying to modify 'change_me' value in /opt/package/conf/example.ini" | |
ini_file: | |
path: "{{ actual_example_ini }}" | |
section: "section" | |
option: "change_me" | |
value: "new value!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your tasks won't work when the file doesn't exist, and are quite lengthy.