diff --git a/lib/ansible/module_utils/junos.py b/lib/ansible/module_utils/junos.py index 66b8d742ac..5e81b55c41 100644 --- a/lib/ansible/module_utils/junos.py +++ b/lib/ansible/module_utils/junos.py @@ -250,9 +250,12 @@ class Netconf(object): return self.device.facts def get_config(self, config_format="text"): - ele = self.rpc('get_configuration', format=config_format) + if config_format not in ['text', 'set', 'xml']: + msg = 'invalid config format... must be one of xml, text, set' + self._fail(msg=msg) - if config_format == "text" or config_format == "set": + ele = self.rpc('get_configuration', format=config_format) + if config_format in ['text', 'set']: return str(ele.text).strip() elif config_format == "xml": return ele