Repository: openshift/openshift-ansible

Issue:
oc_group module errors if group doesn't exist
#### Description

When using the `oc_group` module to create a new group, the module errors and does not create the group.

```
- name: Ensure dedicated-admins group exists
  oc_group:
    name: dakinitestgroup
    state: present

TASK [oso_dedicated_admin : Ensure dedicated-admins group exists] ********************************************************************************************************************************************************************************************************************************************************************
Friday 15 June 2018  16:24:35 +0000 (0:00:01.866)       0:00:11.977 *********** 
fatal: [ded-int-aws-master-250b2]: FAILED! => {"changed": false, "msg": {"cmd": "/usr/bin/oc get group dakinitestgroup -o json -n default", "results": [{}], "returncode": 1, "stderr": "Error from server (NotFound): groups.user.openshift.io \"dakinitestgroup\" not found\n", "stdout": ""}}
```

##### Version

Please put the following version information in the code block
indicated below.

* Your ansible version per `ansible --version`

If you're operating from a **git clone**:

* The output of `git describe`

If you're running from playbooks installed via RPM

* The output of `rpm -q openshift-ansible`

Place the output between the code block below:

```
ansible 2.4.3.0
(vendored roles from openshift-ansible-3.10.0-0.50.0 )
```

##### Steps To Reproduce
1. Run the above code on an openshift cluster to create a group that doesn't yet exist.
2. 


##### Expected Results

Group should be created if it doesn't exist.

##### Observed Results

The task fails because the group doesn't exist.

```
TASK [oso_dedicated_admin : Ensure dedicated-admins group exists] ********************************************************************************************************************************************************************************************************************************************************************
Friday 15 June 2018  16:24:35 +0000 (0:00:01.866)       0:00:11.977 *********** 
fatal: [ded-int-aws-master-250b2]: FAILED! => {"changed": false, "msg": {"cmd": "/usr/bin/oc get group dakinitestgroup -o json -n default", "results": [{}], "returncode": 1, "stderr": "Error from server (NotFound): groups.user.openshift.io \"dakinitestgroup\" not found\n", "stdout": ""}}
```


Discussion:

Resolving patch:
diff --git a/roles/lib_openshift/library/oc_group.py b/roles/lib_openshift/library/oc_group.py
--- a/roles/lib_openshift/library/oc_group.py
+++ b/roles/lib_openshift/library/oc_group.py
@@ -1520,7 +1520,7 @@ def get(self):
         result = self._get(self.kind, self.config.name)
         if result['returncode'] == 0:
             self.group = Group(content=result['results'][0])
-        elif 'groups \"{}\" not found'.format(self.config.name) in result['stderr']:
+        elif 'groups.user.openshift.io \"{}\" not found'.format(self.config.name) in result['stderr']:
             result['returncode'] = 0
             result['results'] = [{}]
 
diff --git a/roles/lib_openshift/src/class/oc_group.py b/roles/lib_openshift/src/class/oc_group.py
--- a/roles/lib_openshift/src/class/oc_group.py
+++ b/roles/lib_openshift/src/class/oc_group.py
@@ -39,7 +39,7 @@ def get(self):
         result = self._get(self.kind, self.config.name)
         if result['returncode'] == 0:
             self.group = Group(content=result['results'][0])
-        elif 'groups \"{}\" not found'.format(self.config.name) in result['stderr']:
+        elif 'groups.user.openshift.io \"{}\" not found'.format(self.config.name) in result['stderr']:
             result['returncode'] = 0
             result['results'] = [{}]
 


Test patch:
diff --git a/roles/lib_openshift/src/test/unit/test_oc_group.py b/roles/lib_openshift/src/test/unit/test_oc_group.py
--- a/roles/lib_openshift/src/test/unit/test_oc_group.py
+++ b/roles/lib_openshift/src/test/unit/test_oc_group.py
@@ -46,8 +46,8 @@ def test_create_group(self, mock_run, mock_tmpfile_copy):
         }'''
 
         mock_run.side_effect = [
-            (1, '', 'Error from server: groups "acme" not found'),
-            (1, '', 'Error from server: groups "acme" not found'),
+            (1, '', 'Error from server: groups.user.openshift.io "acme" not found'),
+            (1, '', 'Error from server: groups.user.openshift.io "acme" not found'),
             (0, '', ''),
             (0, group, ''),
         ]
@@ -70,7 +70,7 @@ def test_failed_get_group(self, mock_run, mock_tmpfile_copy):
         params['name'] = 'noexist'
 
         mock_run.side_effect = [
-            (1, '', 'Error from server: groups "acme" not found'),
+            (1, '', 'Error from server: groups.user.openshift.io "acme" not found'),
         ]
 
         mock_tmpfile_copy.side_effect = [