Merge pull request #4420 from Jmainguy/devel

Added resp= option for svr4pkg to enable the -r option in pkgadd for res...
This commit is contained in:
jctanner 2013-11-13 17:02:58 -08:00
commit ba65eec795

View file

@ -53,6 +53,9 @@ options:
proxy: proxy:
description: description:
- HTTP[s] proxy to be used if C(src) is a URL. - HTTP[s] proxy to be used if C(src) is a URL.
response_file:
description:
- Specifies the location of a response file to be used if package expects input on install. (added in Ansible 1.4)
''' '''
EXAMPLES = ''' EXAMPLES = '''
@ -62,6 +65,9 @@ EXAMPLES = '''
# Install a package directly from an http site # Install a package directly from an http site
- svr4pkg: name=CSWpkgutil src=http://get.opencsw.org/now state=present - svr4pkg: name=CSWpkgutil src=http://get.opencsw.org/now state=present
# Install a package with a response file
- svr4pkg: name=CSWggrep src=/tmp/third-party.pkg response_file=/tmp/ggrep.response state=present
# Ensure that a package is not installed. # Ensure that a package is not installed.
- svr4pkg: name=SUNWgnome-sound-recorder state=absent - svr4pkg: name=SUNWgnome-sound-recorder state=absent
''' '''
@ -109,11 +115,13 @@ def run_command(module, cmd):
cmd[0] = module.get_bin_path(progname, True) cmd[0] = module.get_bin_path(progname, True)
return module.run_command(cmd) return module.run_command(cmd)
def package_install(module, name, src, proxy): def package_install(module, name, src, proxy, response_file):
adminfile = create_admin_file() adminfile = create_admin_file()
cmd = [ 'pkgadd', '-na', adminfile, '-d', src ] cmd = [ 'pkgadd', '-na', adminfile, '-d', src ]
if proxy is not None: if proxy is not None:
cmd += [ '-x', proxy ] cmd += [ '-x', proxy ]
if response_file is not None:
cmd += [ '-r', response_file ]
cmd.append(name) cmd.append(name)
(rc, out, err) = run_command(module, cmd) (rc, out, err) = run_command(module, cmd)
os.unlink(adminfile) os.unlink(adminfile)
@ -132,7 +140,8 @@ def main():
name = dict(required = True), name = dict(required = True),
state = dict(required = True, choices=['present', 'absent']), state = dict(required = True, choices=['present', 'absent']),
src = dict(default = None), src = dict(default = None),
proxy = dict(default = None) proxy = dict(default = None),
response_file = dict(default = None)
), ),
supports_check_mode=True supports_check_mode=True
) )
@ -140,6 +149,7 @@ def main():
name = module.params['name'] name = module.params['name']
src = module.params['src'] src = module.params['src']
proxy = module.params['proxy'] proxy = module.params['proxy']
response_file = module.params['response_file']
rc = None rc = None
out = '' out = ''
err = '' err = ''
@ -154,7 +164,7 @@ def main():
if not package_installed(module, name): if not package_installed(module, name):
if module.check_mode: if module.check_mode:
module.exit_json(changed=True) module.exit_json(changed=True)
(rc, out, err) = package_install(module, name, src, proxy) (rc, out, err) = package_install(module, name, src, proxy, response_file)
# Stdout is normally empty but for some packages can be # Stdout is normally empty but for some packages can be
# very long and is not often useful # very long and is not often useful
if len(out) > 75: if len(out) > 75: