vagrant-smartos / vagrant-smartos-zones

Manage SmartOS local zones in Vagrant
MIT License
54 stars 9 forks source link

lx brand configuration #12

Closed tylerflint closed 9 years ago

tylerflint commented 10 years ago

With many of the Joyent engineers focusing on lx brand zones, there have been many in the community who have stepped up to assist in testing. Observing the experience in the #smartos irc, it seems like this project would really help speed up the testing process.

I'm not familiar with lx brands, but I wonder how users and groups are configured. Is it the linux way, or solaris way? Either way, I suspect the zone setup/configuration of an lx brand might need different commands to run.

bixu commented 10 years ago

I'm pretty sure that we'll be using Linux-flavored 'useradd', etc to manage the logins for the lx brand zone. Hopefully we can re-use existing Vagrant code for this, but I don't know how modular that code is ATM.

sax commented 10 years ago

The user creation is specific to the plugin, as Vagrant assumes the user is already created.

FYI users are created in the zone here: https://github.com/vagrant-smartos/vagrant-smartos-zones/blob/master/lib/vagrant/smartos/zones/cap/create_zone_users.rb

I assume that zlogin will work with lx brands, but I have no idea how user management will work.

bixu commented 10 years ago

Please assign this to me.

bixu commented 10 years ago

@sax @tylerflint - here's what I've worked out so far - still need logic to only apply lx-specific features when present in config and also similar logic to send linux-specific command with zlogin (working through those manually):

monolith:vagrant-smartos-zones blake$ git status
# On branch lx_brand_zones
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   lib/vagrant/smartos/zones/cap/zone/create.rb
#   modified:   lib/vagrant/smartos/zones/config/zone.rb
#
no changes added to commit (use "git add" and/or "git commit -a")
monolith:vagrant-smartos-zones blake$ git diff
diff --git a/lib/vagrant/smartos/zones/cap/zone/create.rb b/lib/vagrant/smartos/zones/cap/zone/create.rb
index 97d890e..fec2e27 100644
--- a/lib/vagrant/smartos/zones/cap/zone/create.rb
+++ b/lib/vagrant/smartos/zones/cap/zone/create.rb
@@ -42,9 +42,10 @@ module Vagrant
               machine.communicate.gz_execute("echo '#{zone_json(machine)}' | #{sudo} vmadm update #{zone_uuid(machine)}")
             end

-            def self.zone_json(machine)
+            def self.zone_json(machine)
               {
                 "brand" => machine.config.zone.brand,
+                "kernel_version" => machine.config.zone.kernel_version,
                 "alias" => machine.config.zone.name,
                 "dataset_uuid" => machine.config.zone.image,
                 "quota" => machine.config.zone.disk_size || 1,
diff --git a/lib/vagrant/smartos/zones/config/zone.rb b/lib/vagrant/smartos/zones/config/zone.rb
index 0970a32..1c938a8 100644
--- a/lib/vagrant/smartos/zones/config/zone.rb
+++ b/lib/vagrant/smartos/zones/config/zone.rb
@@ -5,11 +5,12 @@ module Vagrant
     module Zones
       module Config
         class Zone < Vagrant.plugin("2", :config)
-          attr_accessor :brand, :disk_size, :image, :memory, :name
+          attr_accessor :brand, :kernel_version, :disk_size, :image, :memory, :name
           attr_reader :synced_folders

           def initialize
             @brand = UNSET_VALUE
+            @kernel_verison = UNSET_VALUE
             @disk_size = UNSET_VALUE
             @image = UNSET_VALUE
             @memory = UNSET_VALUE
monolith:vagrant-smartos-zones blake$
bixu commented 9 years ago

It looks like Joyent has fixed the issues with zlogin <zone> <command>, so I'm looking into this again.

bixu commented 9 years ago
echo '{"brand":"lx", "kernel_version":"3.16","alias":"lx","dataset_uuid":"b7493690-f019-4612-958b-bab5f844283e","quota":5,"max_physical_memory":1536,"fs_allowed":"vboxfs","resolvers":["8.8.8.8","8.8.4.4"],"nics":[{"nic_tag":"stub0","ip":"10.0.0.2","netmask":"255.255.255.0","gateway":"10.0.0.1","allow_ip_spoofing":true}]}' | pfexec vmadm create

works with the latest plugin code/platform image (this was a manual test)

tylerflint commented 9 years ago

Nice. So now we just need to manually test the following within an lx brand zone:

1- create group 2- create user 3- sudo

If those work, the plugin can be modified to support lx branded zones with little effort.

Very cool.

bixu commented 9 years ago

Since so much refactoring happened since my last stab at this, I threw out my forked work and am now in a feature branch here: https://github.com/vagrant-smartos/vagrant-smartos-zones/tree/feature/lx_zone_support

Currently have a working sketch of code but would like to do some remote pairing with someone to work out the fine details. Also need to figure out some linux-isms:

==> default: Installing vnic in global zone
==> default: Installing ZoneGate
==> default: Checking if machine supports zones: yes
==> default: Checking for zone image b7493690-f019-4612-958b-bab5f844283e: installed
==> default: Creating zone lx_brand with image b7493690-f019-4612-958b-bab5f844283e
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

pfexec zlogin 628f72a0-7a78-4ec7-8748-99958855cc3b useradd -m -s /bin/bash -G vagrant vagrant

Stdout from the command:

Stderr from the command:

useradd: group vagrant exists - if you want to add this user to that group, use -g.
sax commented 9 years ago

@bixu have you played around with this any more? Can we close this issue?

bixu commented 9 years ago

I've used it enough that I think we can consider the feature delivered.