fixes bug: puppet module is no longer updating persistent external facts (#38026)

(cherry picked from commit 0efbb702b9)
pull/37668/merge
Fabian Zimmermann 7 years ago committed by Matt Davis
parent f91cda4b02
commit 5ac9a7418f

@ -111,16 +111,16 @@ def _get_facter_dir():
def _write_structured_data(basedir, basename, data): def _write_structured_data(basedir, basename, data):
if not os.path.exists(basedir): if not os.path.exists(basedir):
os.makedirs(basedir) os.makedirs(basedir)
file_path = os.path.join(basedir, "{0}.json".format(basename)) file_path = os.path.join(basedir, "{0}.json".format(basename))
# This is more complex than you might normally expect because we want to # 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 # 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 # because ansible still supports python 2.4 and the octal syntax changed
out_file = os.fdopen( out_file = os.fdopen(
os.open( os.open(
file_path, os.O_CREAT | os.O_WRONLY, file_path, os.O_CREAT | os.O_WRONLY,
stat.S_IRUSR | stat.S_IWUSR), 'w') stat.S_IRUSR | stat.S_IWUSR), 'w')
out_file.write(json.dumps(data).encode('utf8')) out_file.write(json.dumps(data).encode('utf8'))
out_file.close() out_file.close()
def main(): def main():

Loading…
Cancel
Save