From 5a7695c440956d881ce22a04bb2c37b7d60ea7ee Mon Sep 17 00:00:00 2001 From: Peter Oliver Date: Wed, 31 Dec 2014 13:27:21 +0000 Subject: [PATCH] Try to fix up commas in version numbers. --- packaging/os/pkg5.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packaging/os/pkg5.py b/packaging/os/pkg5.py index 271b95fffe6..bbdf3eb006b 100644 --- a/packaging/os/pkg5.py +++ b/packaging/os/pkg5.py @@ -48,6 +48,7 @@ EXAMPLES = ''' - pkg5: name=service/network/finger state=absent ''' + def main(): module = AnsibleModule( argument_spec=dict( @@ -67,12 +68,26 @@ def main(): ) params = module.params + packages = [] + + # pkg(5) FRMIs include a comma before the release number, but + # AnsibleModule will have split this into multiple items for us. + # Try to spot where this has happened and fix it. + for fragment in params['name']: + if ( + re.search('^\d+(?:\.\d+)*', fragment) + and packages and re.search('@[^,]*$', packages[-1]) + ): + packages[-1] += ',' + fragment + else: + packages.append(fragment) + if params['state'] in ['present', 'installed']: - ensure(module, 'present', params['name']) + ensure(module, 'present', packages) elif params['state'] in ['latest']: - ensure(module, 'latest', params['name']) + ensure(module, 'latest', packages) elif params['state'] in ['absent', 'uninstalled', 'removed']: - ensure(module, 'absent', params['name']) + ensure(module, 'absent', packages) def ensure(module, state, packages):