Skip to content

Instantly share code, notes, and snippets.

@acataluddi
Created October 11, 2019 13:00
Show Gist options
  • Save acataluddi/19f82f6165fc01706fa1453a311039fa to your computer and use it in GitHub Desktop.
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
@flowerysong
Copy link

Your tasks won't work when the file doesn't exist, and are quite lengthy.

- vars:
      example_ini: /etc/example.ini
  block:
    - stat:
        path: "{{ example_ini }}"
      register: result
  
    - name: Modify 'change_me' value in {{ example_ini }} or its target
      ini_file:
        path: "{{ result.stat.lnk_target | default(example_ini) }}"
        section: section
        option: change_me
        value: new value!

@acataluddi
Copy link
Author

Amazing!

Thank you @flowerysong, much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment