设为首页 收藏本站
查看: 1197|回复: 0

[经验分享] 配置salt+vagrant

[复制链接]

尚未签到

发表于 2015-11-26 11:41:47 | 显示全部楼层 |阅读模式

Salty Vagrant



Provision Vagrant boxes using Saltstack.


Help and discussion can be found at #salt on Freenode IRC (just ping akoumjian)
or the salt-users mailing list.



Warning



DEPRECATED: Vagrant includes a salt provisioner for versions 1.3.0 and above



Introduction



Salty Vagrant is a plugin for Vagrant which lets you use salt as a provisioning tool. You can use your existing
salt formulas and configs to build up development environments.


The simplest way to use Salty Vagrant is by configuring it for masterless mode. With this setup, you use a standalone
minion along with your file_roots and/or pillar_roots. See the examples/ folder for more details.



Masterless
(Quick Start)



  • Install Vagrant
  • Install Salty Vagrant (vagrant
    plugin install vagrant-salt)
  • Get the Ubuntu 12.04 base box: vagrant box add precise64http://files.vagrantup.com/precise64.box
  • Create/Update your Vagrantfile (Detailed in Configuration) [2]
  • Place your minion config in salt/minion [1]
  • Run vagrant up and you should be good to go.

[1]
Make sure your minion config sets file_client: local for masterless

[2]
Don't forget to create a shared folder for your salt file root

Configuration



Here is an extremely simple Vagrantfile, to be used with the above masterless setup:


Vagrant.configure("2") do |config|
## Choose your base box
config.vm.box = "precise64"
## For masterless, mount your salt file root
config.vm.synced_folder "salt/roots/", "/srv/salt/"
## Use all the defaults:
config.vm.provision :salt do |salt|
salt.minion_config = "salt/minion"
salt.run_highstate = true
end
end


Actions




run_highstate (true/false)Executes state.highstate on vagrant up
accept_keys (true/false)Accept all keys if running a master. DEPRECATED: use seed_master

Install
Options




install_master (true/false)Install the salt-master
no_minion (true/false)Don't install the minion
install_syndic (true/false)Install the salt-syndic
install_type (stable | git | daily)Whether to install from a distribution's stable package manager, a daily ppa, or git treeish.
install_args (develop)When performing a git install, you can specify a branch, tag, or any treeish.
always_install (true/false)Installs salt binaries even if they are already detected

Minion
Options




minion_config (salt/minion)Path to a custom salt minion config file.
minion_key (salt/key/minion.pem)Path to your minion key
minion_pub (salt/key/minion.pub)Path to your minion public key

Master
Options




master_config (salt/minion)Path to a custom salt master config file
master_key (salt/key/master.pem)Path to your master key
master_pub (salt/key/master.pub)Path to your master public key
seed_master {minion_name:/path/to/key.pub}Upload keys to master, thereby pre-seeding it before use.

Other




bootstrap_script (salt/bootstrap_salt.sh)Path to a custom bootstrap script
temp_config_dir (/tmp)Path on the guest box that config and bootstrap files will be copied to before placing in the salt directories
pillar_dataGet pillar data that has been set (this is read only because data should be set using the pillarcommand
referenced below)
verbose (true/false)Prints bootstrap script output to screen

Installation
Notes



Supported
Operating Systems



  • Ubuntu 10.x/11.x/12.x
  • Debian 6.x/7.x
  • CentOS 6.3
  • Fedora
  • Arch
  • FreeBSD 9.0


Installing
from source



  • git clone https://github.com/saltstack/salty-vagrant.git
  • cd salty-vagrant
  • git submodule init
  • git submodule update
  • gem install rubygems-bundler
  • gem build vagrant-salt.gemspec
  • vagrant plugin install vagrant-salt-[version].gem


If you'd like to include the latest stable revision of the salt-bootstrap script, run the following after step 5:



  • cd scripts
  • git pull origin stable
  • Rebuild the gem if you had built it previously.


Miscellaneous



Pillar
Data



You can export pillar data for use during provisioning by using the pillar command. Each call will merge the data so you can safely
call it multiple times. The data passed in should only be hashes and lists. Here is an example:


config.vm.provision :salt do |salt|
# Export hostnames for webserver config
salt.pillar({
"hostnames" => {
"www" => "www.example.com",
"intranet" => "intranet.example.com"
}
})
# Export database credentials
salt.pillar({
"database" => {
"user" => "jdoe",
"password" => "topsecret"
}
})
salt.run_highstate = true
end


Using
Remote Salt Master



If you are already using Salt for deployment, you can use your existing master to provision your vagrant boxes as well. You will
need to do one of the following:



  • Manually accept the vagrant's minion key after it boots. [3]
  • Preseed the Vagrant box with minion keys pre-generated on the master

[3]
This is not recommended. If your developers need to destroy and rebuild their VM, you will have to repeat the process.

Preseeding
Vagrant Minion Keys



On the master, create the keypair and add the public key to the accepted minions folder:


root@saltmaster# salt-key --gen-keys=[minion_id]
root@saltmaster# cp [minion_id].pub /etc/salt/pki/master/minions/[minion_id]


Replace [minion_id] with the id you would like to assign the minion.


Next you want to bundle the key pair along with your Vagrantfile, the salt_provisioner.rb, and your minion config. The directory should look something like this:


myvagrant/
Vagrantfile
salt/
minion.conf
key/
minion.pem
minion.pub


You will need to determine your own secure method of transferring this package. Leaking the minion's private key poses a security risk to your salt network.


The are two required settings for your minion.conf file:


master: [master_fqdn]
id: [minion_id]


Make sure you use the same [minion_id] that you used on the master or it will not match with the key.


Create/Update your Vagrantfile per the example provided in the Configuration section.


Finally, you should be able to run vagrant up and the salt should put your vagrant minion in state.highstate.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-143853-1-1.html 上篇帖子: 运维常用软件 下篇帖子: lamp review (add)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表