i have file with string:
MYAPP.db.username.DEV=MYUSERNAME
Where:
MYAPP mean name of applications
DEV means environment
MYUSERNAME means name of user for connection to db
I need to replace these variables according to variables, that i have in some script. I am using this:
- name: Replace line
shell: sed -i "/{{ name_of_app }}.db.username.{{ name_of_environment }}/c\\{{ name_of_app }}.db.username.{{ name_of_environment }}={{ name_of_user_to_db }}" /path/to/my/apps/{{ name_of_app }}/config/{{ name_of_app }}.config
It works fine, but i see warnings in output of ansible
[WARNING]: Consider using the replace, lineinfile or template module rather
than running sed. If you need to use command because replace, lineinfile or
template is insufficient you can add warn=False to this command task or set
command_warnings=False in ansible.cfg to get rid of this message.
changed:
I have tried this
- name: Replace line via replace method
replace:
dest: "/path/to/my/apps/{{ name_of_app }}/config/{{ name_of_app }}.config"
regexp: "{{ name_of_app }}.db.username.{{ name_of_environment }}"
replace: "{{ name_of_app }}.db.username.{{ name_of_environment }}={{ name_of_user_to_db }}"
and this
- name: Replace line via lineinfile method
lineinfile:
dest: "/path/to/my/apps/{{ name_of_app }}/config/{{ name_of_app }}.config"
regexp: "{{ name_of_app }}.db.username.{{ name_of_environment }}"
line: "{{ name_of_app }}.db.username.{{ name_of_environment }}={{ name_of_user_to_db }}"
backrefs: yes
each time, i have result with failed:
FAILED! => {"changed": false, "msg": "Unsupported parameters for (replace) module: when Supported parameters include: after, attributes, backup, before, content, delimiter, directory_mode, encoding, follow, force, group, mode, owner, path, regexp, remote_src, replace, selevel, serole, setype, seuser, src, unsafe_writes, validate"}
Can you help me, where i have error in my playbook ?