I have this code trying to replace string.
File:
<?php
$CONF['database_type'] = 'mysqli';
$CONF['database_host'] = 'some-server.domain.com';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = 'postfixadmin';
$CONF['database_name'] = 'postfix';
$CONF['encrypt'] = 'dovecot:SHA512';
$CONF['configured'] = true;
?>
Tasks:
- name: Replace by setting db parms for PostFixAdmin Host
replace:
path: /etc/postfixadmin/config.local.php
regexp: "$CONF['database_host'] = 'some-server.domain.com';"
replace: "$CONF['database_host'] = '{{db_host}}';"
backup: yes
- name: Replace by setting db parms for PostFixAdmin User
replace:
path: /etc/postfixadmin/config.local.php
regexp: "$CONF['database_user'] = 'postfix';"
replace: "$CONF['database_user'] = '{{db_user}}';"
backup: yes
I have tried \ the $ and ..
Also
- name: Replace by setting db parms for PostFixAdmin Host
lineinfile:
path: /etc/postfixadmin/config.local.php
regexp: ^\\$CONFIG\\['database_host'\\] = .*$
line: "$CONF['database_host'] = '{{db_host}}';"
does not replace it add a second outside of php like this (at the end of the file):
?>
$CONF['database_host'] = 'localhost';
How can I do this?