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
a9fcea58
Commit
a9fcea58
authored
May 29, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'escape' of
git://github.com/ngrilly/ansible
into repr
parents
0a28358e
75ceb805
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
15 deletions
+17
-15
hacking/test-module
+3
-3
lib/ansible/runner/__init__.py
+5
-3
library/files/lineinfile
+1
-1
test/TestRunner.py
+8
-8
No files found.
hacking/test-module
View file @
a9fcea58
...
...
@@ -85,10 +85,10 @@ def boilerplate_module(modfile, args):
if
included_boilerplate
:
module_data
=
module_data
.
replace
(
module_common
.
REPLACER
,
module_common
.
MODULE_COMMON
)
encoded_args
=
"
\"\"\"
%
s
\"\"\"
"
%
args
.
replace
(
"
\"
"
,
"
\\\"
"
)
encoded_args
=
repr
(
str
(
args
)
)
module_data
=
module_data
.
replace
(
module_common
.
REPLACER_ARGS
,
encoded_args
)
encoded_lang
=
"
\"\"\"
%
s
\"\"\"
"
%
C
.
DEFAULT_MODULE_LANG
empty_complex
=
"
\"\"\"
%
s
\"\"\"
"
%
"{}"
encoded_lang
=
repr
(
C
.
DEFAULT_MODULE_LANG
)
empty_complex
=
repr
(
"{}"
)
module_data
=
module_data
.
replace
(
module_common
.
REPLACER_LANG
,
encoded_lang
)
module_data
=
module_data
.
replace
(
'syslog.LOG_USER'
,
"syslog.
%
s"
%
C
.
DEFAULT_SYSLOG_FACILITY
)
module_data
=
module_data
.
replace
(
module_common
.
REPLACER_COMPLEX
,
empty_complex
)
...
...
lib/ansible/runner/__init__.py
View file @
a9fcea58
...
...
@@ -699,9 +699,11 @@ class Runner(object):
module_style
=
'non_native_want_json'
complex_args_json
=
utils
.
jsonify
(
complex_args
)
encoded_args
=
"
\"\"\"
%
s
\"\"\"
"
%
module_args
.
replace
(
"
\"
"
,
"
\\\"
"
)
encoded_lang
=
"
\"\"\"
%
s
\"\"\"
"
%
C
.
DEFAULT_MODULE_LANG
encoded_complex
=
"
\"\"\"
%
s
\"\"\"
"
%
complex_args_json
.
replace
(
"
\\
"
,
"
\\\\
"
)
# We force conversion of module_args to str because module_common calls shlex.split,
# a standard library function that incorrectly handles Unicode input before Python 2.7.3.
encoded_args
=
repr
(
str
(
module_args
))
encoded_lang
=
repr
(
C
.
DEFAULT_MODULE_LANG
)
encoded_complex
=
repr
(
complex_args_json
)
module_data
=
module_data
.
replace
(
module_common
.
REPLACER
,
module_common
.
MODULE_COMMON
)
module_data
=
module_data
.
replace
(
module_common
.
REPLACER_ARGS
,
encoded_args
)
...
...
library/files/lineinfile
View file @
a9fcea58
...
...
@@ -126,7 +126,7 @@ EXAMPLES = r"""
lineinfile: dest=/etc/sudoers state=present regexp='^
%
wheel' line='
%
wheel ALL=(ALL) NOPASSWD: ALL'
lineinfile: dest=/opt/jboss-as/bin/standalone.conf regexp='^(.*)Xms(\d+)m(.*)$' line='\
\1Xms${xms}m\
\3' backrefs=yes
lineinfile: dest=/opt/jboss-as/bin/standalone.conf regexp='^(.*)Xms(\d+)m(.*)$' line='\
1Xms${xms}m
\3' backrefs=yes
"""
def
write_changes
(
module
,
lines
,
dest
):
...
...
test/TestRunner.py
View file @
a9fcea58
...
...
@@ -477,7 +477,7 @@ class TestRunner(unittest.TestCase):
# The order of the test cases is important
# The regexp doesn't match, so the line will not be added anywhere.
testline
=
r'\
\
1: Line added by default at the end of the file.'
testline
=
r'\1: Line added by default at the end of the file.'
testcase
=
(
'lineinfile'
,
[
"dest=
%
s"
%
sample
,
"regexp='^(First): '"
,
...
...
@@ -492,7 +492,7 @@ class TestRunner(unittest.TestCase):
# insertafter with EOF
# The regexp doesn't match, so the line will not be added anywhere.
testline
=
r'\
\
1: Line added with insertafter=EOF'
testline
=
r'\1: Line added with insertafter=EOF'
testcase
=
(
'lineinfile'
,
[
"dest=
%
s"
%
sample
,
"insertafter=EOF"
,
...
...
@@ -508,7 +508,7 @@ class TestRunner(unittest.TestCase):
# with invalid insertafter regex
# The regexp doesn't match, so do nothing.
testline
=
r'\
\
1: Line added with an invalid insertafter regex'
testline
=
r'\1: Line added with an invalid insertafter regex'
testcase
=
(
'lineinfile'
,
[
"dest=
%
s"
%
sample
,
"insertafter='^abcdefgh'"
,
...
...
@@ -522,7 +522,7 @@ class TestRunner(unittest.TestCase):
# with an insertafter regex
# The regexp doesn't match, so do nothing.
testline
=
r'\
\
1: Line added with a valid insertafter regex'
testline
=
r'\1: Line added with a valid insertafter regex'
testcase
=
(
'lineinfile'
,
[
"dest=
%
s"
%
sample
,
"insertafter='^receive messages to '"
,
...
...
@@ -541,7 +541,7 @@ class TestRunner(unittest.TestCase):
target_line
=
'combination of microphone, speaker, keyboard and display. It can send and'
idx
=
artifact
.
index
(
target_line
)
testline
=
r'\
\
1 of megaphone'
testline
=
r'\1 of megaphone'
testline_after
=
'combination of megaphone'
testcase
=
(
'lineinfile'
,
[
"dest=
%
s"
%
sample
,
...
...
@@ -558,7 +558,7 @@ class TestRunner(unittest.TestCase):
assert
target_line
not
in
artifact
# Go again, should be unchanged now.
testline
=
r'\
\
1 of megaphone'
testline
=
r'\1 of megaphone'
testline_after
=
'combination of megaphone'
testcase
=
(
'lineinfile'
,
[
"dest=
%
s"
%
sample
,
...
...
@@ -574,11 +574,11 @@ class TestRunner(unittest.TestCase):
f
=
open
(
sample
,
'a+'
)
f
.
write
(
"1 + 1 = 3"
+
os
.
linesep
)
f
.
close
()
testline
=
r"2 + \
\
g<num> = 3"
testline
=
r"2 + \g<num> = 3"
testline_after
=
"2 + 1 = 3"
testcase
=
(
'lineinfile'
,
[
"dest=
%
s"
%
sample
,
r"regexp='1 \
\+ (?P<num>\
\d) = 3'"
,
r"regexp='1 \
+ (?P<num>
\d) = 3'"
,
"line='
%
s'"
%
testline
,
"backrefs=yes"
,
])
...
...
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