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
ae599d8a
Commit
ae599d8a
authored
Feb 20, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2115 from kavink/devel
teach apt module to support --check mode
parents
405471bb
0f166d87
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
library/apt
+9
-2
library/lineinfile
+4
-3
No files found.
library/apt
View file @
ae599d8a
...
...
@@ -141,6 +141,9 @@ def install(m, pkgspec, cache, upgrade=False, default_release=None, install_reco
if not install_recommends:
cmd += " --no-install-recommends"
if m.check_mode:
m.exit_json(changed=True)
rc, out, err = m.run_command(cmd)
if rc:
m.fail_json(msg="'
apt
-
get
install
%
s
' failed: %s" % (packages, err))
...
...
@@ -164,6 +167,10 @@ def remove(m, pkgspec, cache, purge=False):
if purge:
purge = '
--
purge
'
cmd = "%s -q -y %s remove %s" % (APT, purge,packages)
if m.check_mode:
m.exit_json(changed=True)
rc, out, err = m.run_command(cmd)
if rc:
m.fail_json(msg="'
apt
-
get
remove
%
s
' failed: %s" % (packages, err))
...
...
@@ -180,7 +187,8 @@ def main():
default_release = dict(default=None, aliases=['
default
-
release
']),
install_recommends = dict(default='
yes
', aliases=['
install
-
recommends
'], choices=['
yes
', '
no
']),
force = dict(default='
no
', choices=['
yes
', '
no
'])
)
),
supports_check_mode = True
)
try:
...
...
@@ -235,4 +243,3 @@ def main():
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
main()
library/lineinfile
View file @
ae599d8a
...
...
@@ -164,7 +164,7 @@ def present(module, dest, regexp, line, insertafter, insertbefore, create, backu
msg
=
'line added'
changed
=
True
if
changed
:
if
changed
and
not
module
.
check_mode
:
if
backup
and
os
.
path
.
exists
(
dest
):
module
.
backup_local
(
dest
)
f
=
open
(
dest
,
'wb'
)
...
...
@@ -189,7 +189,7 @@ def absent(module, dest, regexp, backup):
lines
=
filter
(
matcher
,
lines
)
changed
=
len
(
found
)
>
0
if
changed
:
if
changed
and
not
module
.
check_mode
:
if
backup
:
module
.
backup_local
(
dest
)
f
=
open
(
dest
,
'wb'
)
...
...
@@ -209,7 +209,8 @@ def main():
create
=
dict
(
default
=
False
,
choices
=
BOOLEANS
),
backup
=
dict
(
default
=
False
,
choices
=
BOOLEANS
),
),
mutually_exclusive
=
[[
'insertbefore'
,
'insertafter'
]]
mutually_exclusive
=
[[
'insertbefore'
,
'insertafter'
]],
supports_check_mode
=
True
)
params
=
module
.
params
...
...
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