Browse Source

store machine id, so that ansible provisioner can create inventory file

master
Georg Hopp 9 years ago
parent
commit
98100c7c09
  1. 4
      gentoo.json
  2. BIN
      gentoo_001_lxd.box
  3. 2
      gentoo_box/metadata.json
  4. 7
      lib/vagrant/lxd/action.rb
  5. 6
      lib/vagrant/lxd/action/create.rb
  6. 3
      lib/vagrant/lxd/command.rb
  7. 6
      lib/vagrant/lxd/config.rb
  8. 8
      lib/vagrant/lxd/plugin.rb
  9. 6
      playbook.yml
  10. 4
      sid.json
  11. BIN
      sid_001_lxd.box
  12. 3
      sid_box/metadata.json

4
gentoo.json

@ -7,9 +7,9 @@
"providers": [ "providers": [
{ {
"name": "lxd", "name": "lxd",
"url": "file:///data/ghopp/projects/vagrant/vagrant-lxd/gentoo_001_lxd.box",
"url": "file:///home/hopp/projects/vagrant/vagrant-lxd/gentoo_001_lxd.box",
"checksum_type": "sha1", "checksum_type": "sha1",
"checksum": "303573ec033c0eb1939df486f444c5bcc3f82d1e"
"checksum": "279b73b0a0f51368376a89283c842c5b474f9274"
} }
] ]
} }

BIN
gentoo_001_lxd.box

2
gentoo_box/metadata.json

@ -11,7 +11,7 @@
}, },
"packages": { "packages": {
"exec": [ "exec": [
["emerge", "--update", "sudo"]
["emerge", "--update", "sudo", "dhcpcd"]
] ]
}, },
"sudo": { "sudo": {

7
lib/vagrant/lxd/action.rb

@ -49,6 +49,13 @@ module Vagrant
b.use SSHExec b.use SSHExec
end end
end end
def self.action_provision
Vagrant::Action::Builder.new.tap do |b|
#b.use CheckAccessible
b.use Provision
end
end
end end
end end
end end

6
lib/vagrant/lxd/action/create.rb

@ -18,6 +18,12 @@ module Vagrant
env[:ui].info "--- #{driver.name} created ---", :prefix => false env[:ui].info "--- #{driver.name} created ---", :prefix => false
end end
# TODO maybe not optimal, check if it would be better to include the
# pid of the init process to the id of the machine.
# Well, in that case the id changes with every restart which might
# not be feasable...
env[:machine].id = driver.name
@app.call(env) @app.call(env)
end end
end end

3
lib/vagrant/lxd/command.rb

@ -7,6 +7,9 @@ module Vagrant
def execute def execute
@env.ui.info("my own plugin", :prefix => false) @env.ui.info("my own plugin", :prefix => false)
@env.ui.info("--- #{@env.inspect} ---", :prefix => false)
@env.ui.info("--- #{@local_data_path} ---", :prefix => false)
@env.ui.info("--- #{@env.active_machines} ---", :prefix => false)
end end
end end
end end

6
lib/vagrant/lxd/config.rb

@ -0,0 +1,6 @@
module Vagrant
module Lxd
class Config < Vagrant.plugin("2", :config)
end
end
end

8
lib/vagrant/lxd/plugin.rb

@ -16,10 +16,10 @@ module Vagrant
Provider Provider
end end
#config(:lxd, :provider) do
# require File.expand_path("../config", __FILE__)
# Config
#end
config(:lxd, :provider) do
require_relative "config"
Config
end
#synced_folder(:virtualbox) do #synced_folder(:virtualbox) do
# require File.expand_path("../synced_folder", __FILE__) # require File.expand_path("../synced_folder", __FILE__)

6
playbook.yml

@ -0,0 +1,6 @@
---
- hosts: all
become: true
tasks:
- name: test connection
ping:

4
sid.json

@ -7,9 +7,9 @@
"providers": [ "providers": [
{ {
"name": "lxd", "name": "lxd",
"url": "file:///data/ghopp/projects/vagrant/vagrant-lxd/sid_001_lxd.box",
"url": "file:///home/hopp/projects/vagrant/vagrant-lxd/sid_001_lxd.box",
"checksum_type": "sha1", "checksum_type": "sha1",
"checksum": "a533654e7577931659c1cb457b13e6b184d4013d"
"checksum": "21d7376327acdb7f36aa25ed89039248c6562415"
} }
] ]
} }

BIN
sid_001_lxd.box

3
sid_box/metadata.json

@ -10,7 +10,8 @@
"packages": { "packages": {
"exec": [ "exec": [
["apt-get", "install", "-y", "sudo"], ["apt-get", "install", "-y", "sudo"],
["apt-get", "install", "-y", "openssh-server"]
["apt-get", "install", "-y", "openssh-server"],
["apt-get", "install", "-y", "python"]
] ]
}, },
"sudo": { "sudo": {

Loading…
Cancel
Save