Search code examples
debdpkgansible

How do you prevent a dpkg installation task to notify a changed state when it runs for the second time?


There isn't a module for installing .deb packages directly. When you have to run dpkg as a command, it always mark the installation task as one that has changed. I'd some trouble configuring it correctly, so I'm posting here as a public notebook.

Here is the task to install with dpkg:

- name: Install old python 
  command: dpkg -i {{ temp_dir }}/{{ item }}
  with_items: 
    - python2.4-minimal_2.4.6-6+precise1_i386.deb
    - python2.4_2.4.6-6+{{ ubuntu_release }}1_i386.deb
    - libpython2.4_2.4.6-6+{{ ubuntu_release }}1_i386.deb
    - python2.4-dev_2.4.6-6+{{ ubuntu_release }}1_i386.deb

The files where uploaded to {{temp_dir}} in another task.


Solution

  • In Ansible 1.6 (and newer), the apt module has a deb option:

    - apt: deb=/tmp/mypackage.deb