From 3506febbb9f4cf702bf0f8427bc800ee5a5cb54e Mon Sep 17 00:00:00 2001 From: Greg Date: Sun, 26 Feb 2017 01:14:45 -0500 Subject: [PATCH] Fixing issue related to writing ini files When the file is opened with rwa+ and the update file size is smaller than the original the ini file can become corrupt. The issue was noticed when we had comments at the top of /etc/yum/pluginconf.d/rhnplugin.conf after using the rhn_register module the file became correct. rwa+ also make no sense as the file is only written too and why would any appending need to happen? --- lib/ansible/module_utils/redhat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/redhat.py b/lib/ansible/module_utils/redhat.py index cc79f0f858e..1eb69385142 100644 --- a/lib/ansible/module_utils/redhat.py +++ b/lib/ansible/module_utils/redhat.py @@ -66,7 +66,7 @@ class RegistrationBase(object): cfg.set('main', 'enabled', 1) else: cfg.set('main', 'enabled', 0) - fd = open(plugin_conf, 'rwa+') + fd = open(plugin_conf, 'w+') cfg.write(fd) fd.close()