summaryrefslogtreecommitdiffstats
path: root/library/rpm_q.py
diff options
context:
space:
mode:
authorMichael Gugino <mgugino@redhat.com>2017-12-13 12:42:32 -0500
committerMichael Gugino <mgugino@redhat.com>2017-12-18 16:46:22 -0500
commit801779eeb6f6308f81ae7c48409de7686c04a0aa (patch)
treeb6e4e6fcf8b672f5c5ed1269e7ed0c93258090f3 /library/rpm_q.py
parent84266ade6839f9a82e3111f12fce64b88a48845a (diff)
downloadopenshift-801779eeb6f6308f81ae7c48409de7686c04a0aa.tar.gz
openshift-801779eeb6f6308f81ae7c48409de7686c04a0aa.tar.bz2
openshift-801779eeb6f6308f81ae7c48409de7686c04a0aa.tar.xz
openshift-801779eeb6f6308f81ae7c48409de7686c04a0aa.zip
Relocate filter plugins to lib_utils
This commit relocates filter_plugings to lib_utils, changes the namespacing to prevent unintended use of older versions that may be present in filter_plugins/ directory on existing installs. Add lib_utils to meta depends for roles Also consolidate some plugins into lib_utils from various other areas. Update rpm spec, obsolete plugin rpms.
Diffstat (limited to 'library/rpm_q.py')
-rw-r--r--library/rpm_q.py72
1 files changed, 0 insertions, 72 deletions
diff --git a/library/rpm_q.py b/library/rpm_q.py
deleted file mode 100644
index 3dec50fc2..000000000
--- a/library/rpm_q.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-# (c) 2015, Tobias Florek <tob@butter.sh>
-# Licensed under the terms of the MIT License
-"""
-An ansible module to query the RPM database. For use, when yum/dnf are not
-available.
-"""
-
-# pylint: disable=redefined-builtin,wildcard-import,unused-wildcard-import
-from ansible.module_utils.basic import * # noqa: F403
-
-DOCUMENTATION = """
----
-module: rpm_q
-short_description: Query the RPM database
-author: Tobias Florek
-options:
- name:
- description:
- - The name of the package to query
- required: true
- state:
- description:
- - Whether the package is supposed to be installed or not
- choices: [present, absent]
- default: present
-"""
-
-EXAMPLES = """
-- rpm_q: name=ansible state=present
-- rpm_q: name=ansible state=absent
-"""
-
-RPM_BINARY = '/bin/rpm'
-
-
-def main():
- """
- Checks rpm -q for the named package and returns the installed packages
- or None if not installed.
- """
- module = AnsibleModule( # noqa: F405
- argument_spec=dict(
- name=dict(required=True),
- state=dict(default='present', choices=['present', 'absent'])
- ),
- supports_check_mode=True
- )
-
- name = module.params['name']
- state = module.params['state']
-
- # pylint: disable=invalid-name
- rc, out, err = module.run_command([RPM_BINARY, '-q', name])
-
- installed = out.rstrip('\n').split('\n')
-
- if rc != 0:
- if state == 'present':
- module.fail_json(msg="%s is not installed" % name, stdout=out, stderr=err, rc=rc)
- else:
- module.exit_json(changed=False)
- elif state == 'present':
- module.exit_json(changed=False, installed_versions=installed)
- else:
- module.fail_json(msg="%s is installed", installed_versions=installed)
-
-
-if __name__ == '__main__':
- main()