Use the replace module instead of calling the sed regex
directly from shell.
Change-Id: I2408c49ed2578552c924a484a58979d7b0c24ed6
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
# Update /etc/nss-switch.conf to map hostname with IP instead of using `localhost`
# from /etc/hosts which is required by some of the Java API's to avoid
# Java UnknownHostException: "Name or service not known" error.
- shell: sed -i "/^hosts:/s/$/ myhostname/" /etc/nsswitch.conf
+ replace:
+ path: /etc/nsswitch.conf
+ regexp: '^hosts:(\s+.*)?$'
+ replace: 'hosts:\1 myhostname'
+ backup: yes
become: yes
- name: Disable periodic updates