Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
5a330128
Commit
5a330128
authored
Nov 27, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1692 from jpmens/ini_file2
ini_file: prohibit section name 'default'
parents
304d06a5
910f1c04
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
library/ini_file
+10
-0
No files found.
library/ini_file
View file @
5a330128
...
...
@@ -74,6 +74,10 @@ examples:
notes:
- While it is possible to add an I(option) without specifying a I(value), this makes
no sense.
- A section named C(default) cannot be added by the module, but if it exists, individual
options within the section can be updated. (This is a limitation of Python's I(ConfigParser).)
Either use M(template) to create a base INI file with a C([default]) section, or use
M(lineinfile) to add the missing line.
requirements: [ ConfigParser ]
author: Jan-Piet Mens
'''
...
...
@@ -112,6 +116,9 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
if
state
==
'present'
:
if
cp
.
has_section
(
section
)
==
False
:
if
section
.
upper
()
==
'DEFAULT'
:
module
.
fail_json
(
msg
=
"[DEFAULT] is an illegal section name"
)
cp
.
add_section
(
section
)
changed
=
True
...
...
@@ -121,6 +128,9 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
if
str
(
value
)
!=
str
(
oldvalue
):
cp
.
set
(
section
,
option
,
value
)
changed
=
True
except
ConfigParser
.
NoSectionError
:
cp
.
set
(
section
,
option
,
value
)
changed
=
True
except
ConfigParser
.
NoOptionError
:
cp
.
set
(
section
,
option
,
value
)
changed
=
True
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment