From 34490dd6f7cf0a77758efc67f3653dfb174a431c Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Fri, 4 Dec 2015 15:51:22 -0700 Subject: [PATCH] Handle interfaces stanzas with leading whitespace Signed-off-by: Zack Cerza --- roles/testnode/tasks/resolvconf.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/roles/testnode/tasks/resolvconf.yml b/roles/testnode/tasks/resolvconf.yml index 21af204..d4d863b 100644 --- a/roles/testnode/tasks/resolvconf.yml +++ b/roles/testnode/tasks/resolvconf.yml @@ -21,12 +21,15 @@ replace: dest: /etc/network/interfaces # This regexp matches a stanza like: + # # iface eth0 inet static # address 10.8.128.17 # netmask 255.255.248.0 # gateway 10.8.135.254 # broadcast 10.8.135.255 - regexp: '^iface {{ interface }} inet static(\n\ +.*)+' + # + # It also handles cases where the entire stanza has whitespace in front of it. + regexp: '^ *iface {{ interface }} inet static(\n\ +[^\s]+.*)+' replace: "iface {{ interface }} inet dhcp\n" when: etc_network_interfaces.stat.exists register: dhcp_enabled -- 2.39.5