-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A more reliable way to detect Ubuntu #7524
A more reliable way to detect Ubuntu #7524
Conversation
lsb_release command is included in lsb-release package. Sometimes this is not installed; ex: Docker official Ubuntu image. /etc/os-release is included in base-files package, so this is more reliable than lsb_release.
I'll need to test this across multiple ubuntu versions |
We can try following: SetupRequires Creates following # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.provider(:docker) do |d|
d.image = "test_ubuntu"
d.has_ssh = true
end
end Download
Creates Docker image for Vagrant. $ docker build -t test_ubuntu . Before pull-requestVagrant cannot detect Ubuntu (except Ubuntu Trusty). $ bundle exec vagrant destroy -f
$ bundle exec vagrant up --provider=docker --debug 2> /tmp/before.log
$ sed -n -e '/^DEBUG guest: Trying: ubuntu/, /^DEBUG ssh: Exit status: / p' \
/tmp/before.log
DEBUG guest: Trying: ubuntu
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: [ -x /usr/bin/lsb_release ] && /usr/bin/lsb_release -i 2>/dev/null | grep Ubuntu (sudo=false)
DEBUG ssh: Exit status: 1 After pull-requestVagrant can detect Ubuntu. $ bundle exec vagrant destroy -f
$ bundle exec vagrant up --provider=docker --debug 2> /tmp/after.log
$ sed -n -e '/^DEBUG guest: Trying: ubuntu/, /^DEBUG ssh: Exit status: / p' \
/tmp/after.log
DEBUG guest: Trying: ubuntu
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: test -r /etc/os-release && . /etc/os-release && test xubuntu = x$ID (sudo=false)
DEBUG ssh: Exit status: 0 |
Thank you! And I tried to use https://raw.githubusercontent.com/nishidayuya/docker-vagrant-ubuntu/d5d296694da65af1440b007f7761392736286cdb/Dockerfile on |
- Semi-reverts hashicorpGH-7524 - Fixes hashicorpGH-7625
lsb_release
command is included in lsb-release package. Sometimes this is not installed; ex: Docker official Ubuntu image./etc/os-release
is included in base-files package, so this is more reliable than lsb_release.This pull-request uses
/etc/os-release
for Ubuntu detection.