From be5994c998f7e5385e0c55bc8c905b30d910a5b8 Mon Sep 17 00:00:00 2001 From: Anil Belur Date: Mon, 29 Oct 2018 12:55:47 +1000 Subject: [PATCH] Use replace module to update /etc/nsswitch.conf Use the replace module instead of calling the sed regex directly from shell. Change-Id: I2408c49ed2578552c924a484a58979d7b0c24ed6 Signed-off-by: Anil Belur --- provision/baseline.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/provision/baseline.yaml b/provision/baseline.yaml index cbfc28c..fa2de70 100644 --- a/provision/baseline.yaml +++ b/provision/baseline.yaml @@ -36,7 +36,11 @@ # 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 -- 2.16.6