apt - Manages apt-packages

Author:Matthew Williams

Synopsis

Manages apt packages (such as for Debian/Ubuntu).

Options

parameter required default choices comments
cache_valid_time no
    If update_cache is specified and the last run is less or equal than cache_valid_time seconds ago, the update_cache gets skipped.
    default_release no
      Corresponds to the -t option for apt and sets pin priorities
      dpkg_options no force-confdef,force-confold
        Add dpkg options to apt command. Defaults to '-o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold"'Options should be supplied as comma separated list
        force no no
        • yes
        • no
        If yes, force installs/removes.
        install_recommends no True
        • yes
        • no
        Corresponds to the --no-install-recommends option for apt, default behavior works as apt's default behavior, no does not install recommended packages. Suggested packages are never installed.
        pkg no
          A package name or package specifier with version, like foo or foo=1.0. Shell like wildcards (fnmatch) like apt* are also supported.
          purge no
          • yes
          • no
          Will force purging of configuration files if the module state is set to absent.
          state no present
          • latest
          • absent
          • present
          Indicates the desired package state
          update_cache no
          • yes
          • no
          Run the equivalent of apt-get update before the operation. Can be run as part of the package installation or as a separate step
          upgrade no yes
          • yes
          • safe
          • full
          • dist
          If yes or safe, performs an aptitude safe-upgrade.If full, performs an aptitude full-upgrade.If dist, performs an apt-get dist-upgrade.Note: This does not upgrade a specific package, use state=latest for that. (added in Ansible 1.1)

          Note

          Requires python-apt

          Note

          Requires aptitude

          Examples


          # Update repositories cache and install "foo" package
          - apt: pkg=foo update_cache=yes
          
          # Remove "foo" package
          - apt: pkg=foo state=absent
          
          # Install the package "foo"
          - apt: pkg=foo state=present
          
          # Install the version '1.00' of package "foo"
          - apt: pkg=foo=1.00 state=present
          
          # Update the repository cache and update package "nginx" to latest version using default release squeeze-backport
          - apt: pkg=nginx state=latest default_release=squeeze-backports update_cache=yes
          
          # Install latest version of "openjdk-6-jdk" ignoring "install-recommends"
          - apt: pkg=openjdk-6-jdk state=latest install_recommends=no
          
          # Update all packages to the latest version
          - apt: upgrade=dist
          
          # Run the equivalent of "apt-get update" as a separate step
          - apt: update_cache=yes
          
          # Only run "update_cache=yes" if the last one is more than more than 3600 seconds ago
          - apt: update_cache=yes cache_valid_time=3600
          
          # Pass options to dpkg on run
          - apt: upgrade=dist update_cache=yes dpkg_options='force-confold,force-confdef'
          

          Note

          Three of the upgrade modes (full, safe and its alias yes) require aptitude, otherwise apt-get suffices.

          Table Of Contents

          Previous topic

          Packaging Modules

          Next topic

          apt_key - Add or remove an apt key