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
5c05982d
Commit
5c05982d
authored
Mar 16, 2014
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6448 from jirutka/fix-5679-2
Fix #5679 again after recent changes in core
parents
d5856bd4
2bfaacd1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
library/files/lineinfile
+2
-3
test/integration/roles/test_lineinfile/tasks/main.yml
+18
-0
No files found.
library/files/lineinfile
View file @
5c05982d
...
@@ -350,9 +350,8 @@ def main():
...
@@ -350,9 +350,8 @@ def main():
if
ins_bef
is
None
and
ins_aft
is
None
:
if
ins_bef
is
None
and
ins_aft
is
None
:
ins_aft
=
'EOF'
ins_aft
=
'EOF'
# Replace the newline character with an actual newline. Don't replace
# Replace the newline character with an actual newline.
# escaped \\n, hence sub and not str.replace.
line
=
params
[
'line'
]
.
decode
(
'string_escape'
)
line
=
re
.
sub
(
r'\n'
,
os
.
linesep
,
params
[
'line'
])
present
(
module
,
dest
,
params
[
'regexp'
],
line
,
present
(
module
,
dest
,
params
[
'regexp'
],
line
,
ins_aft
,
ins_bef
,
create
,
backup
,
backrefs
)
ins_aft
,
ins_bef
,
create
,
backup
,
backrefs
)
...
...
test/integration/roles/test_lineinfile/tasks/main.yml
View file @
5c05982d
...
@@ -209,3 +209,21 @@
...
@@ -209,3 +209,21 @@
that
:
that
:
-
"
result.stat.md5
==
'fef1d487711facfd7aa2c87d788c19d9'"
-
"
result.stat.md5
==
'fef1d487711facfd7aa2c87d788c19d9'"
-
name
:
insert a multiple lines at the end of the file
lineinfile
:
dest={{output_dir}}/test.txt state=present line="This is a line\nwith \\\n character" insertafter="EOF"
register
:
result
-
name
:
assert that the multiple lines was inserted
assert
:
that
:
-
"
result.changed
==
true"
-
"
result.msg
==
'line
added'"
-
stat
:
path={{output_dir}}/test.txt
register
:
result
-
name
:
assert test md5 matches after insert the multiple lines
assert
:
that
:
-
"
result.stat.md5
==
'c2510d5bc8fdef8e752b8f8e74c784c2'"
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