- Chef 教程
- Chef - 首页
- Chef - 概述
- Chef - 架构
- Chef - 版本控制系统设置
- Chef - 工作站设置
- Chef - 客户端设置
- Chef - Test Kitchen 设置
- Chef - 刀具设置
- Chef - Solo 设置
- Chef - Cookbook
- Chef - Cookbook 依赖
- Chef - 角色
- Chef - 环境
- Chef - Chef-Client 作为守护进程
- Chef - Chef-Shell
- Chef - 测试 Cookbook
- Chef - Foodcritic
- Chef - ChefSpec
- 使用 Test Kitchen 测试 Cookbook
- Chef - 节点
- Chef - Chef-Client 运行
- 高级 Chef
- 动态配置菜谱
- Chef - 模板
- Chef - 使用 Chef DSL 的纯 Ruby
- Chef - 使用菜谱的 Ruby Gems
- Chef - 库
- Chef - 定义
- Chef - 环境变量
- Chef - 数据包
- Chef - 数据包脚本
- Chef - 跨平台 Cookbook
- Chef - 资源
- 轻量级资源提供程序
- Chef - 蓝图
- Chef - 文件和包
- Chef - 社区 Cookbook
- Chef 有用资源
- Chef - 快速指南
- Chef - 有用资源
- Chef - 讨论
Chef - 刀具设置
Knife 是 Chef 的命令行工具,用于与 Chef 服务器交互。它用于上传 Cookbook 和管理 Chef 的其他方面。它在本地机器上的 chefDK(Repo)和 Chef 服务器之间提供了一个接口。它有助于管理:
- Chef 节点
- Cookbook
- 菜谱
- 环境
- 云资源
- 云配置
- 在 Chef 节点上安装 Chef 客户端
Knife 提供了一组命令来管理 Chef 基础设施。
引导命令
- knife bootstrap [SSH_USER@]FQDN (options)
客户端命令
- knife client bulk delete REGEX (options)
- knife client create CLIENTNAME (options)
- knife client delete CLIENT (options)
- knife client edit CLIENT (options)
- 用法:C:/opscode/chef/bin/knife (options)
- knife client key delete CLIENT KEYNAME (options)
- knife client key edit CLIENT KEYNAME (options)
- knife client key list CLIENT (options)
- knife client key show CLIENT KEYNAME (options)
- knife client list (options)
- knife client reregister CLIENT (options)
- knife client show CLIENT (options)
配置命令
- knife configure (options)
- knife configure client DIRECTORY
Cookbook 命令
- knife cookbook bulk delete REGEX (options)
- knife cookbook create COOKBOOK (options)
- knife cookbook delete COOKBOOK VERSION (options)
- knife cookbook download COOKBOOK [VERSION] (options)
- knife cookbook list (options)
- knife cookbook metadata COOKBOOK (options)
- knife cookbook metadata from FILE (options)
- knife cookbook show COOKBOOK [VERSION] [PART] [FILENAME] (options)
- knife cookbook test [COOKBOOKS...] (options)
- knife cookbook upload [COOKBOOKS...] (options)
Cookbook 站点命令
- knife cookbook site download COOKBOOK [VERSION] (options)
- knife cookbook site install COOKBOOK [VERSION] (options)
- knife cookbook site list (options)
- knife cookbook site search QUERY (options)
- knife cookbook site share COOKBOOK [CATEGORY] (options)
- knife cookbook site show COOKBOOK [VERSION] (options)
- knife cookbook site unshare COOKBOOK
数据包命令
- knife data bag create BAG [ITEM] (options)
- knife data bag delete BAG [ITEM] (options)
- knife data bag edit BAG ITEM (options)
- knife data bag from file BAG FILE|FOLDER [FILE|FOLDER..] (options)
- knife data bag list (options)
- knife data bag show BAG [ITEM] (options)
环境命令
- knife environment compare [ENVIRONMENT..] (options)
- knife environment create ENVIRONMENT (options)
- knife environment delete ENVIRONMENT (options)
- knife environment edit ENVIRONMENT (options)
- knife environment from file FILE [FILE..] (options)
- knife environment list (options)
- knife environment show ENVIRONMENT (options)
执行命令
- knife exec [SCRIPT] (options)
帮助命令
- knife help [list|TOPIC]
索引命令
- knife index rebuild (options)
节点命令
- knife node bulk delete REGEX (options)
- knife node create NODE (options)
- knife node delete NODE (options)
- knife node edit NODE (options)
- knife node environment set NODE ENVIRONMENT
- knife node from file FILE (options)
- knife node list (options)
- knife node run_list add [NODE] [ENTRY[,ENTRY]] (options)
- knife node run_list remove [NODE] [ENTRY[,ENTRY]] (options)
- knife node run_list set NODE ENTRIES (options)
- knife node show NODE (options)
OSC 命令
- knife osc_user create USER (options)
- knife osc_user delete USER (options)
- knife osc_user edit USER (options)
- knife osc_user list (options)
- knife osc_user reregister USER (options)
- knife osc_user show USER (options)
基于路径的命令
- knife delete [PATTERN1 ... PATTERNn]
- knife deps PATTERN1 [PATTERNn]
- knife diff PATTERNS
- knife download PATTERNS
- knife edit [PATTERN1 ... PATTERNn]
- knife list [-dfR1p] [PATTERN1 ... PATTERNn]
- knife show [PATTERN1 ... PATTERNn]
- knife upload PATTERNS
- knife xargs [COMMAND]
原始命令
- knife raw REQUEST_PATH
菜谱命令
- knife recipe list [PATTERN]
角色命令
- knife role bulk delete REGEX (options)
- knife role create ROLE (options)
- knife role delete ROLE (options)
- knife role edit ROLE (options)
- knife role env_run_list add [ROLE] [ENVIRONMENT] [ENTRY[,ENTRY]] (options)
- knife role env_run_list clear [ROLE] [ENVIRONMENT]
- knife role env_run_list remove [ROLE] [ENVIRONMENT] [ENTRIES]
- knife role env_run_list replace [ROLE] [ENVIRONMENT] [OLD_ENTRY] [NEW_ENTRY]
- knife role env_run_list set [ROLE] [ENVIRONMENT] [ENTRIES]
- knife role from file FILE [FILE..] (options)
- knife role list (options)
- knife role run_list add [ROLE] [ENTRY[,ENTRY]] (options)
- knife role run_list clear [ROLE]
- knife role run_list remove [ROLE] [ENTRY]
- knife role run_list replace [ROLE] [OLD_ENTRY] [NEW_ENTRY]
- knife role run_list set [ROLE] [ENTRIES]
- knife role show ROLE (options)
服务命令
- knife serve (options)
SSH 命令
- knife ssh QUERY COMMAND (options)
SSL 命令
- knife ssl check [URL] (options)
- knife ssl fetch [URL] (options)
状态命令
- knife status QUERY (options)
标签命令
- knife tag create NODE TAG ...
- knife tag delete NODE TAG ...
- knife tag list NODE
用户命令
- knife user create USERNAME DISPLAY_NAME FIRST_NAME LAST_NAME EMAIL PASSWORD (options)
- knife user delete USER (options)
- knife user edit USER (options)
- knife user key create USER (options)
- knife user key delete USER KEYNAME (options)
- knife user key edit USER KEYNAME (options)
- knife user key list USER (options)
- knife user key show USER KEYNAME (options)
- knife user list (options)
- knife user reregister USER (options)
- knife user show USER (options)
Knife 设置
为了设置 knife,需要移动到.chef目录并在 chef repo 内创建一个knife.rb文件,该文件告诉 knife 配置细节。这将包含一些详细信息。
current_dir = File.dirname(__FILE__) log_level :info log_location STDOUT node_name 'node_name' client_key "#{current_dir}/USER.pem" validation_client_name 'ORG_NAME-validator' validation_key "#{current_dir}/ORGANIZATION-validator.pem" chef_server_url 'https://api.chef.io/organizations/ORG_NAME' cache_type 'BasicFile' cache_options( :path => "#{ENV['HOME']}/.chef/checksums" ) cookbook_path ["#{current_dir}/../cookbooks"]
在上面的代码中,我们使用了使用以下两个密钥的托管 Chef 服务器。
validation_client_name 'ORG_NAME-validator' validation_key "#{current_dir}/ORGANIZATION-validator.pem"
这里,knife.rb 告诉 knife 使用哪个组织以及在哪里找到私钥。它告诉 knife 在哪里找到用户的私钥。
client_key "#{current_dir}/USER.pem"
下面的代码行告诉 knife 我们正在使用托管服务器。
chef_server_url 'https://api.chef.io/organizations/ORG_NAME'
使用 knife.rb 文件,验证器 knife 现在可以连接到您的组织的托管 Opscode。
广告