Vagrant-Butcher 项目使用教程

Vagrant-Butcher 项目使用教程

vagrant-butcherDelete Chef client and node when destroying Vagrant VM项目地址:https://gitcode.com/gh_mirrors/va/vagrant-butcher

1. 项目的目录结构及介绍

Vagrant-Butcher 项目的目录结构如下:

.
├── Gemfile
├── Gemfile.lock
├── LICENSE.txt
├── README.md
├── Rakefile
├── Vagrantfile
├── vagrant-butcher.gemspec
├── lib
│   └── vagrant-butcher
│       └── plugin.rb
└── spec
    └── vagrant-butcher_spec.rb

目录介绍

  • GemfileGemfile.lock:定义了项目的依赖关系。
  • LICENSE.txt:项目的许可证文件。
  • README.md:项目的基本介绍和使用说明。
  • Rakefile:用于定义项目的自动化任务。
  • Vagrantfile:Vagrant 的配置文件示例。
  • vagrant-butcher.gemspec:项目的 gem 规范文件。
  • lib/vagrant-butcher:包含项目的主要代码文件。
  • spec:包含项目的测试文件。

2. 项目的启动文件介绍

项目的启动文件位于 lib/vagrant-butcher/plugin.rb。这个文件定义了 Vagrant-Butcher 插件的主要功能和行为。

module VagrantPlugins
  module Butcher
    class Plugin < Vagrant.plugin("2")
      name "butcher"
      description <<-DESC
      This plugin will automatically delete the Chef client and node when you destroy the VM.
      DESC

      action_hook(:butcher, :machine_action_destroy) do |hook|
        hook.after(Vagrant::Action::Builtin::DestroyConfirm, Action::DeleteChefNode)
        hook.after(Vagrant::Action::Builtin::DestroyConfirm, Action::DeleteChefClient)
      end
    end
  end
end

启动文件介绍

  • name "butcher":定义插件的名称为 "butcher"。
  • description:插件的描述信息。
  • action_hook:定义在销毁虚拟机时的动作钩子,用于删除 Chef 客户端和节点。

3. 项目的配置文件介绍

项目的配置文件主要是 Vagrantfilevagrant-butcher.gemspec

Vagrantfile

Vagrantfile 是一个示例配置文件,展示了如何使用 Vagrant-Butcher 插件。

Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/bionic64"
  config.vm.provision "chef_client" do |chef|
    chef.chef_server_url = "https://api.chef.io/organizations/myorg"
    chef.validation_key_path = "validation.pem"
    chef.validation_client_name = "myorg-validator"
  end
end

vagrant-butcher.gemspec

vagrant-butcher.gemspec 是项目的 gem 规范文件,定义了项目的元数据和依赖关系。

Gem::Specification.new do |spec|
  spec.name          = "vagrant-butcher"
  spec.version       = "2.3.1"
  spec.authors       = ["Cassiano Leal"]
  spec.email         = ["cassianoleal@gmail.com"]
  spec.description   = %q{Delete Chef client and node when destroying Vagrant VM}
  spec.summary       = spec.description
  spec.homepage      = "https://github.com/c10l/vagrant-butcher"
  spec.license       = "MIT"

  spec.files         = `git ls-files`.split($/)
  spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
  spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
  spec.require_paths = ["lib"]

  spec.add_runtime_dependency "ridley", ">= 4.0.0"
  spec.add_development_dependency "bundler", ">= 1.3"
  spec.add_development_dependency "date", ">= 0"
  spec.add_development_dependency "did_you

vagrant-butcherDelete Chef client and node when destroying Vagrant VM项目地址:https://gitcode.com/gh_mirrors/va/vagrant-butcher

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

gitblog_00881

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值