pixicore: Add libvirt Pixiecore Vagrantfile

This commit is contained in:
Dalton Hubble
2015-11-30 11:59:16 -08:00
parent eb7514d781
commit 87b0021445
8 changed files with 114 additions and 9 deletions

View File

@@ -1,16 +1,18 @@
`pxe` provides a Vagrantfile and scripts for setting up a PXE server in libvirt or on physical hardware.
`pixiecore` provides a Vagrantfile and scripts for setting up a Pixiecore server in libvirt or on physical hardware.
## Setup
To develop with with Vagrant, install the dependencies
To develop with Vagrant, install the dependencies
# Fedora 22/23
dnf install vagrant vagrant-libvirt virt-manager
## Usage
The Vagrantfile will setup a `pxe_default` VM running a PXE server with a configured static IP address, DHCP range, CoreOS kernel image, and cloud-config. The VM will be connected to a network called `vagrant-libvirt`.
The Vagrantfile will setup a `pxe_default` VM running a PXE server with a configured static IP address, DHCP range, CoreOS kernel image, and cloud-config. The VM will be connected to a network called `vagrant-pxe`.
### libvirt Provider
@@ -39,4 +41,4 @@ If you change the Vagrantfile or a configuration variable, reload the VM with
To try a new cloud-config, you can also scp the file onto the dev PXE server.
scp new-config.yml core@NODE_IP:/var/www/html/pxe-cloud-config.yml
scp new-config.yml core@NODE_IP:/var/www/html/cloud-config.yml

1
pixiecore/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.vagrant

33
pixiecore/Vagrantfile vendored Normal file
View File

@@ -0,0 +1,33 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'fileutils'
CLOUD_CONFIG_PATH = File.join(File.dirname(__FILE__), "user-data")
CONFIG = File.join(File.dirname(__FILE__), "config.rb")
if File.exist?(CONFIG)
require CONFIG
end
Vagrant.configure(2) do |config|
config.vm.box = "fedora/23-cloud-base"
# Create a public network with a static IP address
config.vm.network "public_network", ip: $pixiecore_server_ip, dev: "wlp3s0"
# Provider Specific Configuration
config.vm.provider :libvirt do |libvirt|
libvirt.cpus = 1
libvirt.memory = 1024
libvirt.management_network_name = "vagrant-pixiecore"
libvirt.management_network_address = $network_range
end
# Provision a Pixiecore Server
config.vm.provision :shell do |s|
s.privileged = true
s.path = "scripts/pixiecore.sh"
s.args = [$pixiecore_server_ip, $ssh_authorized_key]
end
end

9
pixiecore/config.rb Normal file
View File

@@ -0,0 +1,9 @@
# Vagrant Network CIDR
$network_range="192.168.33.0/24"
# Pixiecore Server IP, must be in the network_range
$pixiecore_server_ip="192.168.33.10"
# SSH Authorized Key for client CoreOS instances
$ssh_authorized_key="AAAAB3NzaC1yc2EAAAADAQABAAABAQC9oRIjXKgC1It3U22INv9sDbQjzZNbY6fdzN28hl2gnWf7b4/KJjbCE8cldAiV6qiLwnaqnINgoAy8JN718qos8VsLRdB/GvhlVOQvjJf6gSI9WcG1kVbbYuZ7WV1cxnxjE21+oHHz4IZyGKP6rEv0ODcFWokJt13zpK9isG7iQyBi51KNFPgox/jfM0uDCf+yzSsCX2HUUxmqKDUXD9XDihrGRpbqL6gH5VDYzDmVAHq5e3er1Sz2n+Gx/wUSXzNk9TdCY/cS6k2C6H3+dwA45HFADjmeK+k3dE+cDrXkLsB9GTXnvcmtdoVAFoHBZo8GqRKocaejVgDaRo+prQyJ dghubble@Mars"

View File

@@ -0,0 +1,61 @@
#!/bin/bash -e
# Usage: Setup a Pixiecore Server
# ./pxe.sh IP SSH_KEY
# ./pixiecore.sh "192.168.33.10" "AABC.... name"
PIXIECORE_SERVER_IP=$1
SSH_AUTHORIZED_KEYS=$2
# Pixiecore kernel and init RAM disk
dnf install -yq wget
mkdir -p /var/lib/image
wget -q -O /var/lib/image/coreos_production_pxe.vmlinuz http://stable.release.core-os.net/amd64-usr/current/coreos_production_pxe.vmlinuz
wget -q -O /var/lib/image/coreos_production_pxe_image.cpio.gz http://stable.release.core-os.net/amd64-usr/current/coreos_production_pxe_image.cpio.gz
chcon -Rt svirt_sandbox_file_t /var/lib/image
# Docker
dnf install -yq docker
systemctl enable docker.service
systemctl start docker.service
# HTTP
# static cloud-config HTTP server
dnf install -yq httpd
cat << EOF > "/var/www/html/cloud-config.yml"
#cloud-config
coreos:
units:
- name: etcd2.service
command: start
- name: fleet.service
command: start
ssh_authorized_keys:
- ssh-rsa $SSH_AUTHORIZED_KEYS
EOF
systemctl enable httpd
systemctl start httpd
# Pixiecore
docker pull danderson/pixiecore
#docker run -v /var/lib/image:/image --net=host danderson/pixiecore -kernel /image/coreos_production_pxe.vmlinuz -initrd /image/coreos_production_pxe_image.cpio.gz --cmdline cloud-config-url=http://$PIXIECORE_SERVER_IP/cloud-config.yml
cat << EOF > /etc/systemd/system/pixiecore.service
[Unit]
Description=Pixicore Service
[Service]
Type=simple
ExecStart=/usr/bin/docker run -v /var/lib/image:/image --net=host danderson/pixiecore -kernel /image/coreos_production_pxe.vmlinuz -initrd /image/coreos_production_pxe_image.cpio.gz --cmdline cloud-config-url=http://$PIXIECORE_SERVER_IP/cloud-config.yml
[Install]
WantedBy=multi-user.target
EOF
systemctl enable pixiecore.service
systemctl start pixiecore.service
echo "Done"

3
pxe/Vagrantfile vendored
View File

@@ -19,7 +19,7 @@ Vagrant.configure(2) do |config|
config.vm.provider :libvirt do |libvirt|
libvirt.cpus = 1
libvirt.memory = 1024
libvirt.management_network_name = "vagrant-libvirt"
libvirt.management_network_name = "vagrant-pxe"
libvirt.management_network_address = $network_range
end
@@ -29,5 +29,4 @@ Vagrant.configure(2) do |config|
s.path = "scripts/pxe.sh"
s.args = [$pxe_server_ip, $dhcp_range, $ssh_authorized_key]
end
end

View File

@@ -9,4 +9,4 @@ $pxe_server_ip="192.168.32.10"
$dhcp_range="192.168.32.2,192.168.32.254,12h"
# SSH Authorized Key for client CoreOS instances
$ssh_authorized_key="AAAAB3NzaC1yc2EAAAADAQABAAACAQDp9dypy87zDQgoMm9tk9aKVNDXemN2bp+taQzY4I2BS74H850SjvxVqMHbTcZVi+gMmUev9DPo5xfDOeTPeaT5fnNaKTLNGLezGM0pjMtKWOrZSQqK2YywjT/VdnBvNG6zKHE/MgpexLdkqiPJGPSHhRB+rQ5JX1FL3Qpt9prD2tW8audLmZ6PorC8/HLIwgBIrlh8JFbVFYGEy4dFImz2eyTqNUxDhP2hx17Drvssy/D6HR4zehgP1MGJWOKGfFlE2xe+hy+S6fjkPK5Nc7MR0uqhCkJHpCfVFjbHyZsQK3oi30Afe9t/CdRfPgQW+daeA7yBd1d/56A8QEbRf7W8wO5/CaSBoomA3bufJwwtT50oQwi3r0+hapivvmlUo3WhXwFoPV/XLyQUNGMWKmOWEqqmREFpi/NVnfItU8CenowvDoly0FkreztO4bAAhMd0w4/bAUisRHlucXXifqFEZr5NUt0BIaZmjavbXDadajzhwbK5mWpijuLoiuYCsa+5pQjFVlZRo5f3F3dQ5nREgRSWJPkxzllHygdEeKqxcE4slZJwZbrBgV4OT2nwGjBpfHsbBKBZRM6eKOiDIOVf/hh4+9+GirHWKosv3HRKHH9TisfIFlZoxzxY6E87oPvlf+7rEwHhuaPUoThSXxB6JS9LiOcqxjgL1ltfapgLqQ== dghubble@gmail.com"
$ssh_authorized_key="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9oRIjXKgC1It3U22INv9sDbQjzZNbY6fdzN28hl2gnWf7b4/KJjbCE8cldAiV6qiLwnaqnINgoAy8JN718qos8VsLRdB/GvhlVOQvjJf6gSI9WcG1kVbbYuZ7WV1cxnxjE21+oHHz4IZyGKP6rEv0ODcFWokJt13zpK9isG7iQyBi51KNFPgox/jfM0uDCf+yzSsCX2HUUxmqKDUXD9XDihrGRpbqL6gH5VDYzDmVAHq5e3er1Sz2n+Gx/wUSXzNk9TdCY/cS6k2C6H3+dwA45HFADjmeK+k3dE+cDrXkLsB9GTXnvcmtdoVAFoHBZo8GqRKocaejVgDaRo+prQyJ dghubble"

View File

@@ -40,7 +40,7 @@ display boot.msg
label coreos
menu default
kernel coreos_production_pxe.vmlinuz
append initrd=coreos_production_pxe_image.cpio.gz cloud-config-url=http://$PXE_SERVER_IP/pxe-cloud-config.yml
append initrd=coreos_production_pxe_image.cpio.gz cloud-config-url=http://$PXE_SERVER_IP/cloud-config.yml
EOF
# TFTP ldlinux.c32 pxelinux.0
@@ -48,7 +48,7 @@ dnf install -yq syslinux
ln -s /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/pxelinux.0
ln -s /usr/share/syslinux/ldlinux.c32 /var/lib/tftpboot/ldlinux.c32
# TFTP kernel image and options
# TFTP kernel image and init RAM disk
dnf install -yq wget
wget -q -O /var/lib/tftpboot/coreos_production_pxe.vmlinuz http://stable.release.core-os.net/amd64-usr/current/coreos_production_pxe.vmlinuz
wget -q -O /var/lib/tftpboot/coreos_production_pxe_image.cpio.gz http://stable.release.core-os.net/amd64-usr/current/coreos_production_pxe_image.cpio.gz
@@ -63,7 +63,7 @@ systemctl start dnsmasq
# static cloud-config HTTP server
dnf install -yq httpd
cat << EOF > "/var/www/html/pxe-cloud-config.yml"
cat << EOF > "/var/www/html/cloud-config.yml"
#cloud-config
coreos:
units: