--- - name: demo blockinfile hosts: server become: true vars: installstate: present tasks: - name: "copy some lines into /etc/profile" blockinfile: path: /etc/profile block: | #This is a #phantastic #block using #ansible #blockinfile marker: "# {mark} OLAFS SUPER BLOCK" state: '{{ installstate }}' insertbefore: "^unset i$"