summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2015-05-29 08:09:31 -0400
committerGreg DeKoenigsberg <greg@eucalyptus.com>2015-06-16 11:33:12 -0400
commitce93a91a590a9eddeaddcfe9601db4f7f08b1cf6 (patch)
tree84640b5e8c73e10e2419c02f838ee64d0dd1225c
parente7ed08f762188244406e5fe1252c34ee64dcbfe7 (diff)
downloadansible-modules-extras-ce93a91a590a9eddeaddcfe9601db4f7f08b1cf6.tar.gz
Fix octal values for python 2.4
-rw-r--r--system/puppet.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/system/puppet.py b/system/puppet.py
index d6bc4348..46a5ea58 100644
--- a/system/puppet.py
+++ b/system/puppet.py
@@ -18,6 +18,7 @@
import json
import os
import pipes
+import stat
DOCUMENTATION = '''
---
@@ -82,8 +83,13 @@ def _write_structured_data(basedir, basename, data):
if not os.path.exists(basedir):
os.makedirs(basedir)
file_path = os.path.join(basedir, "{0}.json".format(basename))
+ # This is more complex than you might normally expect because we want to
+ # open the file with only u+rw set. Also, we use the stat constants
+ # because ansible still supports python 2.4 and the octal syntax changed
out_file = os.fdopen(
- os.open(file_path, os.O_CREAT | os.O_WRONLY, 0o600), 'w')
+ os.open(
+ file_path, os.O_CREAT | os.O_WRONLY,
+ stat.S_IRUSR | stat.S_IWUSR), 'w')
out_file.write(json.dumps(data).encode('utf8'))
out_file.close()