From c7c8481181e96dab508e11917551551f83c5b677 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 22 Mar 2017 21:41:43 -0700 Subject: [PATCH] No need to specialcase comment characters If the # is inside of quotes, it's a string. If it's outside of quotes then an exception will be raised which we'll catch and then send to the to_text() call at the end of the function anyhow. Fixes #22868 --- lib/ansible/inventory/ini.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/ansible/inventory/ini.py b/lib/ansible/inventory/ini.py index 9347be39f9..8feade991b 100644 --- a/lib/ansible/inventory/ini.py +++ b/lib/ansible/inventory/ini.py @@ -327,17 +327,16 @@ class InventoryParser(object): Attempt to transform the string value from an ini file into a basic python object (int, dict, list, unicode string, etc). ''' - if "#" not in v: - try: - v = ast.literal_eval(v) - # Using explicit exceptions. - # Likely a string that literal_eval does not like. We wil then just set it. - except ValueError: - # For some reason this was thought to be malformed. - pass - except SyntaxError: - # Is this a hash with an equals at the end? - pass + try: + v = ast.literal_eval(v) + # Using explicit exceptions. + # Likely a string that literal_eval does not like. We wil then just set it. + except ValueError: + # For some reason this was thought to be malformed. + pass + except SyntaxError: + # Is this a hash with an equals at the end? + pass return to_text(v, nonstring='passthru', errors='surrogate_or_strict') def get_host_variables(self, host):