github:eã§ç®¡çãã¦ããChefã®ã¯ãã¯ããã¯ããBerkshelf APIãµã¼ãã¼ãç«ã¦ã¦ããæãã«ä¾å解決ããæ¹æ³
ã¡ãã£ã¨åã«ãªãªã¼ã¹ããã Berkshelf 3ãããBerkshelf APIã¨ããã¤ã³ããã¯ã¹ãµã¼ãã¼ããã¯ãã¯ããã¯ã®æ å ±ãå¾ãããã«ãªãã¾ããã
- https://github.com/berkshelf/berkshelf/wiki/2.x-to-3.0-Upgrade-Guide
- https://github.com/berkshelf/berkshelf-api
Berkshelf APIã使ãã¨ãå¤é¨ã«å ¬éãã¦ããªãã¯ãã¯ããã¯ãBerksfileã§æå®ããéã®è¨è¿°ãç°¡æ½ã«ãªãã¾ãã
ã¾ã æ¥ãæµ ãããããBerkshelf API ï¼ github:e ã®æ å ±ãå°ãªãã®ã§ãåå¿é²ãå ¼ãã¦æ®ãã¦ããã¾ãã
ç°å¢ã¯ä»¥ä¸ã®ã¨ããã§ãã
- berkshelf (3.1.3)
- berkshelf-api (2.0.0)
Berkshelf APIãå¿ è¦ãªçç±
Berksfile ã§ cookbook ãã¼ã¯ã¼ãã« git: ãæ·»ãããã¨ã§ãgithub:e ããã¯ãã¯ããã¯ãæã£ã¦ãããã¨ãã§ãã¾ãã
source 'https://api.berkshelf.com' cookbook 'oreno-apache', git: '[email protected]:cookbooks/oreno-apache.git'
ãã¦ãã¯ãã¯ãã㯠oreno-apache ã oreno-iptables ã«ä¾åãã¦ããï¼oreno-apache/metadata.rbã§ depends 'oreno-iptables' ãã¦ããï¼ã¨ãã¾ãã
ãã®ç¶æ ã§ berks ãå®è¡ããã¨ãoreno-iptables ãè¦ã¤ããããªãã¦ã¨ã©ã¼ã«ãªãã¾ãã
$ berks vendor ./cookbooks Resolving cookbook dependencies... Fetching 'oreno-apache' from [email protected]:cookbooks/oreno-apache.git (at master) Fetching cookbook index from https://api.berkshelf.com... Unable to satisfy constraints on package oreno-iptables, which does not exist, due to solution constraint (oreno-apache = 0.1.0). Solution constraints that may result in a constraint on oreno-iptables: [(oreno-apache = 0.1.0) -> (oreno-iptables >= 0.0.0)] Missing artifacts: oreno-iptables Demand that cannot be met: (oreno-apache = 0.1.0) Unable to find a solution for demands: oreno-apache (0.1.0)
åå ã¯ãå é¨ã® github:e ã«ãããªã oreno-iptables ã®æ å ±ãBerkshelf API (https://api.berkshelf.com) ããå¾ãã¤ã³ããã¯ã¹æ å ±ããæ¢ããã¨ãã¦ãå½ç¶ããã«ã¯æ å ±ããªãããã§ãã
ãªã®ã§ã以ä¸ã®ããã«Berksfileã« oreno-iptables ã®æ å ±ãæ¸ãã°ããã¾ãããã¾ãã
source 'https://api.berkshelf.com' cookbook 'oreno-apache', git: '[email protected]:cookbooks/oreno-apache.git' cookbook 'oreno-iptables, git: '[email protected]:cookbooks/oreno-iptables.git'
ãããããã§ã¯ä½¿ãããã¯ãã¯ããã¯ãä¾åãã¦ããã¯ãã¯ããã¯ã¾ã§ãã¡ãã¡æèãã¦ãããã¬ãã«ã®Berksfileã«æ¸ããªãã¨ããã¾ãããã²ã¨ã¤ããµãã¤ãªãã¾ã ããã§ãããå¢ãã¦ããã¨é¢åãã®ãããªãã§ãããã
ããã§å é¨ã®ã¯ãã¯ããã¯ã®æ å ±ãè¿ãBerkshelf APIãç«ã¦ããã¨ã§ããã®ãããªBerksfileãæ¸ãã°ããããã«ãªãã¾ãã
source 'http://berks-api.oreno:26200' source 'https://api.berkshelf.com' cookbook 'oreno-apache'
ç°¡æ½ã§ãããï¼
æåã®sourceãåç §ãã¦ã¯ãã¯ããã¯ãè¦ã¤ãããªãã£ãå ´åã¯ã次ã®sourceãåç §ããã®ã§ãããã§å é¨ã¯ãã¯ããã¯ã¨ã³ãã¥ããã£ã¯ãã¯ããã¯ã®ä¸¡æ¹ã®æ å ±ãåå¾ã§ããããã«ãªãããã§ãã
github:e ã®æ§æ
Berkshelf APIãµã¼ãã¼ããåç §ããå ´åãgithub:e ä¸ã®ã¯ãã¯ããã¯ã®ç®¡çã¯ä»¥ä¸ã®ãããªæ§æã«ãªã£ã¦ããå¿ è¦ãããã¾ãã
- organizationã®ä¸ã«ã¯ãã¯ããã¯ã®ã¬ãã¸ããªãç½®ã
- ã¦ã¼ã¶ã¼ã®ä¸ã§ã¯ãã¡ã§ã (å°ãªãã¨ã berkshelf-api 2.0ã®å®è£ ã§ã¯)
- ã¯ãã¯ããã¯ä»¥å¤ã®ã¬ãã¸ããªããã£ã¦ãç¡è¦ããã¾ãããã¯ãã¯ããã¯å°ç¨ã®organizationãç¨æããæ¹ãããã§ããã
- metadata.rbã®versionãgit tagãã
- ãversion '1.2.3'ããªããv1.2.3ãã¨ããã¿ã°ãã¤ããå¿ è¦ãããã¾ã
- ã¿ã°ãã¤ãã¦ããªãã¨ã¯ãã¯ããã¯ã¨èªèãããªãã¦ãããã¾ã
metadata.rb ã®æ¸ãæ¹
Berkshelf APIãµã¼ãã¼ã¯ãgithub:e ããå½è©²ã¯ãã¯ããã¯ã® metadata.rb ã®ãå 容ããå¾ã¦ãããããã£ã¦ instance_eval ã§è©ä¾¡ãã¾ãã
ãããã£ã¦ãmetadata.rb ã«å¤é¨ãã¡ã¤ã«ãåç §ãããããªã³ã¼ããæ¸ãã¦ããã¨ãä¾å¤ãçºçãã¦ã¹ãããããã¯ãã¯ããã¯ã¨ã¿ãªãããªããªã£ã¦ãã¾ãã¾ãã
ä¾ãã° knife cookbook create ã§ä½ã£ãã¯ãã¯ããã¯ã® metadata.rb ã«ã¯ã
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
ã¨æ¸ããã¦ããã®ã§ä¿®æ£ããå¿ è¦ããã¾ãã(berks cookbookã§ä½ã£ããã®ã¯å¤§ä¸å¤«ã§ã)
èªå㯠../recipes/*.rb ãéãã¦ãinclude_recipeããã¦ããã¯ãã¯ããã¯ãå ¨é¨ depends ããRubyã³ã¼ããæ¸ãã¦ããã®ã§ãããã¾ããã
Berkshelf APIãµã¼ãã¼ãä¸ãã
berkshelf-api ã®ã¤ã³ã¹ãã¼ã«æ¹æ³ã¯ https://github.com/berkshelf/berkshelf-api ãåç §ãã¦ãã ããã
github:e ã«ããã¯ãã¯ããã¯ã®æ å ±ãè¿ãããã«ã次ã®ãããªè¨å®ãã¡ã¤ã«ãä½ã£ã¦ã
{
"endpoints": [
{
"type": "github",
"options": {
"organization": "cookbooks",
"access_token": "YOUR_ACCESS_TOKEN",
"api_endpoint": "https://github.oreno/api/v3",
"web_endpoint": "https://github.oreno",
"ssl_verify": true
}
}
]
}èµ·åãã¾ãã
berks-api -c /path/to/config.json
ãã¾ãããã°ã26200çªãã¼ãã® /universe ã«ã¢ã¯ã»ã¹ããã°ã¯ãã¯ããã¯ã®æ å ±ãè¿ã£ã¦ãã¾ãã
$ curl http://127.0.0.1:26200/universe | jq .
{
"oreno-apache": {
"0.1.2": {
"location_path": "https://github.oreno/cookbooks/oreno-apache",
"location_type": "github",
"dependencies": {
"oreno-iptables": ">= 0.0.0"
},
...berks-api ã¯ããªãçãå¨æã§ github:e ã«ã¢ã¯ã»ã¹ãã¦ããããã§ãpush ãããæ å ±ã¯ã»ã¼ããã«åæ ãããããã§ãã
berks ã®è¨å®ããã
ããã§é©å㪠URL ããã¯ãã¯ããã¯ããã¦ã³ãã¼ãã§ããæ å ±ã¯æã£ãã®ã§ãããgithub:e ããå®éã«ãã¦ã³ãã¼ãããã«ã¯ berks ã®è¨å®ãå¿ è¦ã§ãã
~/.berkshelf/config.json ã«æ¬¡ã®ããã«æ¸ãã¾ãã
{
"github": [
{
"access_token": "YOUR_ACCESS_TOKEN",
"api_endpoint": "https://github.oreno/api/v3",
"web_endpoint": "https://github.oreno",
"ssl_verify": true
}
]
}ããã§ berks vendor ã§èªå®¶è£½ã¨ã³ãã¥ããã£ã®ä¸¡æ¹ã®ã¯ãã¯ããã¯ãåå¾ã§ããããã«ãªã£ãã¯ãã§ãï¼