mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 05:12:45 +00:00
create non-existent ini file
fixing fail_json more verbose fail msg
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user