debops / ansible-apt

Configure and manage APT Package Manager
GNU General Public License v3.0
10 stars 15 forks source link

Wrong apt-sources on Raspbian, kills system #9

Closed htgoebel closed 7 years ago

htgoebel commented 9 years ago

When running this role without any configuration on a Raspbian system (Raspbian GNU/Linux 7 (wheezy)), the role installs http://cdn.debian.net as a source.

This is especially fatal, since just a few tasks later ("Install requested packages"), a new version of openssh-server will be installed, which is not able to run. Thus running this role will garbage the whole system.

Possible solution: Try to detect Raspbian and do not set up a source/mirror in this case. Using any of the variables detected by setup (esp. ansible_distribution is of no help as these all show debian. Detection can be done by greping for ID=raspbian in /etc/os-release.

My knowledge about Ansible is too less, so I can not submit a pull-request. Sorry.

drybjed commented 9 years ago

@htgoebel I don't have a Pi to test with, so you will need to help me here. :-)

First, give me a list of valid /etc/apt/sources.list from Raspian that work. Give me also output of ansible host -m setup to see default values if various variables.

To test if role will work without changing the sources, in your inventory, set apt_default_sources: False - this should prevent loading of default sources by the role and leave your sources.list intact.

htgoebel commented 9 years ago

These are the sources configured on my raspberry: /etc/apt/source.list: deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi /etc/apt/source.list.d/raspi.list deb http://archive.raspberrypi.org/debian/ wheezy main As I'm new to Raspberry, I do not know if these are a good choice, but these are the defaults.

drybjed commented 9 years ago

@htgoebel OK, I can add separate set of sources for Raspian, you will just need to set for example:

apt_default_sources_lookup: 'Raspian'

in your inventory. Will do that probably tommorow as I don't have access to my work computer at the moment. Did you check with apt_default_sources: False?

htgoebel commented 9 years ago

The output of setup is of no help: There is no value pointing to Raspibian (leaving alone hardware-ids like MAC-addresses). This is why I proposed to check /etc/os-release.

htgoebel commented 9 years ago

Did you check with apt_default_sources: False?

Yes, this solved the problem for me. And I can live with it until a fix is available. So do not hurry :-)

drybjed commented 9 years ago

@htgoebel Good to hear that apt_default_sources: [] lets you bypass that problem. The issue with checking /etc/os-release directly for me is, that it's currently an isolated case (only one platform so far). It think better way to solve this would be to fix Raspian detection in ansible's setup module, to provide correct distribution name via ansible_distribution variable.

As for current issues with apt and ferm on Raspian - I expected that not all cases can be handled by DebOps and some inventory configuration will be required in some cases. I think that an example inventory for Rasian included in debops/examples repository could be a good help for other users, it could specify a good set of default variables for Pi. Could you compile them and make a pull request?

ypid commented 8 years ago

Just checking the role redesign by drybjed. Seems to me this issue might be fixed with the PR. @htgoebel Can you check that and potentially close this issue?

drybjed commented 8 years ago

NB: The debops.core role can be used to override the distribution/release detection. For example in this case, you would set in your inventory:

core__distribution: 'Raspbian'

Roles that use the ansible_local.core.distribution variable, like debops.apt with recent changes, would see "Raspbian" as the distribution instead of "Debian".

Bat-signaling @pedroluislopez to also look at these changes if possible.

Vollbrecht commented 7 years ago

There is another option to detect if the System is Debian or Raspian. If you youse ansible_lsb fact insted of ansible_distribution you see as ansible_lsb.id = 'Raspian' instead of 'Debian'

here is the example of 2 of my hosts. One is backpord debian (on x86) and one is fresh installed raspbian-lite (raspberrypi 2)

ansible -i ../development.ini pi -m setup -a"filter=ansible_lsb" 192.168.178.59 | SUCCESS => { "ansible_facts": { "ansible_lsb": { "codename": "jessie", "description": "Raspbian GNU/Linux 8.0 (jessie)", "id": "Raspbian", "major_release": "8", "release": "8.0" } },

ansible -i ../development.ini backup-server -m setup -a"filter=ansible_lsb" 192.168.178.60 | SUCCESS => { "ansible_facts": { "ansible_lsb": { "codename": "jessie", "description": "Debian GNU/Linux 8.8 (jessie)", "id": "Debian", "major_release": "8", "release": "8.8" } }, "changed": false } Hope it helps

Vollbrecht commented 7 years ago

i created an pull request for the issue

91

drybjed commented 7 years ago

@Vollbrecht Thanks! This issue should now be fixed in the debops.apt master branch, therefore I'm closing it. The new role release will be performed at a later date.