less than 1 minute read

Replacing multiple lines in file

- name: Set some kernel parameters
  lineinfile:
    dest: /etc/sysctl.conf
    regexp: ""
    line: ""
  with_items:
    - { regexp: '^kernel.shmall', line: 'kernel.shmall = 2097152' }
    - { regexp: '^kernel.shmmax', line: 'kernel.shmmax = 134217728' }
    - { regexp: '^fs.file-max', line: 'fs.file-max = 65536' }

Replacing a block of text

    blockinfile:
      path: inventory.test
      block: |
         [isolated_group_]
         
         [isolated_group_:vars]
         controller=tower
      state: present

Leave a comment