瀏覽代碼

Provide backup_ext functionality keeping backwards compatibility.

Kenny Woodson 7 年之前
父節點
當前提交
99bbbba238
共有 35 個文件被更改,包括 378 次插入251 次删除
  1. 10 8
      roles/lib_openshift/library/oc_adm_ca_server_cert.py
  2. 10 8
      roles/lib_openshift/library/oc_adm_csr.py
  3. 10 8
      roles/lib_openshift/library/oc_adm_manage_node.py
  4. 10 8
      roles/lib_openshift/library/oc_adm_policy_group.py
  5. 10 8
      roles/lib_openshift/library/oc_adm_policy_user.py
  6. 10 8
      roles/lib_openshift/library/oc_adm_registry.py
  7. 10 8
      roles/lib_openshift/library/oc_adm_router.py
  8. 10 8
      roles/lib_openshift/library/oc_clusterrole.py
  9. 10 8
      roles/lib_openshift/library/oc_configmap.py
  10. 10 8
      roles/lib_openshift/library/oc_edit.py
  11. 10 8
      roles/lib_openshift/library/oc_env.py
  12. 10 8
      roles/lib_openshift/library/oc_group.py
  13. 10 8
      roles/lib_openshift/library/oc_image.py
  14. 10 8
      roles/lib_openshift/library/oc_label.py
  15. 10 8
      roles/lib_openshift/library/oc_obj.py
  16. 10 8
      roles/lib_openshift/library/oc_objectvalidator.py
  17. 10 8
      roles/lib_openshift/library/oc_process.py
  18. 10 8
      roles/lib_openshift/library/oc_project.py
  19. 10 8
      roles/lib_openshift/library/oc_pvc.py
  20. 10 8
      roles/lib_openshift/library/oc_route.py
  21. 10 8
      roles/lib_openshift/library/oc_scale.py
  22. 10 8
      roles/lib_openshift/library/oc_secret.py
  23. 10 8
      roles/lib_openshift/library/oc_service.py
  24. 10 8
      roles/lib_openshift/library/oc_serviceaccount.py
  25. 10 8
      roles/lib_openshift/library/oc_serviceaccount_secret.py
  26. 10 8
      roles/lib_openshift/library/oc_storageclass.py
  27. 10 8
      roles/lib_openshift/library/oc_user.py
  28. 10 8
      roles/lib_openshift/library/oc_version.py
  29. 10 8
      roles/lib_openshift/library/oc_volume.py
  30. 18 9
      roles/lib_utils/library/yedit.py
  31. 2 1
      roles/lib_utils/src/ansible/yedit.py
  32. 10 8
      roles/lib_utils/src/class/yedit.py
  33. 6 0
      roles/lib_utils/src/doc/yedit
  34. 50 1
      roles/lib_utils/src/test/integration/yedit.yml
  35. 2 0
      roles/lib_utils/src/test/unit/test_yedit.py

+ 10 - 8
roles/lib_openshift/library/oc_adm_ca_server_cert.py

@@ -164,7 +164,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -177,6 +177,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -184,6 +185,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -378,7 +384,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -689,12 +695,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -764,6 +765,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_adm_csr.py

@@ -142,7 +142,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -155,6 +155,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -162,6 +163,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -356,7 +362,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -667,12 +673,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -742,6 +743,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_adm_manage_node.py

@@ -150,7 +150,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -163,6 +163,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -170,6 +171,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -364,7 +370,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -675,12 +681,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -750,6 +751,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_adm_policy_group.py

@@ -136,7 +136,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -149,6 +149,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -156,6 +157,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -350,7 +356,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -661,12 +667,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -736,6 +737,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_adm_policy_user.py

@@ -150,7 +150,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -163,6 +163,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -170,6 +171,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -364,7 +370,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -675,12 +681,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -750,6 +751,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_adm_registry.py

@@ -254,7 +254,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -267,6 +267,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -274,6 +275,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -468,7 +474,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -779,12 +785,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -854,6 +855,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_adm_router.py

@@ -279,7 +279,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -292,6 +292,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -299,6 +300,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -493,7 +499,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -804,12 +810,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -879,6 +880,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_clusterrole.py

@@ -128,7 +128,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -141,6 +141,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -148,6 +149,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -342,7 +348,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -653,12 +659,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -728,6 +729,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_configmap.py

@@ -134,7 +134,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -147,6 +147,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -154,6 +155,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -348,7 +354,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -659,12 +665,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -734,6 +735,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_edit.py

@@ -184,7 +184,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -197,6 +197,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -204,6 +205,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -398,7 +404,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -709,12 +715,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -784,6 +785,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_env.py

@@ -145,7 +145,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -158,6 +158,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -165,6 +166,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -359,7 +365,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -670,12 +676,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -745,6 +746,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_group.py

@@ -118,7 +118,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -131,6 +131,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -138,6 +139,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -332,7 +338,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -643,12 +649,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -718,6 +719,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_image.py

@@ -137,7 +137,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -150,6 +150,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -157,6 +158,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -351,7 +357,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -662,12 +668,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -737,6 +738,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_label.py

@@ -154,7 +154,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -167,6 +167,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -174,6 +175,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -368,7 +374,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -679,12 +685,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -754,6 +755,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_obj.py

@@ -163,7 +163,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -176,6 +176,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -183,6 +184,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -377,7 +383,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -688,12 +694,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -763,6 +764,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_objectvalidator.py

@@ -89,7 +89,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -102,6 +102,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -109,6 +110,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -303,7 +309,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -614,12 +620,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -689,6 +690,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_process.py

@@ -146,7 +146,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -159,6 +159,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -166,6 +167,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -360,7 +366,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -671,12 +677,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -746,6 +747,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_project.py

@@ -143,7 +143,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -156,6 +156,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -163,6 +164,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -357,7 +363,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -668,12 +674,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -743,6 +744,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_pvc.py

@@ -150,7 +150,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -163,6 +163,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -170,6 +171,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -364,7 +370,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -675,12 +681,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -750,6 +751,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_route.py

@@ -194,7 +194,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -207,6 +207,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -214,6 +215,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -408,7 +414,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -719,12 +725,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -794,6 +795,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_scale.py

@@ -132,7 +132,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -145,6 +145,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -152,6 +153,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -346,7 +352,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -657,12 +663,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -732,6 +733,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_secret.py

@@ -190,7 +190,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -203,6 +203,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -210,6 +211,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -404,7 +410,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -715,12 +721,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -790,6 +791,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_service.py

@@ -197,7 +197,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -210,6 +210,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -217,6 +218,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -411,7 +417,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -722,12 +728,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -797,6 +798,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_serviceaccount.py

@@ -130,7 +130,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -143,6 +143,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -150,6 +151,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -344,7 +350,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -655,12 +661,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -730,6 +731,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_serviceaccount_secret.py

@@ -130,7 +130,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -143,6 +143,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -150,6 +151,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -344,7 +350,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -655,12 +661,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -730,6 +731,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_storageclass.py

@@ -148,7 +148,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -161,6 +161,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -168,6 +169,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -362,7 +368,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -673,12 +679,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -748,6 +749,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_user.py

@@ -190,7 +190,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -203,6 +203,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -210,6 +211,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -404,7 +410,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -715,12 +721,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -790,6 +791,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_version.py

@@ -102,7 +102,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -115,6 +115,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -122,6 +123,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -316,7 +322,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -627,12 +633,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -702,6 +703,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 10 - 8
roles/lib_openshift/library/oc_volume.py

@@ -179,7 +179,7 @@ class YeditException(Exception):  # pragma: no cover
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):  # pragma: no cover
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -192,6 +192,7 @@ class Yedit(object):  # pragma: no cover
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -199,6 +200,11 @@ class Yedit(object):  # pragma: no cover
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -393,7 +399,7 @@ class Yedit(object):  # pragma: no cover
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -704,12 +710,7 @@ class Yedit(object):  # pragma: no cover
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -779,6 +780,7 @@ class Yedit(object):  # pragma: no cover
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 18 - 9
roles/lib_utils/library/yedit.py

@@ -143,6 +143,12 @@ options:
     required: false
     default: false
     aliases: []
+  backup_ext:
+    description:
+    - The backup file's appended string.
+    required: false
+    default: .orig
+    aliases: []
   backup:
     description:
     - Whether to make a backup copy of the current file when performing an
@@ -211,7 +217,7 @@ class YeditException(Exception):
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -224,6 +230,7 @@ class Yedit(object):
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -231,6 +238,11 @@ class Yedit(object):
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -425,7 +437,7 @@ class Yedit(object):
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -736,12 +748,7 @@ class Yedit(object):
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -811,6 +818,7 @@ class Yedit(object):
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']
@@ -932,7 +940,8 @@ def main():
             curr_value_format=dict(default='yaml',
                                    choices=['yaml', 'json', 'str'],
                                    type='str'),
-            backup=dict(default=True, type='bool'),
+            backup=dict(default=False, type='bool'),
+            backup_ext=dict(default=".{}".format(time.strftime("%Y%m%dT%H%M%S")), type='str'),
             separator=dict(default='.', type='str'),
             edits=dict(default=None, type='list'),
         ),

+ 2 - 1
roles/lib_utils/src/ansible/yedit.py

@@ -24,7 +24,8 @@ def main():
             curr_value_format=dict(default='yaml',
                                    choices=['yaml', 'json', 'str'],
                                    type='str'),
-            backup=dict(default=True, type='bool'),
+            backup=dict(default=False, type='bool'),
+            backup_ext=dict(default=".{}".format(time.strftime("%Y%m%dT%H%M%S")), type='str'),
             separator=dict(default='.', type='str'),
             edits=dict(default=None, type='list'),
         ),

+ 10 - 8
roles/lib_utils/src/class/yedit.py

@@ -7,7 +7,7 @@ class YeditException(Exception):
     pass
 
 
-# pylint: disable=too-many-public-methods
+# pylint: disable=too-many-public-methods,too-many-instance-attributes
 class Yedit(object):
     ''' Class to modify yaml files '''
     re_valid_key = r"(((\[-?\d+\])|([0-9a-zA-Z%s/_-]+)).?)+$"
@@ -20,6 +20,7 @@ class Yedit(object):
                  content=None,
                  content_type='yaml',
                  separator='.',
+                 backup_ext=None,
                  backup=False):
         self.content = content
         self._separator = separator
@@ -27,6 +28,11 @@ class Yedit(object):
         self.__yaml_dict = content
         self.content_type = content_type
         self.backup = backup
+        if backup_ext is None:
+            self.backup_ext = ".{}".format(time.strftime("%Y%m%dT%H%M%S"))
+        else:
+            self.backup_ext = backup_ext
+
         self.load(content_type=self.content_type)
         if self.__yaml_dict is None:
             self.__yaml_dict = {}
@@ -221,7 +227,7 @@ class Yedit(object):
             raise YeditException('Please specify a filename.')
 
         if self.backup and self.file_exists():
-            shutil.copy(self.filename, '{}.{}'.format(self.filename, time.strftime("%Y%m%dT%H%M%S")))
+            shutil.copy(self.filename, '{}{}'.format(self.filename, self.backup_ext))
 
         # Try to set format attributes if supported
         try:
@@ -532,12 +538,7 @@ class Yedit(object):
 
         curr_value = invalue
         if val_type == 'yaml':
-            try:
-                # AUDIT:maybe-no-member makes sense due to different yaml libraries
-                # pylint: disable=maybe-no-member
-                curr_value = yaml.safe_load(invalue, Loader=yaml.RoundTripLoader)
-            except AttributeError:
-                curr_value = yaml.safe_load(invalue)
+            curr_value = yaml.safe_load(str(invalue))
         elif val_type == 'json':
             curr_value = json.loads(invalue)
 
@@ -607,6 +608,7 @@ class Yedit(object):
         yamlfile = Yedit(filename=params['src'],
                          backup=params['backup'],
                          content_type=params['content_type'],
+                         backup_ext=params['backup_ext'],
                          separator=params['separator'])
 
         state = params['state']

+ 6 - 0
roles/lib_utils/src/doc/yedit

@@ -95,6 +95,12 @@ options:
     required: false
     default: false
     aliases: []
+  backup_ext:
+    description:
+    - The backup file's appended string.
+    required: false
+    default: .orig
+    aliases: []
   backup:
     description:
     - Whether to make a backup copy of the current file when performing an

+ 50 - 1
roles/lib_utils/src/test/integration/yedit.yml

@@ -11,7 +11,6 @@
   vars:
     test_file: kube-manager-test.yaml
     test: test
-  strategy: debug
 
   post_tasks:
   - name: copy the kube-manager.yaml file so that we have a pristine copy each time
@@ -277,3 +276,53 @@
       - absentout.result == ['oranges']
       - absentout.result|length == 1
       ###### end test state absent on list item ####
+
+
+  ###### test backup ext on filename #####
+  - name: test backup ext on file
+    yedit:
+      state: present
+      src: "{{ test_file }}"
+      key: test
+      backup: true
+      backup_ext: .orig
+      value: "{{ lookup('pipe', 'date +%s') }}"
+
+  - name: second call which should be noop
+    yedit:
+      state: present
+      src: "{{ test_file }}"
+      key: test
+      backup: true
+      value: "{{ lookup('pipe', 'date +%s') }}"
+
+  - name: stat file
+    stat:
+      path: "{{ test_file }}.orig"
+    register: statout
+
+  - assert:
+      that:
+      - statout.stat.exists
+
+  - name: set the date string for backup_ext
+    set_fact:
+      date_str: "{{ lookup('pipe', 'date +%s') }}"
+
+  - yedit:
+      state: present
+      src: "{{ test_file }}"
+      key: test
+      backup: true
+      backup_ext: "{{ date_str }}"
+      value: "{{ lookup('pipe', 'date +%s') }}"
+
+  - name: stat file
+    stat:
+      path: "{{ test_file }}{{ date_str }}"
+    register: statout
+
+  - assert:
+      that:
+      - statout.stat.exists
+      ###### end test state absent on list item ####

+ 2 - 0
roles/lib_utils/src/test/unit/test_yedit.py

@@ -365,6 +365,7 @@ class YeditTest(unittest.TestCase):
         params = {
             'src': None,
             'backup': False,
+            'backup_ext': '',
             'separator': '.',
             'state': 'present',
             'edits': [],
@@ -388,6 +389,7 @@ class YeditTest(unittest.TestCase):
         params = {
             'src': '/tmp/test',
             'backup': False,
+            'backup_ext': '',
             'separator': '.',
             'state': 'present',
             'edits': [],