-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
2,709 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.vagrant | ||
template.json | ||
*.box | ||
*.log | ||
tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Base Box `nat-xenial` | ||
====================== | ||
|
||
This box builds a NAT'd Ubuntu Xenial RH or Peer based on configuration settings. | ||
|
||
Unless stated otherwise all machine architectures are amd64. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
require 'fileutils' | ||
|
||
unless Vagrant.has_plugin?('vagrant-subutai') | ||
raise "\e[33m\n\nVagrant Subutai Plugin is required. Please install plugin by following command:\n\nvagrant plugin install vagrant-subutai\n\e[0m" | ||
end | ||
|
||
# check dependency | ||
if Gem::Version.new(VagrantSubutai::VERSION) < Gem::Version.new('7.0.3') | ||
raise "\e[33m\n\nVagrant Subutai Plugin version (#{VagrantSubutai::VERSION}) is incompatible with your box. Please update plugin by following command:\n\nvagrant plugin update vagrant-subutai\n\e[0m" | ||
end | ||
|
||
require 'vagrant-subutai' | ||
|
||
SubutaiConfig.bridged! | ||
# SubutaiConfig.logging!(:debug) | ||
|
||
SubutaiConfig.load_config(ARGV[0], :hyper_v) | ||
SubutaiConfig.print | ||
|
||
Vagrant.require_version '>= 2.0.1' | ||
|
||
Vagrant.configure('2') do |config| | ||
config.vm.box = 'subutai/xenial' | ||
url = SubutaiConfig.url_of_cdn | ||
owner = 'subutai' | ||
artifact_name = 'vagrant-subutai-xenial-hyperv.box' | ||
config.vm.box_url = url + '/raw/download?id=' + SubutaiConfig.get_latest_id_artifact(owner, artifact_name) | ||
config.ssh.username = 'subutai' | ||
|
||
config.vm.base_mac = SubutaiConfig.get(:_BASE_MAC) | ||
|
||
config.vm.synced_folder ".", "/vagrant", disabled: true | ||
|
||
config.vm.network 'public_network', :bridge => SubutaiConfig.get(:BRIDGE) | ||
|
||
config.vm.provider "hyperv" do |h| | ||
h.maxmemory = SubutaiConfig.get(:SUBUTAI_RAM) | ||
h.memory = SubutaiConfig.get(:SUBUTAI_RAM) | ||
h.cpus = SubutaiConfig.get(:SUBUTAI_CPU) | ||
end | ||
|
||
if SubutaiConfig.write? || SubutaiConfig.reload? | ||
has_grow, grow_by = SubutaiDisk.has_grow | ||
|
||
if has_grow | ||
config.vm.provision :create_disk, run: "always" | ||
config.vm.provision "shell", run: "always", env: {DISK_SIZE: grow_by.to_i}, | ||
path: 'https://raw.githubusercontent.com/subutai-io/packer/master/provisioning/en/subutai_disk.sh' | ||
end | ||
end | ||
|
||
config.vm.provision 'shell', env: SubutaiConfig.config, inline: <<-SHELL | ||
echo "SUBUTAI_VAGRANT_VERSION=$VERSION" >> /etc/environment | ||
echo "SUBUTAI_BRIDGE_IFACE=eth0" >> /etc/environment | ||
#echo "SUBUTAI_NAT_IFACE=enp0s3" >> /etc/environment | ||
#echo "SUBUTAI_HOST_IFACE=enp0s9" >> /etc/environment | ||
if [ -n "$APT_PROXY_URL" ]; then | ||
echo 'Acquire::http { Proxy "'$APT_PROXY_URL'"; };' > /etc/apt/apt.conf.d/02proxy | ||
fi | ||
if [ -n "$PASSWORD_OVERRIDE" ]; then | ||
usermod --password $(echo "$PASSWORD_OVERRIDE" | openssl passwd -1 -stdin) subutai | ||
fi | ||
SHELL | ||
|
||
unless SubutaiConfig.get(:AUTHORIZED_KEYS).nil? | ||
config.vm.provision 'file', source: SubutaiConfig.get(:AUTHORIZED_KEYS), destination: '/tmp/authorized_keys' | ||
|
||
config.vm.provision 'shell', inline: <<-SHELL | ||
mkdir -p /root/.ssh | ||
cat /tmp/authorized_keys >> /root/.ssh/authorized_keys | ||
chmod 600 /root/.ssh/authorized_keys | ||
chmod 700 /root/.ssh | ||
mkdir -p /home/subutai/.ssh | ||
cat /tmp/authorized_keys >> /home/subutai/.ssh/authorized_keys | ||
chown subutai:subutai /home/subutai/.ssh/authorized_keys | ||
chmod 600 /home/subutai/.ssh/authorized_keys | ||
chmod 700 /home/subutai/.ssh | ||
chown subutai:subutai /home/subutai/.ssh | ||
SHELL | ||
end | ||
|
||
if SubutaiConfig.provision_management? | ||
config.vm.provision 'file', source: SubutaiConfig.get(:_ALT_MANAGEMENT), destination: '$HOME/subutai.management' | ||
SubutaiConfig.management_provisioned! | ||
end | ||
|
||
config.vm.provision 'shell', env: SubutaiConfig.config, | ||
path: 'https://raw.githubusercontent.com/subutai-io/packer/master/provisioning/en/provisioner.sh' | ||
|
||
if SubutaiConfig.boolean?(:PROVISION) | ||
config.vm.provision :registration | ||
config.vm.provision :blueprint | ||
end | ||
|
||
if SubutaiConfig.boolean?(:SUBUTAI_DESKTOP) | ||
config.vm.provision 'shell', env: SubutaiConfig.config, | ||
path: 'https://raw.githubusercontent.com/subutai-io/packer/master/provisioning/en/subutai_desktop.sh' | ||
end | ||
|
||
config.vm.provision 'shell', env: SubutaiConfig.config, | ||
path: 'https://raw.githubusercontent.com/subutai-io/packer/master/provisioning/en/logrotate.sh' | ||
|
||
config.vm.provision :cleanup | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"type": "hyperv-iso", | ||
"vm_name": "{{ user `vm_name` }}", | ||
"boot_command": import ".\\http\\hyperv\\ubuntu-boot.jsonnet", | ||
"disk_size": "{{user `disk_size`}}", | ||
"guest_additions_mode": "disable", | ||
"iso_url": "{{user `iso_url`}}", | ||
"iso_checksum_type": "{{user `iso_checksum_type`}}", | ||
"iso_checksum": "{{user `iso_checksum`}}", | ||
"communicator": "ssh", | ||
"ssh_username": "{{user `ssh_username`}}", | ||
"ssh_password": "{{user `ssh_password`}}", | ||
"ssh_timeout" : "4h", | ||
"http_directory": "./http/", | ||
"boot_wait": "5s", | ||
"shutdown_command": "echo {{user `ssh_password`}} | sudo -S -E shutdown -P now", | ||
"ram_size": "{{user `memory`}}", | ||
"cpu": "{{user `cpus`}}", | ||
"generation": 2, | ||
"switch_name": "{{user `hyperv_switchname`}}", | ||
"enable_secure_boot": false, | ||
"enable_mac_spoofing": true, | ||
"enable_dynamic_memory": false, | ||
"enable_virtualization_extensions": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"output": "vagrant-subutai-{{user `vm_name`}}-hyperv-{{user `version`}}.box", | ||
"vagrantfile_template": ".\\xenial\\hyperv\\Vagrantfile" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"type": "shell", | ||
"execute_command": "export PROXY_ON='{{user `proxy_on`}}';export APT_PROXY_HOST='{{user `apt_proxy_host`}}';export APT_PROXY_URL='{{user `apt_proxy_url`}}';export BRANCHTAG='{{user `branch_or_tag`}}';export DISTRIBUTION='{{user `distribution`}}';export DESKTOP='{{user `desktop`}}';export SSH_USERNAME='{{user `ssh_username`}}';export SSH_PASSWORD='{{user `ssh_password`}}'; echo '{{user `ssh_password`}}' | {{ .Vars }} sudo -E -S sh '{{ .Path }}'", | ||
"inline": [ | ||
"echo 'subutai ALL=NOPASSWD: ALL' >> /etc/sudoers", | ||
"date > /home/{{user `ssh_username`}}/vagrant_box_build_time", | ||
"echo Updating from repositories ...", | ||
"DEBIAN_FRONTEND=noninteractive apt-get -q -y update", | ||
"echo Upgrading...", | ||
"DEBIAN_FRONTEND=noninteractive apt-get -q -y upgrade", | ||
"echo Upgrading distribution ...", | ||
"DEBIAN_FRONTEND=noninteractive apt-get -q -y dist-upgrade", | ||
"echo Adding needed packages ...", | ||
"DEBIAN_FRONTEND=noninteractive apt-get -q -y install net-tools inotify-tools", | ||
"DEBIAN_FRONTEND=noninteractive apt-get -q -y install linux-cloud-tools-$(uname -r)", | ||
"DEBIAN_FRONTEND=noninteractive apt-get -q -y install linux-virtual-lts-xenial linux-tools-virtual-lts-xenial linux-cloud-tools-virtual-lts-xenial", | ||
"echo \"{{user `ssh_username`}} ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers.d/{{user `ssh_username`}}", | ||
"chmod 440 /etc/sudoers.d/{{user `ssh_username`}}", | ||
"mkdir -pm 700 /home/{{user `ssh_username`}}/.ssh", | ||
"wget --no-check-certificate https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub -O /home/{{user `ssh_username`}}/.ssh/authorized_keys", | ||
"chmod 0600 /home/{{user `ssh_username`}}/.ssh/authorized_keys", | ||
"chown -R {{user `ssh_username`}}:{{user `ssh_username`}} /home/{{user `ssh_username`}}/.ssh", | ||
"cp /tmp/sources.list /etc/apt/sources.list", | ||
"DEBIAN_FRONTEND=noninteractive apt-get -q update", | ||
"sed -i '1 i\\ulimit -n 65535' /etc/profile", | ||
"DEBIAN_FRONTEND=noninteractive apt-get -q -y install zfsutils-linux", | ||
"/sbin/modprobe zfs", | ||
"zpool create -f subutai /dev/mapper/main-zfs", | ||
"zfs create -o mountpoint=\"/var/lib/lxc\" subutai/fs", | ||
"zpool set autoexpand=on subutai", | ||
"DEBIAN_FRONTEND=noninteractive apt-get -q -y install lxc", | ||
"DEBIAN_FRONTEND=noninteractive apt-get -q -y install dirmngr", | ||
"apt-key adv --recv-keys --keyserver keyserver.ubuntu.com C6B2AC7FBEB649F1" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"builders": [ | ||
import ".\\xenial\\hyperv\\builder.jsonnet", | ||
], | ||
"post-processors": [ | ||
[ | ||
{ | ||
"compression_level": 9, | ||
"keep_input_artifact": false, | ||
"only": [ | ||
"hyperv-iso" | ||
], | ||
"override": { | ||
"hyperv": import ".\\xenial\\hyperv\\post-processor.jsonnet" | ||
}, | ||
"type": "vagrant" | ||
} | ||
] | ||
], | ||
"provisioners": [ | ||
{ | ||
type: "file", | ||
source: ".\\http\\xenial.sources.list", | ||
destination: "/tmp/sources.list" | ||
}, | ||
{ | ||
"override": { | ||
"hyperv-iso": import ".\\xenial\\hyperv\\provisioner.jsonnet", | ||
}, | ||
"type": "shell" | ||
}, | ||
], | ||
"variables": import ".\\xenial\\variables.jsonnet" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
require 'fileutils' | ||
|
||
unless Vagrant.has_plugin?('vagrant-subutai') | ||
raise "\e[33m\n\nVagrant Subutai Plugin is required. Please install plugin by following command:\n\nvagrant plugin install vagrant-subutai\n\e[0m" | ||
end | ||
|
||
unless Vagrant.has_plugin?('vagrant-libvirt') | ||
raise "\e[33m\n\nVagrant Libvirt Plugin is required. Please install plugin by following command:\n\nvagrant plugin install vagrant-libvirt\n\e[0m" | ||
end | ||
|
||
if Gem::Version.new(VagrantSubutai::VERSION) < Gem::Version.new('7.0.4') | ||
raise "\e[33m\n\nVagrant Subutai Plugin version (#{VagrantSubutai::VERSION}) is incompatible with your box. Please update plugin by following command:\n\nvagrant plugin update vagrant-subutai\n\e[0m" | ||
end | ||
|
||
require 'vagrant-subutai' | ||
|
||
SubutaiConfig.bridged! | ||
#SubutaiConfig.logging!(:debug) | ||
|
||
SubutaiConfig.load_config(ARGV[0], :libvirt) | ||
SubutaiConfig.print | ||
|
||
Vagrant.require_version '>= 2.0.1' | ||
|
||
Vagrant.configure('2') do |config| | ||
|
||
config.vm.box = 'subutai/xenial' | ||
url = SubutaiConfig.url_of_cdn | ||
owner = 'subutai' | ||
artifact_name = 'vagrant-subutai-xenial-libvirt.box' | ||
config.vm.box_url = url + '/raw/download?id=' + SubutaiConfig.get_latest_id_artifact(owner, artifact_name) | ||
config.ssh.username = 'subutai' | ||
|
||
# check LIBVIRT_USER and LIBVIRT_HOST | ||
if !SubutaiConfig.get(:LIBVIRT_HOST).nil? && !SubutaiConfig.get(:LIBVIRT_USER).nil? | ||
STDOUT.puts "\e\n==> default: Started libvirt operation in remote machine\n. USER: #{SubutaiConfig.get(:LIBVIRT_USER)}, HOST: #{SubutaiConfig.get(:LIBVIRT_HOST).strip}\e[0m" | ||
proxy_timeout = 500000 | ||
|
||
config.ssh.insert_key = false | ||
config.ssh.forward_agent = true | ||
config.ssh.proxy_command = "ssh -p #{SubutaiConfig.get(:LIBVIRT_PORT)} #{SubutaiConfig.get(:LIBVIRT_USER).strip}@#{SubutaiConfig.get(:LIBVIRT_HOST).strip} netcat -w #{proxy_timeout} %h %p" | ||
end | ||
|
||
config.vm.base_mac = SubutaiConfig.get(:_BASE_MAC) | ||
|
||
# Second Bridged Interface enp??? | ||
unless SubutaiConfig.get(:BRIDGE).nil? || SubutaiConfig.boolean?(:LIBVIRT_NO_BRIDGE) | ||
if SubutaiConfig.get(:LIBVIRT_MACVTAP) | ||
config.vm.network "public_network", type: "direct", | ||
dev: SubutaiConfig.get(:BRIDGE), | ||
mode: "bridge", | ||
network_name: "public-network" | ||
else | ||
config.vm.network "public_network", type: "bridge", | ||
dev: SubutaiConfig.get(:BRIDGE), | ||
mode: "bridge", | ||
network_name: "public-network" | ||
end | ||
end | ||
|
||
if SubutaiConfig.boolean?(:SUBUTAI_PEER) | ||
config.vm.network 'forwarded_port', guest: 8443, host: SubutaiConfig.get(:_CONSOLE_PORT) | ||
end | ||
|
||
config.vm.synced_folder ".", "/vagrant", disabled: false | ||
|
||
config.vm.provider 'libvirt' do |libvirt| | ||
libvirt.driver = 'kvm' | ||
libvirt.username = 'subutai' | ||
libvirt.storage_pool_name = 'default' | ||
libvirt.random_hostname = "#{(0...8).map { ('a'..'z').to_a[rand(26)] }.join}" # generates random 8 character string | ||
|
||
libvirt.memory = SubutaiConfig.get(:SUBUTAI_RAM) | ||
libvirt.cpus = SubutaiConfig.get(:SUBUTAI_CPU) | ||
|
||
if SubutaiConfig.write? || SubutaiConfig.reload? | ||
has_grow, grow_by = SubutaiDisk.has_grow | ||
|
||
if has_grow | ||
size = SubutaiDisk.libvirt_size(grow_by) | ||
|
||
STDOUT.puts "\e[33m#{SubutaiDisk.message(grow_by)}\e[0m" | ||
|
||
libvirt.storage :file, :size => size, :cache => "none" | ||
|
||
SubutaiDisk.save_conf(grow_by) | ||
end | ||
end | ||
|
||
# check LIBVIRT_USER and LIBVIRT_HOST | ||
if !SubutaiConfig.get(:LIBVIRT_HOST).nil? && !SubutaiConfig.get(:LIBVIRT_USER).nil? | ||
libvirt.uri = "qemu+ssh://#{SubutaiConfig.get(:LIBVIRT_USER).strip}@#{SubutaiConfig.get(:LIBVIRT_HOST).strip}:#{SubutaiConfig.get(:LIBVIRT_PORT)}/system" | ||
libvirt.connect_via_ssh | ||
end | ||
end | ||
|
||
if SubutaiConfig.write? || SubutaiConfig.reload? | ||
has_grow, grow_by = SubutaiDisk.has_grow | ||
|
||
if has_grow | ||
config.vm.provision "shell", run: "always", env: {DISK_SIZE: grow_by.to_i}, | ||
path: 'https://raw.githubusercontent.com/subutai-io/packer/master/provisioning/en/virtio/subutai_disk.sh' | ||
end | ||
end | ||
|
||
config.vm.provision 'shell', env: SubutaiConfig.config, inline: <<-SHELL | ||
echo "SUBUTAI_VAGRANT_VERSION=$VERSION" >> /etc/environment | ||
echo "SUBUTAI_BRIDGE_IFACE=eth1" >> /etc/environment | ||
echo "SUBUTAI_NAT_IFACE=eth0" >> /etc/environment | ||
if [ -n "$APT_PROXY_URL" ]; then | ||
echo 'Acquire::http { Proxy "'$APT_PROXY_URL'"; };' > /etc/apt/apt.conf.d/02proxy | ||
fi | ||
if [ -n "$PASSWORD_OVERRIDE" ]; then | ||
usermod --password $(echo "$PASSWORD_OVERRIDE" | openssl passwd -1 -stdin) subutai | ||
fi | ||
SHELL | ||
|
||
unless SubutaiConfig.get(:AUTHORIZED_KEYS).nil? | ||
config.vm.provision 'file', source: SubutaiConfig.get(:AUTHORIZED_KEYS), destination: '/tmp/authorized_keys' | ||
|
||
config.vm.provision 'shell', inline: <<-SHELL | ||
mkdir -p /root/.ssh | ||
cat /tmp/authorized_keys >> /root/.ssh/authorized_keys | ||
chmod 600 /root/.ssh/authorized_keys | ||
chmod 700 /root/.ssh | ||
mkdir -p /home/subutai/.ssh | ||
cat /tmp/authorized_keys >> /home/subutai/.ssh/authorized_keys | ||
chown subutai:subutai /home/subutai/.ssh/authorized_keys | ||
chmod 600 /home/subutai/.ssh/authorized_keys | ||
chmod 700 /home/subutai/.ssh | ||
chown subutai:subutai /home/subutai/.ssh | ||
SHELL | ||
end | ||
|
||
if SubutaiConfig.provision_management? | ||
config.vm.provision 'file', source: SubutaiConfig.get(:_ALT_MANAGEMENT), destination: '$HOME/subutai.management' | ||
SubutaiConfig.management_provisioned! | ||
end | ||
|
||
config.vm.provision 'shell', env: SubutaiConfig.config, | ||
path: 'https://raw.githubusercontent.com/subutai-io/packer/master/provisioning/en/provisioner.sh' | ||
|
||
if SubutaiConfig.boolean?(:PROVISION) | ||
config.vm.provision :registration | ||
config.vm.provision :blueprint | ||
end | ||
|
||
if SubutaiConfig.boolean?(:SUBUTAI_DESKTOP) | ||
config.vm.provision 'shell', env: SubutaiConfig.config, | ||
path: 'https://raw.githubusercontent.com/subutai-io/packer/master/provisioning/en/subutai_desktop.sh' | ||
end | ||
|
||
config.vm.provision 'shell', env: SubutaiConfig.config, | ||
path: 'https://raw.githubusercontent.com/subutai-io/packer/master/provisioning/en/logrotate.sh' | ||
|
||
config.vm.provision :cleanup | ||
end |
Oops, something went wrong.