Ansible apt build-dep: "No package matching ..."
Asked Answered
A

1

9

I'm installing unrar-nonfree on Raspbian based on How to install unrar-nonfree? (raspberrypi.stackexchange.com) but using Ansible. I successfully added the apt repository using ansibles: apt_repository which updates the cache (default) when there is a change. Inmediatly after I'm attempting to run:

sudo apt-get build-dep unrar-nonfree

But with ansible's equivalent:

- apt:
    pkg: unrar-nonfree
    state: build-dep

Except this fails with: fatal: [192.168.2.3]: FAILED! => {"changed": false, "failed": true, "msg": "No package matching 'unrar-nonfree' is available"}

Extended (-vvv) logs for the failure:

TASK [unrar-nonfree : apt] *****************************************************
task path: /Users/leonelgalan/Work/ansible-pi/roles/unrar-nonfree/tasks/main.yml:12
<192.168.2.2> ESTABLISH SSH CONNECTION FOR USER: leonelgalan
<192.168.2.2> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=leonelgalan -o ConnectTimeout=10 -o ControlPath=/Users/leonelgalan/.ansible/cp/ansible-ssh-%h-%p-%r -tt 192.168.2.2 '/bin/sh -c '"'"'( umask 22 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1462315830.89-175365841755446 `" && echo "` echo $HOME/.ansible/tmp/ansible-tmp-1462315830.89-175365841755446 `" )'"'"''
<192.168.2.2> PUT /var/folders/q8/mdl09l9d6m38tkk9rjtgq_9r0000gn/T/tmpwEEqbI TO /home/leonelgalan/.ansible/tmp/ansible-tmp-1462315830.89-175365841755446/apt
<192.168.2.2> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=leonelgalan -o ConnectTimeout=10 -o ControlPath=/Users/leonelgalan/.ansible/cp/ansible-ssh-%h-%p-%r '[192.168.2.2]'
<192.168.2.2> ESTABLISH SSH CONNECTION FOR USER: leonelgalan
<192.168.2.2> SSH: EXEC ssh -C -q -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=leonelgalan -o ConnectTimeout=10 -o ControlPath=/Users/leonelgalan/.ansible/cp/ansible-ssh-%h-%p-%r -tt 192.168.2.2 '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-uctakuwrjhufxakpatxinjmeibajdcbz; /bin/sh -c '"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 /usr/bin/python /home/leonelgalan/.ansible/tmp/ansible-tmp-1462315830.89-175365841755446/apt; rm -rf "/home/leonelgalan/.ansible/tmp/ansible-tmp-1462315830.89-175365841755446/" > /dev/null 2>&1'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"''"'"'"'"'"'"'"'"''"'"''
fatal: [192.168.2.2]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"cache_valid_time": null, "deb": null, "default_release": null, "dpkg_options": "force-confdef,force-confold", "force": false, "install_recommends": null, "package": ["unrar-nonfree"], "pkg": "unrar-nonfree", "purge": false, "state": "build-dep", "update_cache": true, "upgrade": null}, "module_name": "apt"}, "msg": "No package matching 'unrar-nonfree' is available"}

Troubleshooting

Ansible: ansible 2.0.1.0 OS: Raspbian Jessie March 2016

  1. I've re-ran the script multiple times, it fails on the same spot every time.
  2. I've added an additional -apt: update_cache=yes between the two tasks.
  3. I've ran sudo apt-get build-dep unrar-nonfree with success on the same machine. Ansible still fails:

Logs for #3:

$ sudo apt-get build-dep unrar-nonfree
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  debhelper gettext intltool-debian libunistring0 po-debconf
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 2,482 kB of archives.
After this operation, 8,594 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main libunistring0 armhf 0.9.3-5.2 [253 kB]
Get:2 http://mirrordirector.raspbian.org/raspbian/ jessie/main gettext armhf 0.19.3-2 [1,167 kB]
Get:3 http://mirrordirector.raspbian.org/raspbian/ jessie/main intltool-debian all 0.35.0+20060710.1 [29.8 kB]
Get:4 http://mirrordirector.raspbian.org/raspbian/ jessie/main po-debconf all 1.0.16+nmu3 [220 kB]
Get:5 http://mirrordirector.raspbian.org/raspbian/ jessie/main debhelper all 9.20150101 [813 kB]
Fetched 2,482 kB in 26s (93.3 kB/s)
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend requires a screen at least 13 lines tall and 31 columns wide.)
debconf: falling back to frontend: Readline
Selecting previously unselected package libunistring0:armhf.
(Reading database ... 125630 files and directories currently installed.)
Preparing to unpack .../libunistring0_0.9.3-5.2_armhf.deb ...
Unpacking libunistring0:armhf (0.9.3-5.2) ...
Selecting previously unselected package gettext.
Preparing to unpack .../gettext_0.19.3-2_armhf.deb ...
Unpacking gettext (0.19.3-2) ...
Selecting previously unselected package intltool-debian.
Preparing to unpack .../intltool-debian_0.35.0+20060710.1_all.deb ...
Unpacking intltool-debian (0.35.0+20060710.1) ...
Selecting previously unselected package po-debconf.
Preparing to unpack .../po-debconf_1.0.16+nmu3_all.deb ...
Unpacking po-debconf (1.0.16+nmu3) ...
Selecting previously unselected package debhelper.
Preparing to unpack .../debhelper_9.20150101_all.deb ...
Unpacking debhelper (9.20150101) ...
Processing triggers for man-db (2.7.0.2-5) ...
Processing triggers for install-info (5.2.0.dfsg.1-6) ...
Setting up libunistring0:armhf (0.9.3-5.2) ...
Setting up gettext (0.19.3-2) ...
Setting up intltool-debian (0.35.0+20060710.1) ...
Setting up po-debconf (1.0.16+nmu3) ...
Setting up debhelper (9.20150101) ...
Processing triggers for libc-bin (2.19-18+deb8u4) ...
Aidoneus answered 26/4, 2016 at 16:57 Comment(1)
You still got this issue?Pleurisy
L
1

Try this one:

- apt_repository: repo='deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi' state=present
- apt: update_cache=yes
- apt:
    name: unrar-nonfree
    state: build-dep
- shell: mkdir -p /tmp/unrar && cd /tmp/unrar && rm -f /tmp/unrar/* && sudo apt-get source -b unrar-nonfree -y && sudo  dpkg -i unrar*.deb && rm -rf /tmp/unrar/
Lutz answered 28/4, 2016 at 20:21 Comment(9)
Thanks for helping, but it's the third step, the one that fails. That's the one in the original question. It fails with "No package matching 'unrar-nonfree' is available"Gonfalonier
The package is exist archive.raspbian.org/raspbian/pool/non-free/u/unrar-nonfree but in repo file I can't find it: archive.raspbian.org/raspbian/dists/wheezy/non-free/…Lutz
You might use the archive.raspbian.org/raspbian/pool/main/u/unrar-free/…Lutz
But running the same command without ansible works. See my third troubleshooting step. Basically I'm looking for why this isn't working on ansible, rather than getting unrar-nonfree con my Pi, I already did that.Gonfalonier
As you can see github.com/ansible/ansible-modules-core/blob/release1.8.0/… the module is using the apt-get. Try Ansible-playbook -vvv to see the cmdLutz
Also you should check if repo was addedLutz
Do you mean in cat /etc/apt/sources.list? Yes that file has "deb-src archive.raspbian.org/raspbian jessie main contrib non-free rpi" after running that first Ansible_ task. As I mentioned before, I'm at a point that the it works if I run it manually, but it fails when I run it on Ansible (in other words, the preconditions are set). I'll report the output of -vvv once I have my RPI next to me.Gonfalonier
I've link the output of -vvv: gist.github.com/leonelgalan/f14fb8f83368ffd764697643e3d23ac7, but I don't see the commands anywhere. It appears they are abstracted in a python file that it's later removed.Gonfalonier
It's like a bug. did you use Ansible from distro's repository or installed it with pip? I faced with issues when have used it from distro's repository. Can you try update Ansible? And open a bug in their repository on github.Lutz

© 2022 - 2024 — McMap. All rights reserved.