diff options
author | Eivind Uggedal <eivind@uggedal.com> | 2013-07-23 15:01:13 +0200 |
---|---|---|
committer | Eivind Uggedal <eivind@uggedal.com> | 2013-07-23 15:01:13 +0200 |
commit | 35b918359b6bd9b1d4e09131b0e86b577a793155 (patch) | |
tree | ce917e344d43bdb45907842178a820faef4ce041 /library | |
parent | d1effecb2ef073e478c67a7ca39cf56708a66a48 (diff) | |
download | ansible-35b918359b6bd9b1d4e09131b0e86b577a793155.tar.gz |
Pacman module: recursive remove support
Diffstat (limited to 'library')
-rw-r--r-- | library/packaging/pacman | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/library/packaging/pacman b/library/packaging/pacman index e2dbd5b2a6..653d1a3b61 100644 --- a/library/packaging/pacman +++ b/library/packaging/pacman @@ -45,6 +45,14 @@ options: default: "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 notes: [] ''' @@ -59,6 +67,9 @@ EXAMPLES = ''' # Remove packages foo and bar - 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) - pacman: name=bar, state=installed, update_cache=yes ''' @@ -92,6 +103,10 @@ def update_package_db(module): def remove_packages(module, packages): + if module.params["recursive"]: + args = "Rs" + else: + args = "R" remove_c = 0 # Using a for loop incase of error, we can report the package that failed @@ -100,7 +115,7 @@ def remove_packages(module, packages): if not query_package(module, package): 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: module.fail_json(msg="failed to remove %s" % (package)) @@ -141,6 +156,7 @@ def main(): argument_spec = dict( state = dict(default="installed", choices=["installed","absent"]), update_cache = dict(default="no", aliases=["update-cache"], type='bool'), + recursive = dict(default="no", type='bool'), name = dict(aliases=["pkg"], required=True))) |