Merge branch 'yum-module' of git://github.com/Tinche/ansible into testing_427

pull/2758/merge
Michael DeHaan 12 years ago
commit 17f3cb6dde

@ -68,7 +68,25 @@ options:
version_added: "0.9" version_added: "0.9"
default: null default: null
aliases: [] aliases: []
conf_file:
description:
- The remote yum configuration file to use for the transaction.
required: false
version_added: "0.6"
default: null
aliases: []
disable_gpg_check:
description:
- Whether to disable the GPG checking of signatures of packages being
installed. Has an effect only if state is I(present) or I(latest).
required: false
version_added: "1.2"
default: "no"
choices: ["yes", "no"]
aliases: []
examples: examples:
- code: yum name=httpd state=latest - code: yum name=httpd state=latest
- code: yum name=httpd state=removed - code: yum name=httpd state=removed
@ -564,7 +582,8 @@ def latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos):
module.exit_json(**res) module.exit_json(**res)
def ensure(module, state, pkgspec, conf_file, enablerepo, disablerepo): def ensure(module, state, pkgspec, conf_file, enablerepo, disablerepo,
disable_gpg_check):
# take multiple args comma separated # take multiple args comma separated
items = pkgspec.split(',') items = pkgspec.split(',')
@ -614,10 +633,14 @@ def ensure(module, state, pkgspec, conf_file, enablerepo, disablerepo):
module.fail_json(msg="Error accessing repos: %s" % e) module.fail_json(msg="Error accessing repos: %s" % e)
if state in ['installed', 'present']: if state in ['installed', 'present']:
if disable_gpg_check:
yum_basecmd.append('--nogpgcheck')
install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos) install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos)
elif state in ['removed', 'absent']: elif state in ['removed', 'absent']:
remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos) remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos)
elif state == 'latest': elif state == 'latest':
if disable_gpg_check:
yum_basecmd.append('--nogpgcheck')
latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos) latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos)
# should be caught by AnsibleModule argument_spec # should be caught by AnsibleModule argument_spec
@ -645,6 +668,8 @@ def main():
disablerepo=dict(), disablerepo=dict(),
list=dict(), list=dict(),
conf_file=dict(default=None), conf_file=dict(default=None),
disable_gpg_check=dict(required=False, default="no",
choices=BOOLEANS, type='bool'),
), ),
required_one_of = [['name','list']], required_one_of = [['name','list']],
mutually_exclusive = [['name','list']], mutually_exclusive = [['name','list']],
@ -664,7 +689,9 @@ def main():
state = params['state'] state = params['state']
enablerepo = params.get('enablerepo', '') enablerepo = params.get('enablerepo', '')
disablerepo = params.get('disablerepo', '') disablerepo = params.get('disablerepo', '')
res = ensure(module, state, pkg, params['conf_file'], enablerepo, disablerepo) disable_gpg_check = params['disable_gpg_check']
res = ensure(module, state, pkg, params['conf_file'], enablerepo,
disablerepo, disable_gpg_check)
module.fail_json(msg="we should never get here unless this all failed", **res) module.fail_json(msg="we should never get here unless this all failed", **res)
# this is magic, see lib/ansible/module_common.py # this is magic, see lib/ansible/module_common.py

Loading…
Cancel
Save