Compare commits

..

16 commits

Author SHA1 Message Date
a47660a1e5 Update 'README.md' 2023-02-03 19:28:15 +00:00
3575d65ffb Update 'README.md' 2023-02-03 19:08:48 +00:00
Glenn Y. Rolland
938a29ed96
Merge branch 'fgrehm:master' into master 2023-02-03 19:56:32 +01:00
Fabio
ff58ecd5f2
Update README.md 2022-11-24 20:41:12 -03:00
Fabio
df6b78c4ed
Update README.md 2022-11-24 20:40:54 -03:00
Fabio
4d53acb9fb
Update README.md 2022-11-24 20:40:34 -03:00
Fabio
b88d50fb68
Update README.md 2022-11-16 22:39:19 -03:00
4e3306ed74 Fix the 'eval: Address:: not found' error that may appear 2022-09-28 15:01:04 +02:00
Fabio Rehm
c167ac7f83
Make it clear that project is looking for maintainers
Ref https://github.com/fgrehm/vagrant-lxc/issues/492
2021-01-12 11:15:50 -03:00
Virgil Dupras
a112b072aa
Merge pull request #473 from ebobby/fix-redir3
Fix redir version fetching.
2018-09-26 19:53:14 -04:00
Francisco Soto
f750bf406c Fix redir version fetching.
"" || "something" doesn't really work. Have to check for the actual string
length to determine if got something or not out of the pipe.
2018-09-24 18:43:03 -07:00
Virgil Dupras
2a5510b34c Fix "vargant package" for LXC 2.1+ config format
New config format would be under `lxc.rootfs.path` and be prefixed by
`dir:`.
2018-07-24 12:23:25 -04:00
Virgil Dupras
a1aa60ded5 Remove supports_attach? and call to /sbin/halt
Hosts without support for lxc-attach are ancien and can always use old
versions of vagrant-lxc. To be able to move forward more easily, we
should be able to assume a functional `lxc-attach`.

As for `/sbin/halt`, I'm really not sure it's needed anymore. Let's see
if its removal causes problems.
2018-07-24 11:21:09 -04:00
Virgil Dupras
61c921ac6f Use require_relative everywhere in plugin entry point 2018-07-24 10:25:08 -04:00
Virgil Dupras
437b5e7a2e README: base boxes status update 2018-07-24 10:08:07 -04:00
Virgil Dupras
2c2630a788 Bump minimum requirements for next vagrant-lxc release (v1.5)
We now depend on vagrant 1.9+ and LXC 2.0+, following bundled version in
debian stretch.

Also, update Gemfile to target latest vagrant/vagrant-spec. It's too
complicated to test against old vagrant versions. Vagrant 1.8.x didn't
specify an upper bound for supported versions but vagrant 1.9 does
(<2.4). This breaks out CI testing matrix which tests against 2.3, 2.4
and 2.5.

So let's make our live easier and just test against the latest vagrant
version and try not to mistakenly drop support for our lowest supported
vagrant version...
2018-07-24 09:37:34 -04:00
10 changed files with 29 additions and 121 deletions

View file

@ -1,21 +1,8 @@
## [1.4.3](https://github.com/fgrehm/vagrant-lxc/compare/v1.4.2...v1.4.3) (Sep 27, 2018)
FEATURES:
- Add config for container ssh IP. [[GH-469]]
FIXES:
- Fix problems with `redir` command line (bis). [[GH-473]]
[GH-469]: https://github.com/fgrehm/vagrant-lxc/issues/469
[GH-473]: https://github.com/fgrehm/vagrant-lxc/issues/473
## [1.4.2](https://github.com/fgrehm/vagrant-lxc/compare/v1.4.1...v1.4.2) (Jul 17, 2018)
FIXES:
- Fix problems with `redir` 3.x command line. [[GH-467]]
[GH-467]: https://github.com/fgrehm/vagrant-lxc/issues/467
## [1.4.1](https://github.com/fgrehm/vagrant-lxc/compare/v1.4.0...v1.4.1) (Apr 30, 2018)
FEATURES:

View file

@ -1,7 +1,7 @@
source 'https://rubygems.org'
group :development do
gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v1.8.7'
gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git'
gem 'guard'
gem 'guard-rspec'
gem 'rb-inotify'
@ -9,10 +9,9 @@ end
group :development, :test do
gem 'rake', '~> 10.4.2'
gem 'rspec', '~> 2.99.0'
gem 'rspec', '~> 3.5.0'
gem 'coveralls', '~> 0.7.2', require: (ENV['COVERAGE'] == 'true')
# The is the ref *just* before we switch to childprocess 0.6, which conflicts with vagrant 1.8 deps.
gem 'vagrant-spec', git: 'https://github.com/mitchellh/vagrant-spec.git', ref: '5006bc73cd8796465ca09307d4774f8ec8375aa0'
gem 'vagrant-spec', git: 'https://github.com/mitchellh/vagrant-spec.git'
end
group :plugins do

View file

@ -1,8 +1,12 @@
🟢 We plan to support and maintain vagrant-lxc, as well as clean it up.<br/>
🟢 Please feel free to contribute Issues and pull requests.<br/>
🟢 P.S: Thanks [Fabio Rehm](https://fabiorehm.com) for the amazing initial project.
# vagrant-lxc
[![Build Status](https://travis-ci.org/fgrehm/vagrant-lxc.png?branch=master)](https://travis-ci.org/fgrehm/vagrant-lxc) [![Gem Version](https://badge.fury.io/rb/vagrant-lxc.png)](http://badge.fury.io/rb/vagrant-lxc) [![Code Climate](https://codeclimate.com/github/fgrehm/vagrant-lxc.png)](https://codeclimate.com/github/fgrehm/vagrant-lxc) [![Coverage Status](https://coveralls.io/repos/fgrehm/vagrant-lxc/badge.png?branch=master)](https://coveralls.io/r/fgrehm/vagrant-lxc) [![Gitter chat](https://badges.gitter.im/fgrehm/vagrant-lxc.png)](https://gitter.im/fgrehm/vagrant-lxc)
[LXC](http://lxc.sourceforge.net/) provider for [Vagrant](http://www.vagrantup.com/) 1.8+
[LXC](http://lxc.sourceforge.net/) provider for [Vagrant](http://www.vagrantup.com/) 1.9+
This is a Vagrant plugin that allows it to control and provision Linux Containers
as an alternative to the built in VirtualBox provider for Linux hosts. Check out
@ -17,8 +21,8 @@ to see it in action.
## Requirements
* [Vagrant 1.8+](http://www.vagrantup.com/downloads.html)
* lxc >=1.0
* [Vagrant 1.9+](http://www.vagrantup.com/downloads.html)
* lxc >=2.1
* `redir` (if you are planning to use port forwarding)
* `brctl` (if you are planning to use private networks, on Ubuntu this means `apt-get install bridge-utils`)
@ -51,8 +55,9 @@ _More information about skipping the `--provider` argument can be found at the
## Base boxes
Base boxes can be found on [Atlas](https://atlas.hashicorp.com/boxes/search?provider=lxc)
and some scripts to build your own are available at [fgrehm/vagrant-lxc-base-boxes](https://github.com/fgrehm/vagrant-lxc-base-boxes).
Base boxes provided on Atlas haven't been refreshed for a good while and shouldn't be relied on.
Your best best is to build your boxes yourself. Some scripts to build your own are available at
[hsoft/vagrant-lxc-base-boxes](https://github.com/hsoft/vagrant-lxc-base-boxes).
If you want to build your own boxes, please have a look at [`BOXES.md`](https://github.com/fgrehm/vagrant-lxc/tree/master/BOXES.md)
for more information.

View file

@ -50,20 +50,20 @@ module Vagrant
end
def rootfs_path
config_entry = config_string.match(/^lxc\.rootfs\s+=\s+(.+)$/)[1]
case config_entry
when /^overlayfs:/
pathtype, path = config_string.match(/^lxc\.rootfs(?:\.path)?\s+=\s+(.+:)?(.+)$/)[1..2]
case pathtype
when 'overlayfs:'
# Split on colon (:), ignoring any colon escaped by an escape character ( \ )
# Pays attention to when the escape character is itself escaped.
fs_type, master_path, overlay_path = config_entry.split(/(?<!\\)(?:\\\\)*:/)
_, overlay_path = config_entry.split(/(?<!\\)(?:\\\\)*:/)
if overlay_path
Pathname.new(overlay_path)
else
# Malformed: fall back to prior behaviour
Pathname.new(config_entry)
Pathname.new(path)
end
else
Pathname.new(config_entry)
Pathname.new(path)
end
end
@ -122,10 +122,6 @@ module Vagrant
@cli.destroy
end
def supports_attach?
@cli.supports_attach?
end
def attach(*command)
@cli.attach(*command)
end

View file

@ -89,7 +89,6 @@ module Vagrant
# Man Page:
# 2 The specified container exists but was not running.
def stop
attach '/sbin/halt' if supports_attach?
begin
run :stop, '--name', @name
rescue LXC::Errors::ExecuteError => e
@ -142,19 +141,6 @@ module Vagrant
end
end
def supports_attach?
unless defined?(@supports_attach)
begin
@supports_attach = true
run(:attach, '--name', @name, '--', '/bin/true')
rescue LXC::Errors::ExecuteError
@supports_attach = false
end
end
return @supports_attach
end
private
def run(command, *args)

View file

@ -10,7 +10,7 @@ module Vagrant
EOF
provider(:lxc, parallel: true, priority: 7) do
require File.expand_path("../provider", __FILE__)
require_relative 'provider'
init!
Provider
end
@ -22,13 +22,13 @@ module Vagrant
end
config(:lxc, :provider) do
require File.expand_path("../config", __FILE__)
require_relative 'config'
init!
Config
end
synced_folder(:lxc) do
require File.expand_path("../synced_folder", __FILE__)
require_relative 'synced_folder'
SyncedFolder
end

View file

@ -1,5 +1,5 @@
module Vagrant
module LXC
VERSION = "1.4.3"
VERSION = "1.4.2"
end
end

View file

@ -390,7 +390,7 @@ else
;;
"")
if installed ipcalc; then
eval $(ipcalc -b $IPADDR)
eval "$(ipcalc -b $IPADDR)"
ip netns exec "$NSPID" ip addr add "$IPADDR" brd "$BROADCAST" dev "$CONTAINER_IFNAME"
else
ip netns exec "$NSPID" ip addr add "$IPADDR" dev "$CONTAINER_IFNAME"

View file

@ -134,39 +134,14 @@ describe Vagrant::LXC::Driver::CLI do
before do
allow(subject).to receive(:run)
end
context 'lxc-attach is supported' do
before do
subject.stub(attach: true, supports_attach?: true)
subject.stop
end
it 'runs a /sbin/halt within the container' do
expect(subject).to have_received(:attach).with('/sbin/halt')
end
it 'issues a lxc-stop with provided container name' do
expect(subject).to have_received(:run).with(:stop, '--name', name)
end
end
context 'lxc-attach is not supported' do
before do
subject.stub(attach: false, supports_attach?: false)
subject.stop
end
it 'runs a /sbin/halt within the container' do
expect(subject).to_not have_received(:attach)
end
it 'issues a lxc-stop with provided container name' do
expect(subject).to have_received(:run).with(:stop, '--name', name)
end
end
end
describe 'state' do
let(:name) { 'a-container' }
subject { described_class.new(sudo_wrapper, name) }
@ -231,33 +206,4 @@ describe Vagrant::LXC::Driver::CLI do
skip 'waits for the expected container state'
end
describe 'check for whether lxc-attach is supported' do
let(:name) { 'a-running-container' }
subject { described_class.new(sudo_wrapper, name) }
context 'lxc-attach is present on system' do
before { subject.stub(run: true) }
it 'returns true if `lxc-attach --name CNAME -- /bin/true` works' do
expect(subject.supports_attach?).to be_truthy
expect(subject).to have_received(:run).with(
:attach, '--name', name, '--', '/bin/true'
)
end
end
context 'lxc-attach is not present on system' do
before do
allow(subject).to receive(:run).and_raise(Vagrant::LXC::Errors::ExecuteError.new('msg'))
end
it 'returns true if `lxc-attach --name CNAME -- /bin/true` works' do
expect(subject.supports_attach?).to be_falsy
expect(subject).to have_received(:run).with(
:attach, '--name', name, '--', '/bin/true'
)
end
end
end
end

View file

@ -75,17 +75,6 @@ describe Vagrant::LXC::Driver do
end
end
describe 'supports_attach?' do
let(:cli) { double(Vagrant::LXC::Driver::CLI, supports_attach?: true) }
subject { described_class.new('name', nil, cli) }
it 'delegates to cli object' do
expect(subject.supports_attach?).to be_truthy
expect(cli).to have_received(:supports_attach?)
end
end
describe 'start' do
let(:customizations) { [['a', '1'], ['b', '2']] }
let(:internal_customization) { ['internal', 'customization'] }