butterknife使用linux容器(lxc)和btrfs文件系统使裸机linux部署变得非常简单。
butterknife的Python项目详细描述
简介
butterknife命令行实用程序可用于通过http提供快照; 通过ssh和多播发送和接收快照; 列出本地和远程快照。
安装
安装依赖项:
sudo apt-get install lxc python3-dev cython3 python3-pip pigz btrfs-progs
sudo apt-get install python3-lxc # Ubuntu 14.04 or older
sudo pip3 install jinja2 click falcon
安装蝶形刀:
sudo pip3 install butterknife
列表模板
在/var/lib/butterknife/pool上列出本地模板:
butterknife list
列出特定目录中的本地模板:
butterknife list file:///path/to/directory
通过ssh在远程机器上的/var/lib/butterknife/pool中列出模板:
butterknife list ssh://hostname
通过http:
在远程计算机上列出模板butterknife list http[s]://hostname[:port]
推/拉模板
当前切换ssh正在工作。复制后 /var/lib/butterknife/pool从机器hostname到本地池 at/var/lib/butterknife/池:
butterknife pull ssh://hostname
您也可以通过http:
butterknife pull http://butterknife.koodur.com
请注意,对称推/拉需要修补的btrfs prog,该prog具有btrfs receive的附加-p和-c标志。
多播
通过多播发送本地模板:
butterknife multicast send @template\:com.koodur.butterknife.Ubuntu\:x86_64\:snap7
您甚至可以多播远程子卷:
butterknife multicast send @template\:com.koodur.butterknife.Ubuntu\:x86_64\:snap7 --pool ssh://hostname
在/var/lib/butterknife/pool接收到本地池:
butterknife multicast receive
systemd nspawn工作流
在/var/lib/machines下为butterknife图像创建一个btrfs子卷。 用您要使用的映像名替换archlinux。
sudo btrfs subvolume create /var/lib/machines/ArchLinux
在其中安装基本系统
sudo pacstrap -i -c -d /var/lib/machines/ArchLinux base
插入并自定义容器
sudo systemd-nspawn -M ArchLinux
# do your thing
您还需要一些脚本,这些脚本将在创建快照时运行,以及 使用配置映像执行部署。
在puppet-butterknife存储库中查找应该添加的脚本和文件
在中创建butterknife配置文件 /var/lib/machines/archlinux/etc/butterknife/butterknife.conf
[template]name=ArchLinux
还要确保你的主人身上有这样的东西 etc/butterknife/butterknife.conf配置文件
[global]namespace=org.example.butterknifeendpoint=https://butterknife.example.org
为您的图像拍摄快照
butterknife nspawn release ArchLinux
现在你应该准备好为你的客户提供这种形象