Don Branson
Don Branson

Reputation: 13709

Ansible not recognizing deb parameter for aptitude

According to http://docs.ansible.com/apt_module.html, the aptitude module allows installation from a .deb file:

# Install a .deb package
- apt: deb=/tmp/mypackage.deb

But running Ansible 1.9.2 or 1.8.4 on Ubuntu 14.04, this config:

- name: install riak
  apt: deb=/data/riak/riak.deb update_cache=no

produces this output:

TASK: [riak | install riak] *************************************************** 
failed: [riak-server-1] => {"failed": true}
msg: unsupported parameter for module: deb

The same Ansible script works fine on Macs running Ansible 1.8.4 and 1.9.

The guest in all cases is a Vagrant-created ubuntu/trusty64. The entire VM creation and setup is done with Vagrant and Ansible, and we're all running with the same Vagrant/Ansible files.

Edit:

>ansible-playbook --version
 ansible-playbook 1.9.2
   configured module search path = /usr/share/ansible

>ansible --version
ansible 1.9.2
  configured module search path = /usr/share/ansible

>locate apt.py | xargs md5sum
0058a84d0685ad1b67895fdf2da95bc5  /usr/local/lib/python2.7/dist-packages/ansible-1.9.2-py2.7.egg/ansible/modules/core/packaging/os/apt.py
134ac4074dd7929826f5cf888b2ec3ad  /usr/local/lib/python2.7/dist-packages/ansible-1.9.2-py2.7.egg/ansible/modules/core/packaging/os/apt.pyc

It's built from source:

>git status
On branch stable-1.9
Your branch is up-to-date with 'origin/stable-1.9'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

    modified:   lib/ansible/module_utils/basic.py
    modified:   lib/ansible/modules/core (modified content)
    modified:   v2/ansible/modules/core (modified content)

>git diff lib/ansible/module_utils/basic.py
diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py
index 91501b1..3430abe 100644
--- a/lib/ansible/module_utils/basic.py
+++ b/lib/ansible/module_utils/basic.py
@@ -911,7 +911,7 @@ class AnsibleModule(object):
             #if k in ('CHECKMODE', 'NO_LOG'):
             #    continue
             if k not in self._legal_inputs:
-                self.fail_json(msg="unsupported parameter for module: %s" % k)
+                self.fail_json(msg="unsupported parameter for module: %s. supported parameters are %s" % (k, self._legal_inputs))

     def _count_terms(self, check):
         count = 0

TASK: [riak | install riak] *************************************************** 
failed: [riak-server-3] => {"failed": true}
msg: unsupported parameter for module: deb. supported parameters are ['CHECKMODE', 'NO_LOG', 'dpkg_options', 'upgrade', 'force', 'package', 'pkg', 'name', 'purge', 'state', 'update_cache', 'update-cache', 'default_release', 'default-release', 'install_recommends', 'install-recommends', 'cache_valid_time']

It really looks to me like it's picking up an old version of apt.py from somewhere. I ran sudo find / -name apt.py, and there are several copies in my home, but only the one under /usr.

Edit:

I removed all the apt.py instances laying around, so that:

>sudo find / -name apt.py* | xargs md5sum
134ac4074dd7929826f5cf888b2ec3ad  /usr/local/lib/python2.7/dist-packages/ansible-1.9.2-py2.7.egg/ansible/modules/core/packaging/os/apt.pyc
0058a84d0685ad1b67895fdf2da95bc5  /usr/local/lib/python2.7/dist-packages/ansible-1.9.2-py2.7.egg/ansible/modules/core/packaging/os/apt.py

Upvotes: 4

Views: 1853

Answers (1)

Don Branson
Don Branson

Reputation: 13709

Well, it's now working. It turns out that there was a remnant of ansible left over from running sudo apt-get install ansible some time ago. So, even though I had tried to completely scrub any ansible bits left using

sudo rm -rf /usr/local/lib/python2.7/dist-packages/ansible* /usr/local/bin/ansible* /usr/bin/ansible*

and even though there was no old apt.py left anywhere on my system, sudo apt-get remove ansible found something to remove. I thought I had already run that before ever going down the source route, but apparently not.

>sudo apt-get remove ansible
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  python-jinja2 python-markupsafe python-yaml
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  ansible
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 2,758 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 282489 files and directories currently installed.)
Removing ansible (1.5.4+dfsg-1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...

After that, I re-cloned the source:

git clone [email protected]:ansible/ansible --recursive

and rebuilt:

sudo make clean install
sudo /bin/bash ./hacking/env-setup

Now the install from a .deb file works:

TASK: [riak | install riak] *************************************************** 
changed: [riak-server-3]

Upvotes: 1

Related Questions