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
35b91835
Commit
35b91835
authored
Jul 23, 2013
by
Eivind Uggedal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pacman module: recursive remove support
parent
d1effecb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletions
+17
-1
library/packaging/pacman
+17
-1
No files found.
library/packaging/pacman
View file @
35b91835
...
@@ -45,6 +45,14 @@ options:
...
@@ -45,6 +45,14 @@ options:
default: "no"
default: "no"
choices: [ "yes", "no" ]
choices: [ "yes", "no" ]
recursive:
description:
- remove all not explicitly installed dependencies not required
by other packages of the package to remove
required: false
default: "no"
choices: [ "yes", "no" ]
author: Afterburn
author: Afterburn
notes: []
notes: []
'''
'''
...
@@ -59,6 +67,9 @@ EXAMPLES = '''
...
@@ -59,6 +67,9 @@ EXAMPLES = '''
# Remove packages foo and bar
# Remove packages foo and bar
- pacman: name=foo,bar state=absent
- pacman: name=foo,bar state=absent
# Recursively remove package baz
- pacman: name=baz state=absent recursive=yes
# Update the package database (pacman -Syy) and install bar (bar will be the updated if a newer version exists)
# Update the package database (pacman -Syy) and install bar (bar will be the updated if a newer version exists)
- pacman: name=bar, state=installed, update_cache=yes
- pacman: name=bar, state=installed, update_cache=yes
'''
'''
...
@@ -92,6 +103,10 @@ def update_package_db(module):
...
@@ -92,6 +103,10 @@ def update_package_db(module):
def
remove_packages
(
module
,
packages
):
def
remove_packages
(
module
,
packages
):
if
module
.
params
[
"recursive"
]:
args
=
"Rs"
else
:
args
=
"R"
remove_c
=
0
remove_c
=
0
# Using a for loop incase of error, we can report the package that failed
# Using a for loop incase of error, we can report the package that failed
...
@@ -100,7 +115,7 @@ def remove_packages(module, packages):
...
@@ -100,7 +115,7 @@ def remove_packages(module, packages):
if
not
query_package
(
module
,
package
):
if
not
query_package
(
module
,
package
):
continue
continue
rc
=
os
.
system
(
"pacman -
R
%
s --noconfirm > /dev/null"
%
(
package
))
rc
=
os
.
system
(
"pacman -
%
s
%
s --noconfirm > /dev/null"
%
(
args
,
package
))
if
rc
!=
0
:
if
rc
!=
0
:
module
.
fail_json
(
msg
=
"failed to remove
%
s"
%
(
package
))
module
.
fail_json
(
msg
=
"failed to remove
%
s"
%
(
package
))
...
@@ -141,6 +156,7 @@ def main():
...
@@ -141,6 +156,7 @@ def main():
argument_spec
=
dict
(
argument_spec
=
dict
(
state
=
dict
(
default
=
"installed"
,
choices
=
[
"installed"
,
"absent"
]),
state
=
dict
(
default
=
"installed"
,
choices
=
[
"installed"
,
"absent"
]),
update_cache
=
dict
(
default
=
"no"
,
aliases
=
[
"update-cache"
],
type
=
'bool'
),
update_cache
=
dict
(
default
=
"no"
,
aliases
=
[
"update-cache"
],
type
=
'bool'
),
recursive
=
dict
(
default
=
"no"
,
type
=
'bool'
),
name
=
dict
(
aliases
=
[
"pkg"
],
required
=
True
)))
name
=
dict
(
aliases
=
[
"pkg"
],
required
=
True
)))
...
...
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