From 4d24e2e29f66bdc0ee03bc70c7622ef3ecc18d00 Mon Sep 17 00:00:00 2001 From: Scott Sturdivant Date: Mon, 21 Oct 2013 14:20:54 -0600 Subject: [PATCH] If the output of rcvar isn't a key=value pair, ignore it. --- library/system/service | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/library/system/service b/library/system/service index 34b8dc31e1e..bd03672d8b9 100644 --- a/library/system/service +++ b/library/system/service @@ -793,8 +793,17 @@ class FreeBsdService(Service): self.module.fail_json(msg="unable to determine rcvar") # In rare cases, i.e. sendmail, rcvar can return several key=value pairs - # Usually there is just one, however. - self.rcconf_key = rcvars[0].split('=')[0] + # Usually there is just one, however. In other rare cases, i.e. uwsgi, + # rcvar can return extra uncommented data that is not at all related to + # the rcvar. We will just take the first key=value pair we come across + # and hope for the best. + for rcvar in rcvars: + if '=' in rcvar: + self.rcconf_key = rcvar.split('=')[0] + break + + if self.rcconf_key is None: + self.module.fail_json(msg="unable to determine rcvar") return self.service_enable_rcconf()