debops / ansible-apt

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

Expose default mirrors for the different distributions in facts in accessible way #86

Closed ypid closed 7 years ago

ypid commented 7 years ago

It would be nice to expose the mirrors for the different distributions in facts so that they can be used instead from one central location.

Currently it is a list which is unsuitable to use it from other roles.

Related to: #85

drybjed commented 7 years ago

I'm not sure that I understand this correctly. The debops.apt facts already have a key with the different distribution mirrors recognized by the script, default_mirrors. Do you mean to change it/add a dictionary with some more data like what distribution it's meant to be used with, etc.?

What would be the use case by other roles?

ypid commented 7 years ago

Do you mean to change it/add a dictionary with some more data like what distribution it's meant to be used with, etc.?

That is what I had in mind but to not overdo it, I guess just adding a "default_mirror" which contains the default mirror of the current distribution should do. Mirrors for other distros are not very useful in Ansible facts I think.

This could be used in the following places:

$ ag -Q httpredir.debian.org -G '\.yml$'
debops.preseed/defaults/main.yml
277:preseed__debian_mirror_hostname: 'httpredir.debian.org'

debops.ipxe/defaults/main.yml
96:ipxe_debian_installer_mirror: 'httpredir.debian.org'

debops.lxc/defaults/main.yml
205:lxc_template_debootstrap_mirror: 'http://httpredir.debian.org/debian'

debops.apt_cacher_ng/defaults/main.yml
198:apt_cacher_ng__upstream_mirror_debian: 'http://httpredir.debian.org/debian/'
487:    reason: 'http://httpredir.debian.org/debian is not included in the deb_mirrors.gz file of apt-cacher-ng as of 0.8.0-3 (latest in Debian Jessie). This can result in unnecessary resource (bandwidth, storage) usage. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=782643'
drybjed commented 7 years ago

Ah, that explains it. Agreed, that might be useful in other roles. A 1 element as a string sounds like the best option for these.

ypid commented 7 years ago

Or maybe the default_mirrors option should be changed to only contain mirrors for the current distribution? Or is there a usecase for the current variant?

drybjed commented 7 years ago

No, it's just not filtered out from the current list of APT sources, but I don't think that there's a specific reason for it not to be; usually Debian repositories are not used on Ubuntu, etc. Let's go with that, it might be easier to implement.

The roles that use the list should decide by themselves if they want to use all of the sources via a list, or pick just the first one in case there's more than one.

ypid commented 7 years ago

Thanks!