I want to add new hosts to an http configuration file. When I use blockinfile it's replacing the last block and not appending to the end. What I'd like to do is keep adding to the file but blockfile doesn't seem to be doing what I want.
<VirtualHost *:*>
ServerAdmin someone
DocumentRoot /var/www/html/prod/liver
ServerName liver
ServerAlias www.liver
</VirtualHost>
<VirtualHost *:*>
ServerAdmin someone
DocumentRoot /var/www/html/prod/liver
ServerName liver
ServerAlias www.liver
</VirtualHost>
My code
---
- hosts: web
vars_prompt:
- name: "site"
prompt: "Enter application"
private: no
tasks:
- name: "append"
blockinfile:
dest: /tmp/xxxyyy
insertafter: "# {mark} ANSIBLE MANAGED BLOCK"
block: |
<VirtualHost *:*>
ServerAdmin someone
DocumentRoot /var/www/html/prod/{{site}}
ServerName {{site}}
ServerAlias www.{{site}}
</VirtualHost>