diff options
author | Tin Tvrtkovic <tinchester@gmail.com> | 2013-04-23 18:12:37 +0200 |
---|---|---|
committer | Tin Tvrtkovic <tinchester@gmail.com> | 2013-04-23 18:12:37 +0200 |
commit | 66bcba7f19ba243849e65f717b54757eb033585f (patch) | |
tree | ecbab05080d98f2d016617e441387aa19d5a33a1 /library/yum | |
parent | c601e53fce235f33088e4eb0cd1fa0b1562d3481 (diff) | |
download | ansible-66bcba7f19ba243849e65f717b54757eb033585f.tar.gz |
disable_gpg_check in the yum module.
Diffstat (limited to 'library/yum')
-rw-r--r-- | library/yum | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/library/yum b/library/yum index c11af7dbba..921b13db1a 100644 --- a/library/yum +++ b/library/yum @@ -68,7 +68,25 @@ options: version_added: "0.9" default: null 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: - code: yum name=httpd state=latest - 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) -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 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) 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) elif state in ['removed', 'absent']: remove(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos) elif state == 'latest': + if disable_gpg_check: + yum_basecmd.append('--nogpgcheck') latest(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos) # should be caught by AnsibleModule argument_spec @@ -645,6 +668,8 @@ def main(): disablerepo=dict(), list=dict(), conf_file=dict(default=None), + disable_gpg_check=dict(required=False, default="no", + choices=BOOLEANS, type='bool'), ), required_one_of = [['name','list']], mutually_exclusive = [['name','list']], @@ -664,7 +689,9 @@ def main(): state = params['state'] enablerepo = params.get('enablerepo', '') 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) # this is magic, see lib/ansible/module_common.py |