|
|
|
@ -99,6 +99,7 @@ options:
|
|
|
|
|
deb:
|
|
|
|
|
description:
|
|
|
|
|
- Path to a .deb package on the remote machine.
|
|
|
|
|
- If :// in the path, ansible will attempt to download deb before installing. (Version added 2.1)
|
|
|
|
|
required: false
|
|
|
|
|
version_added: "1.6"
|
|
|
|
|
autoremove:
|
|
|
|
@ -159,6 +160,9 @@ EXAMPLES = '''
|
|
|
|
|
|
|
|
|
|
# Install the build dependencies for package "foo"
|
|
|
|
|
- apt: pkg=foo state=build-dep
|
|
|
|
|
|
|
|
|
|
# Install a .deb package from the internet.
|
|
|
|
|
- apt: deb=https://example.com/python-ppq_0.1-1_all.deb
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
RETURN = '''
|
|
|
|
@ -579,6 +583,31 @@ def upgrade(m, mode="yes", force=False, default_release=None,
|
|
|
|
|
m.exit_json(changed=False, msg=out, stdout=out, stderr=err)
|
|
|
|
|
m.exit_json(changed=True, msg=out, stdout=out, stderr=err)
|
|
|
|
|
|
|
|
|
|
def download(module, deb):
|
|
|
|
|
tempdir = os.path.dirname(__file__)
|
|
|
|
|
package = os.path.join(tempdir, str(deb.rsplit('/', 1)[1]))
|
|
|
|
|
# When downloading a deb, how much of the deb to download before
|
|
|
|
|
# saving to a tempfile (64k)
|
|
|
|
|
BUFSIZE = 65536
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
rsp, info = fetch_url(module, deb)
|
|
|
|
|
f = open(package, 'w')
|
|
|
|
|
# Read 1kb at a time to save on ram
|
|
|
|
|
while True:
|
|
|
|
|
data = rsp.read(BUFSIZE)
|
|
|
|
|
|
|
|
|
|
if data == "":
|
|
|
|
|
break # End of file, break while loop
|
|
|
|
|
|
|
|
|
|
f.write(data)
|
|
|
|
|
f.close()
|
|
|
|
|
deb = package
|
|
|
|
|
except Exception, e:
|
|
|
|
|
module.fail_json(msg="Failure downloading %s, %s" % (deb, e))
|
|
|
|
|
|
|
|
|
|
return deb
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
module = AnsibleModule(
|
|
|
|
|
argument_spec = dict(
|
|
|
|
@ -695,6 +724,8 @@ def main():
|
|
|
|
|
if p['deb']:
|
|
|
|
|
if p['state'] != 'present':
|
|
|
|
|
module.fail_json(msg="deb only supports state=present")
|
|
|
|
|
if '://' in p['deb']:
|
|
|
|
|
p['deb'] = download(module, p['deb'])
|
|
|
|
|
install_deb(module, p['deb'], cache,
|
|
|
|
|
install_recommends=install_recommends,
|
|
|
|
|
allow_unauthenticated=allow_unauthenticated,
|
|
|
|
@ -739,6 +770,7 @@ def main():
|
|
|
|
|
|
|
|
|
|
# import module snippets
|
|
|
|
|
from ansible.module_utils.basic import *
|
|
|
|
|
from ansible.module_utils.urls import *
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|
|
|
|
|