regex - Ansible lineinfile doesn't recognize regular expression -


file edited

#centos-base.repo # [base] name=centos-$releasever - base  [updates] name=centos-$releasever - updates  [contrib] name=centos-$releasever - contrib 

ansible task

- name: postgresql | yum | exclude old version   remote_user: root   sudo: no   lineinfile: dest=/etc/yum.repos.d/centos-base.repo               line='exclude=postgresql*'               insertafter={{ item }}   with_items:     - ^\[base\]     - ^\[updates\] 

results:

the line added once file , it's added @ eof instead of @ next line after [base] , [updates].

i regex valid(checked on https://pythex.org/ ).

instead of lineinfile module, consider using ini_file module. way don't have bust head regex expressions.

manage (add, remove, change) individual settings in ini-style file without having manage file whole with, say, template or assemble. adds missing sections if don’t exist.

example:

# ensure "fav=lemonade in section "[drinks]" in specified file - ini_file: dest=/etc/conf section=drinks option=fav value=lemonade mode=0600 backup=yes  - ini_file: dest=/etc/anotherconf             section=drinks             option=temperature             value=cold             backup=yes 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -