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
0419fb74
Commit
0419fb74
authored
Aug 17, 2013
by
Mark Harrison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support check mode with pacman module
parent
58477207
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
library/packaging/pacman
+22
-4
No files found.
library/packaging/pacman
View file @
0419fb74
...
...
@@ -151,6 +151,21 @@ def install_packages(module, packages):
module
.
exit_json
(
changed
=
False
,
msg
=
"package(s) already installed"
)
def
check_packages
(
module
,
packages
,
state
):
would_be_changed
=
[]
for
package
in
packages
:
installed
=
query_package
(
module
,
package
)
if
((
state
==
"installed"
and
not
installed
)
or
(
state
==
"absent"
and
installed
)):
would_be_changed
.
append
(
package
)
if
would_be_changed
:
if
state
==
"absent"
:
state
=
"removed"
module
.
exit_json
(
changed
=
True
,
msg
=
"
%
s package(s) would be
%
s"
%
(
len
(
would_be_changed
),
state
))
else
:
module
.
exit_json
(
change
=
False
,
msg
=
"package(s) already
%
s"
%
state
)
def
main
():
module
=
AnsibleModule
(
...
...
@@ -158,7 +173,8 @@ def main():
state
=
dict
(
default
=
"installed"
,
choices
=
[
"installed"
,
"absent"
]),
update_cache
=
dict
(
default
=
"no"
,
aliases
=
[
"update-cache"
],
type
=
'bool'
),
recurse
=
dict
(
default
=
"no"
,
type
=
'bool'
),
name
=
dict
(
aliases
=
[
"pkg"
],
required
=
True
)))
name
=
dict
(
aliases
=
[
"pkg"
],
required
=
True
)),
supports_check_mode
=
True
)
if
not
os
.
path
.
exists
(
PACMAN_PATH
):
...
...
@@ -166,13 +182,15 @@ def main():
p
=
module
.
params
if
p
[
"update_cache"
]:
if
p
[
"update_cache"
]
and
not
module
.
check_mode
:
update_package_db
(
module
)
pkgs
=
p
[
"name"
]
.
split
(
","
)
if
p
[
"state"
]
==
"installed"
:
if
module
.
check_mode
:
check_packages
(
module
,
pkgs
,
p
[
'state'
])
elif
p
[
"state"
]
==
"installed"
:
install_packages
(
module
,
pkgs
)
elif
p
[
"state"
]
==
"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