From 52d499d268f57b962f09170c35adf450ec53ae14 Mon Sep 17 00:00:00 2001 From: Charles Paul Date: Mon, 23 Nov 2015 22:51:08 +0900 Subject: [PATCH] create non-existent ini file fixing fail_json more verbose fail msg --- lib/ansible/modules/files/ini_file.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ansible/modules/files/ini_file.py b/lib/ansible/modules/files/ini_file.py index d837c329d4..fe583c65af 100644 --- a/lib/ansible/modules/files/ini_file.py +++ b/lib/ansible/modules/files/ini_file.py @@ -96,6 +96,7 @@ EXAMPLES = ''' import ConfigParser import sys +import os # ============================================================== # do_ini @@ -103,6 +104,11 @@ import sys def do_ini(module, filename, section=None, option=None, value=None, state='present', backup=False): + if not os.path.exists(filename): + try: + open(filename,'w').close() + except: + module.fail_json(msg="Destination file %s not writable" % filename) ini_file = open(filename, 'r') try: ini_lines = ini_file.readlines()