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
af051d6f
Commit
af051d6f
authored
Jun 15, 2013
by
Jan-Piet Mens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ini_file: add support for lists of options/values
parent
cf2ddb6f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
2 deletions
+25
-2
library/files/ini_file
+25
-2
No files found.
library/files/ini_file
View file @
af051d6f
...
@@ -107,12 +107,21 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
...
@@ -107,12 +107,21 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
changed
=
True
changed
=
True
else
:
else
:
if
option
is
not
None
:
if
option
is
not
None
:
if
type
(
option
)
==
str
:
try
:
try
:
if
cp
.
get
(
section
,
option
):
if
cp
.
get
(
section
,
option
):
cp
.
remove_option
(
section
,
option
)
cp
.
remove_option
(
section
,
option
)
changed
=
True
changed
=
True
except
:
except
:
pass
pass
else
:
for
o
in
option
:
try
:
if
cp
.
get
(
section
,
o
):
cp
.
remove_option
(
section
,
o
)
changed
=
True
except
:
pass
if
state
==
'present'
:
if
state
==
'present'
:
if
cp
.
has_section
(
section
)
==
False
:
if
cp
.
has_section
(
section
)
==
False
:
...
@@ -123,6 +132,20 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
...
@@ -123,6 +132,20 @@ def do_ini(module, filename, section=None, option=None, value=None, state='prese
changed
=
True
changed
=
True
if
option
is
not
None
and
value
is
not
None
:
if
option
is
not
None
and
value
is
not
None
:
olist
=
[]
vlist
=
[]
if
type
(
option
)
==
str
and
type
(
value
)
==
str
:
olist
.
append
(
option
)
vlist
.
append
(
value
)
else
:
olist
=
list
(
option
)
vlist
=
list
(
value
)
if
len
(
olist
)
!=
len
(
vlist
):
module
.
fail_json
(
msg
=
"Option and value lists must be of same lengths"
)
n
=
0
for
option
in
olist
:
value
=
vlist
[
n
]
n
=
n
+
1
try
:
try
:
oldvalue
=
cp
.
get
(
section
,
option
)
oldvalue
=
cp
.
get
(
section
,
option
)
if
str
(
value
)
!=
str
(
oldvalue
):
if
str
(
value
)
!=
str
(
oldvalue
):
...
@@ -156,8 +179,8 @@ def main():
...
@@ -156,8 +179,8 @@ def main():
argument_spec
=
dict
(
argument_spec
=
dict
(
dest
=
dict
(
required
=
True
),
dest
=
dict
(
required
=
True
),
section
=
dict
(
required
=
True
),
section
=
dict
(
required
=
True
),
option
=
dict
(
required
=
False
),
option
=
dict
(
required
=
False
,
type
=
'list'
),
value
=
dict
(
required
=
False
),
value
=
dict
(
required
=
False
,
type
=
'list'
),
backup
=
dict
(
default
=
'no'
,
type
=
'bool'
),
backup
=
dict
(
default
=
'no'
,
type
=
'bool'
),
state
=
dict
(
default
=
'present'
,
choices
=
[
'present'
,
'absent'
])
state
=
dict
(
default
=
'present'
,
choices
=
[
'present'
,
'absent'
])
),
),
...
...
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