ansible_lineinfile_conf - robjcook/sync GitHub Wiki

---
- name: Update configuration
  hosts: your_host_group
  become: yes

  tasks:
    - name: Set new
      ansible.builtin.lineinfile:
        path: /etc/test.conf
        regexp: '^rep=.*'
        line: 'rep={{ new }}'
        owner: root
        group: root
        mode: '0640'
      notify: Restart service

    - name: Set new
      ansible.builtin.lineinfile:
        path: /etc/pgbackrest/pgbackrest.conf
        regexp: '^ret=.*'
        line: 'ret={{ new }}'
        owner: root
        group: root
        mode: '0640'
      notify: Restart service

  handlers:
    - name: Restart service
      ansible.builtin.service:
        name: rest
        state: restarted