Commit graph

58 commits

Author SHA1 Message Date
Patrick Gerken
38d6956c1f Properly catch import errors in apt
When one accidentally tries to run this module as a user, he gets the error message that python-apt must be installed, no matter what. Because importing apt will trigger an exception as a regular user. Explicitly catching the ImportError will let the exception bubble. The exception clearly says Permission denied somewhere, and the user has a better idea, what he must fix.
2014-03-14 02:13:20 +01:00
Michael DeHaan
297b048d0e Fix other reference to APT_ENV_VARS. 2014-03-11 10:47:53 -04:00
Michael DeHaan
c09d4b1c7a Update apt module so that environment variables are set correctly since not going through shell. Very sorry folks, it will be addressed. 2014-03-11 08:39:28 -04:00
James Cammarata
be0be16e89 Merge branch '5853-python-2.5-apt_repository-fix' of https://github.com/timurbatyrshin/ansible into timurbatyrshin-5853-python-2.5-apt_repository-fix 2014-02-24 15:20:29 -06:00
Timur Batyrshin
db173453ba further compatibility with older versions of python-apt (#5853) 2014-02-02 23:15:19 +04:00
Rene Moser
849aab0a12 apt: fixed pkg=<name>=<version> fails if package is not yet installed.
Reported and patch provided by https://github.com/msolo. Closes GH-5625.
2014-01-16 11:05:12 +01:00
lichesser
7201972a56 Remove debugging code
I guess this is left over from testing
2014-01-08 02:34:59 +01:00
James Tanner
c8bd14925d Fixes #5369 Do not pass --force-yes to aptitude 2014-01-07 15:53:28 -05:00
jctanner
b9cb49e638 Merge pull request #4872 from timurbatyrshin/4869-old-python-apt-fix
#4869 compatibility with older versions of apt
2013-12-13 10:43:47 -08:00
Rene Moser
2d805ae5da apt: update index before trying to autoinstall python-apt 2013-12-09 10:21:27 +01:00
jctanner
6b45c4a6ca Merge pull request #5181 from mvo5/bugfix/apt-fnmatch-remove
add fnmatch() support for apt remove too (just like install)
2013-12-05 09:18:04 -08:00
Michael Scherer
3df62f1d8a Fix apt module to be able to install package by giving just a provides and not the full name
The apt module check if a packag eis valid by loking in the cache, checking only for
full name, while it should also check that the name is not just provided.
Fix https://github.com/ansible/ansible/issues/5177
2013-12-05 17:56:54 +01:00
Michael Vogt
559de5c65e add fnmatch() support for apt remove too (just like install) 2013-12-05 17:54:43 +01:00
James Tanner
ad837709bd Addresses #5023 Fix import comments 2013-12-02 15:13:49 -05:00
James Tanner
6000d636b3 Fixes #5023 Convert all modules to use new snippet import pattern 2013-12-02 15:11:23 -05:00
Michael DeHaan
36effd237c There's a cleaner way to do this, commit to module formatter pending.
Revert "No longer need to reference 'version_added' in docs for these, as this was quite a while ago."

This reverts commit ff0a41d446.
2013-11-27 21:23:03 -05:00
Michael DeHaan
ff0a41d446 No longer need to reference 'version_added' in docs for these, as this was quite a while ago. 2013-11-27 21:19:32 -05:00
James Tanner
f332bb0d7c Fixes #4891 Catch unicodedecode errors from python-apt 2013-11-13 09:48:56 -05:00
James Tanner
7502e15298 Address #4285 remove redundant stderr output in apt module 2013-11-11 22:27:47 -05:00
jctanner
9faaa2b98b Merge pull request #4285 from blair/apt-module-register-stdout-stderr
apt: pass child process stdout and stdout to m.fail_json() and m.exit_js...
2013-11-11 19:15:10 -08:00
jctanner
a28bcd60d9 Merge pull request #4617 from resmo/feature/python-apt
apt: autoinstall python-apt if apt or apt_pkg is not available
2013-11-11 18:50:43 -08:00
James Tanner
f820e8e719 Merge pull request #4286 from blair/ansible
apt: do not consider not-removed and not-upgraded packages as changes.
2013-11-11 21:39:07 -05:00
Timur Batyrshin
9e7623e9de #4869 compatibility with older versions of apt 2013-11-11 16:56:05 +04:00
Yegor Minin
df5fd0e0d0 apt: allow specifying dpkg options
This will allow specifying dpkg options as a string passed over to apt
command. dpkg_options expects a comma-separated string of options to be
passed as dpkg options which will be further expanded. For example
dpkg_options='force-confdef,force-confold' will end up as
-o \"Dpkg::Options::=--force-confold\" when passed to apt
Example usage would be:
-m apt -u ubuntu -s \
 -a "upgrade=dist update_cache=yes dpkg_options='force-confold'"
or
apt: upgrade=dist update_cache=yes dpkg_options='force-confold'
2013-11-01 20:11:40 +02:00
Rene Moser
a10e017d6e apt: autoinstall python-apt if not available 2013-10-21 16:39:18 +02:00
Michael DeHaan
0e55bd892d For values that are booleans in the module doc, the value in the doc section should be a boolean or truthiness
is engaged in the documentation formatting.  This fixes the update_cache default in the docs to the proper
value of "no"
2013-10-09 07:52:23 -04:00
Michael DeHaan
203a4f10cd Use explicit boolean defaults in apt module to make the code more clear. 2013-10-09 07:47:24 -04:00
Blair Zajac
3a8c9f04da apt: do not consider not-removed and not-upgraded packages as changes.
If one pins a package and does a 'apt-get dist-upgrade' then the
output looks like:

    # apt-get dist-upgrade
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Calculating upgrade... Done
    The following packages have been kept back:
      cassandra
    0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

The check for any changes made should only be on the 'upgraded' and
'newly installed' values and not include the 'to remove' and 'not
upgraded' values.
2013-09-28 16:50:50 -07:00
Blair Zajac
d133c0aeee apt: pass child process stdout and stdout to m.fail_json() and m.exit_json().
Without this, this fails:

    - name: apt-get dist-upgrade
      action: apt upgrade=dist
      register: apt_get_contents

    - name: apt-get clean
      action: command apt-get clean
      when: apt_get_contents.stdout.find("0 upgraded") == -1

TASK: [apt-get clean] *********************************************************

fatal: [192.168.2.2] => error while evaluating conditional: {% if apt_get_contents.stdout.find("0 upgraded") == -1 %} True {% else %} False {% endif %}

FATAL: all hosts have already failed -- aborting
2013-09-28 16:28:18 -07:00
James Cammarata
671eeb65b2 Merge pull request #4138 from resmo/fix/redundant-fail-json
apt: fixed duplicate fail_json
2013-09-17 06:08:51 -07:00
Rene Moser
9449d62fb2 apt: fixed duplicate fail_json 2013-09-17 15:05:20 +02:00
James Cammarata
0d408ff295 Use low-level package objects in the apt module to check installed state
Packages which are half-installed are not adequately represented by
the .is_installed field of the apt.package.Package object. By using the
lower-level apt_pkg.Package object (which provides the .current_state
field), we can check for a partially-installed state more accurately.

Fixes #3421
2013-09-11 23:33:59 -05:00
James Cammarata
6feb4e3837 Fail apt package install when nothing is matched by the fnmatch pattern
Related to PR #3823
2013-08-12 11:26:31 -05:00
Michael Vogt
5c39c659e5 add support for fnmatch() style apt filenames
You can write a apt action like "- apt: pkg=apt*" with this package.
2013-08-12 16:11:15 +02:00
Alan Grosskurth
b950f9456a apt: Run remove commands noninteractively
I'm seeing ansible hang when trying to remove a package, and the hung
process is `whiptail` like in #2763. It looks like we only use
`APT_ENVVARS` and `DPKG_OPTIONS` for the `apt` commands in install()
and upgrade(). This change uses them in remove() as well, which fixes
the hang.
2013-08-05 15:20:45 -07:00
Michael DeHaan
a35370a766 Fix prev feature commit, Do not require aptitude to use apt commands in the apt module, only needed when upgrading. 2013-07-22 15:15:55 -04:00
Michael DeHaan
e1167d6977 tweak indentation for 'make pep8' 2013-07-20 12:48:11 -04:00
Michael DeHaan
f4b1e426ea Merge pull request #3379 from serenecloud/devel
Return a friendly error message if aptitude isn't installed
2013-07-19 07:36:39 -07:00
Felix Stuermer
b5df29901f Use the force=yes option for apt upgrade actions 2013-07-09 10:57:19 +02:00
serenecloud
a17ca862fb Return a friendly error message if aptitude isn't installed 2013-06-30 15:36:13 +12:00
Michael DeHaan
50fa88f28a Merge branch 'fix-apt-purge' of git://github.com/madduck/ansible into purge 2013-06-19 21:35:28 -04:00
Michael DeHaan
d9c0a5c37d Revert "now modules can implement with_items list globbing w/o updating"
This reverts commit 4942a06bc2.

Conflicts:

	lib/ansible/runner/__init__.py
2013-06-19 19:00:18 -04:00
martin f. krafft
ae42144752 Always assume purged for older python-apt
Older python-apt modules don't export Package.installed_files and there
seems to be no other way to figure out if a package is
removed-but-not-purged, so we just always assume it's purged.

Signed-off-by: martin f. krafft <madduck@madduck.net>
2013-06-19 10:56:43 +02:00
martin f. krafft
420f7d7ac6 Introduce non-purged package status
A package may be removed but not purged with APT. The only way to
identify this state is by looking at the list of installed files of
a package. Even if the package has no files installed, this list will be
non-empty until the package is removed:

  # python -c "import apt; c=apt.Cache(); c.update(); c.open(); p=c['ruby1.8']; print p, p.installed, p.installed_files"
  <Package: name:'ruby1.8' id:1425> None [u'']

  # dpkg --purge ruby1.8
  (Reading database ... 27904 files and directories currently installed.)
  Removing ruby1.8 ...
  Purging configuration files for ruby1.8 ...

  # python -c "import apt; c=apt.Cache(); c.update(); c.open(); p=c['ruby1.8']; print p, p.installed, p.installed_files"
  <Package: name:'ruby1.8' id:1425> None []

See http://bugs.debian.org/712749 too.

If a package is not marked installed but it still 'has_files', then it
should be processed if the request is to purge it.

Signed-off-by: martin f. krafft <madduck@madduck.net>
2013-06-19 10:00:33 +02:00
martin f. krafft
8e37a2bec9 Fix purging of packages
A small error in the reuse of a variable caused packages to never get
purged. This commit fixes that.

Signed-off-by: martin f. krafft <madduck@madduck.net>
2013-06-19 10:00:33 +02:00
Jesse Keating
86bc2ec08a pkg option of apt is not required
You can use apt module with update_cache and without specifying a
package. Update the docs to reflect this.
2013-06-18 16:25:46 -07:00
Michael DeHaan
d9f91be34a Merge pull request #3227 from bcoca/modules_wantlist
implementing with_items list globbing made easier for modules
2013-06-16 19:29:02 -07:00
Brian Coca
4942a06bc2 now modules can implement with_items list globbing w/o updating
hardcoded lists in ansible code, just add WITH_ITEMS_USES_LIST in a
comment anywhere, and of course, support recieving params as list.

Signed-off-by: Brian Coca <briancoca+dev@gmail.com>
2013-06-15 16:28:43 -04:00
Jan-Piet Mens
5c69918d53 DOCS: standardize on EXAMPLES (a.k.a. Docs-JumboPatch JetLag Edition)
Migrated all examples: in DOCUMENTATION=''' string to standalone EXAMPLES=''' string
  Added deprecation warning to moduledev.rst and remove deprecated example from it
  Fixed up a few typos and uppercased some acronyms.
  add consistency to how EXAMPLES are formatted
2013-06-15 20:54:25 +02:00
John Jarvis
423fe82d94 fixing syntax error 2013-05-18 19:49:25 -04:00