From 0658847ea653a42ea7965bb1f9e79289a11033f0 Mon Sep 17 00:00:00 2001 From: Ilya Kuznetsov Date: Fri, 14 Feb 2014 20:03:14 +0700 Subject: [PATCH] Allow equal sign in single-line ini variables --- lib/ansible/inventory/ini.py | 2 +- test/TestInventory.py | 7 ++++++- test/simple_hosts | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/ansible/inventory/ini.py b/lib/ansible/inventory/ini.py index 220e842f6bc..c50fae61164 100644 --- a/lib/ansible/inventory/ini.py +++ b/lib/ansible/inventory/ini.py @@ -119,7 +119,7 @@ class InventoryParser(object): if t.startswith('#'): break try: - (k,v) = t.split("=") + (k,v) = t.split("=", 1) except ValueError, e: raise errors.AnsibleError("Invalid ini entry: %s - %s" % (t, str(e))) try: diff --git a/test/TestInventory.py b/test/TestInventory.py index 60ebeb7fc2e..43c9bc82ab8 100644 --- a/test/TestInventory.py +++ b/test/TestInventory.py @@ -55,7 +55,7 @@ class TestInventory(unittest.TestCase): 'thrudgelmir0', 'thrudgelmir1', 'thrudgelmir2', 'thrudgelmir3', 'thrudgelmir4', 'thrudgelmir5', 'Hotep-a', 'Hotep-b', 'Hotep-c', - 'BastC', 'BastD', ] + 'BastC', 'BastD', 'neptun', ] ##################################### ### Empty inventory format tests @@ -401,6 +401,11 @@ class TestInventory(unittest.TestCase): 'inventory_hostname_short': 'zeus', 'group_names': ['greek', 'major-god']} + def test_allows_equals_sign_in_var(self): + inventory = self.simple_inventory() + auth = inventory.get_variables('neptun')['auth'] + assert auth == 'YWRtaW46YWRtaW4=' + # test disabled as needs to be updated to model desired behavior # #def test_dir_inventory(self): diff --git a/test/simple_hosts b/test/simple_hosts index 669d92a32a4..4625b3dbabe 100644 --- a/test/simple_hosts +++ b/test/simple_hosts @@ -17,3 +17,6 @@ loki [egyptian] Hotep-[a:c] Bast[C:D] + +[auth] +neptun auth="YWRtaW46YWRtaW4="