前邊有轉發過來自chef 團隊的一篇omnibus-ctl
介紹文章,如下嘗試進行項目試用html
就是簡單的集成,沒有多少複雜的操做linux
2.6.3
使用 rbenv
安裝,能夠參考rbenv mac&&linux 安裝簡單說明gem install bundler
gem source -r https://rubygems.org/
gem source -a https://gems.ruby-china.com/
腳手架模式git
gem install omnibus
項目是一個簡單的模擬gitlab 的軟件包,沒有多少操做github
omnibus new gitlab
├── Berksfile
├── Gemfile
├── Gemfile.lock
├── README.md
├── config
│ ├── projects
│ │ └── gitlab.rb
│ └── software
│ ├── gitlab-ctl.rb
│ └── preparation.rb
├── files
│ └── gitlab-ctl-commands
│ └── config.rb
├── omnibus.rb
└── package-scripts
└── gitlab
├── postinst
├── postrm
├── preinst
└── prerm
config/software/gitlab-ctl.rb
,files/gitlab-ctl-commands
是添加的文件Gemfile
由於須要集成omnibus-ctl
因此須要引用gem 包,我修改了source 爲國內的source 'https://gems.ruby-china.com/'
# Install omnibus
gem 'omnibus', '~> 6.0'
# gem 'omnibus-ctl', '~> 0.6.0'
gem 'omnibus-software', git: 'https://github.com/chef/omnibus-software.git'
# Use Chef's software definitions. It is recommended that you write your own
# software definitions, but you can clone/fork Chef's to get you started.
# gem 'omnibus-software', github: 'chef/omnibus-software'
# This development group is installed by default when you run `bundle install`,
# but if you are using Omnibus in a CI-based infrastructure, you do not need
# the Test Kitchen-based build lab. You can skip these unnecessary dependencies
# by running `bundle install --without development` to speed up build times.
group :development do
# Use Berkshelf for resolving cookbook dependencies
gem 'berkshelf'
# Use Test Kitchen with Vagrant for converging the build environment
gem 'test-kitchen'
gem 'kitchen-vagrant'
end
config/project/gitlab.rb
項目包信息描述,包含依賴以及項目信息json
#
# Copyright 2019 YOUR NAME
#
# All Rights Reserved.
#
name "gitlab"
maintainer "rongfengliang"
homepage "https://github.com/rongfengliang"
# Defaults to C:/my on Windows
# and /opt/my on all other platforms
install_dir "#{default_root}/#{name}"
build_version Omnibus::BuildVersion.semver
build_iteration 1
# Creates required build directories
dependency "preparation"
dependency "gitlab-ctl" # 咱們須要依賴的soft 定義
# my dependencies/components
# dependency "somedep"
exclude "**/.git"
exclude "**/bundler/git"
config/software/gitlab-ctl.rb
咱們的包軟件定義:
這個實際上就是對omnibus-ctl
的一個包裝ruby
name "gitlab-ctl"
dependency "omnibus-ctl"
source :path => File.expand_path("files/gitlab-ctl-commands", RbConfig::CONFIG['project_root'])
build do
block do
open("#{install_dir}/embedded/bin/gitlab-ctl", "w") do |file|
file.print <<-EOH
#!/bin/bash
# Ruby environment if gitlab-ctl is called from a Ruby script.
for ruby_env_var in RUBYOPT \\
BUNDLE_BIN_PATH \\
BUNDLE_GEMFILE \\
GEM_PATH \\
GEM_HOME
do
unset $ruby_env_var
done
#{install_dir}/embedded/bin/omnibus-ctl gitlab #{install_dir}/embedded/service/omnibus-ctl $@
EOH
end
end
command "chmod 755 #{install_dir}/embedded/bin/gitlab-ctl"
# additional omnibus-ctl commands
sync "#{project_dir}/", "#{install_dir}/embedded/service/omnibus-ctl/"
end
files/gitlab-ctl-commands
自定義命令:bash
add_command 'config', 'reconfig for gitlab server', 1 do |cmd_name|
puts 'run config'
reconfigure
end
bundle install --binstubs
sudo bin/omnibus build gitlab
tree pkg/
pkg/
├── gitlab-0.0.0+20190701053352-1.el7.x86_64.rpm
├── gitlab-0.0.0+20190701053352-1.el7.x86_64.rpm.metadata.json
├── gitlab-0.0.0+20190701062746-1.el7.x86_64.rpm
├── gitlab-0.0.0+20190701062746-1.el7.x86_64.rpm.metadata.json
└── version-manifest.json
yum install gitlab-0.0.0+20190701062746-1.el7.x86_64.rpm
已加載插件:fastestmirror
正在檢查 gitlab-0.0.0+20190701062746-1.el7.x86_64.rpm: gitlab-0.0.0+20190701062746-1.el7.x86_64
gitlab-0.0.0+20190701062746-1.el7.x86_64.rpm 將被安裝
正在解決依賴關係
--> 正在檢查事務
---> 軟件包 gitlab.x86_64.0.0.0.0+20190701062746-1.el7 將被 安裝
--> 解決依賴關係完成
依賴關係解決
===============================================================================================================
Package 架構 版本 源 大小
===============================================================================================================
正在安裝:
gitlab x86_64 0.0.0+20190701062746-1.el7 /gitlab-0.0.0+20190701062746-1.el7.x86_64 46 M
事務概要
========================================
tree -L 3 /opt/gitlab/
/opt/gitlab/
├── bin
├── embedded
│ ├── bin
│ │ ├── bundle
│ │ ├── bundler
│ │ ├── c_rehash
│ │ ├── erb
│ │ ├── gem
│ │ ├── gitlab-ctl
│ │ ├── irb
│ │ ├── libtool
│ │ ├── libtoolize
│ │ ├── makedepend
│ │ ├── omnibus-ctl
│ │ ├── openssl
│ │ ├── pkg-config
│ │ ├── rake
│ │ ├── rdoc
│ │ ├── ri
│ │ ├── ruby
│ │ └── update_rubygems
│ ├── include
│ │ ├── ffi.h
│ │ ├── ffitarget.h
│ │ ├── libltdl
│ │ ├── ltdl.h
│ │ ├── openssl
│ │ ├── ruby-2.6.0
│ │ ├── X11
│ │ ├── yaml.h
│ │ ├── zconf.h
│ │ └── zlib.h
│ ├── lib
│ │ ├── config_guess
│ │ ├── engines
│ │ ├── libcrypto.a
│ │ ├── libcrypto.so -> libcrypto.so.1.0.0
│ │ ├── libcrypto.so.1.0.0
│ │ ├── libffi-3.2.1
│ │ ├── libffi.a
│ │ ├── libffi.la
│ │ ├── libffi.so -> libffi.so.6.0.4
│ │ ├── libffi.so.6 -> libffi.so.6.0.4
│ │ ├── libffi.so.6.0.4
│ │ ├── libltdl.a
│ │ ├── libltdl.la
│ │ ├── libltdl.so -> libltdl.so.7.3.0
│ │ ├── libltdl.so.7 -> libltdl.so.7.3.0
│ │ ├── libltdl.so.7.3.0
│ │ ├── libruby.so -> libruby.so.2.6.3
│ │ ├── libruby.so.2.6 -> libruby.so.2.6.3
│ │ ├── libruby.so.2.6.3
│ │ ├── libssl.a
│ │ ├── libssl.so -> libssl.so.1.0.0
│ │ ├── libssl.so.1.0.0
│ │ ├── libyaml-0.so.2 -> libyaml-0.so.2.0.5
│ │ ├── libyaml-0.so.2.0.5
│ │ ├── libyaml.a
│ │ ├── libyaml.la
│ │ ├── libyaml.so -> libyaml-0.so.2.0.5
│ │ ├── libz.a
│ │ ├── libz.so -> libz.so.1.2.11
│ │ ├── libz.so.1 -> libz.so.1.2.11
│ │ ├── libz.so.1.2.11
│ │ ├── pkgconfig
│ │ └── ruby
│ ├── service
│ │ └── omnibus-ctl
│ ├── share
│ │ ├── aclocal
│ │ ├── doc
│ │ ├── info
│ │ ├── libtool
│ │ ├── man
│ │ ├── pkgconfig
│ │ └── util-macros
│ └── ssl
│ ├── cert.pem -> certs/cacert.pem
│ ├── certs
│ ├── misc
│ └── openssl.cnf
├── LICENSE
├── LICENSES
│ ├── bundler-LICENSE.md
│ ├── cacerts-index.815ca599c9df.txt
│ ├── config_guess-config.guess
│ ├── config_guess-config.sub
│ ├── libffi-LICENSE
│ ├── libtool-COPYING
│ ├── libyaml-LICENSE
│ ├── makedepend-COPYING
│ ├── omnibus-ctl-LICENSE
│ ├── openssl-LICENSE
│ ├── pkg-config-lite-COPYING
│ ├── ruby-BSDL
│ ├── ruby-COPYING
│ ├── rubygems-LICENSE.txt
│ ├── ruby-LEGAL
│ ├── util-macros-COPYING
│ ├── xproto-COPYING
│ └── zlib-README
├── version-manifest.json
└── version-manifest.txt
gitlab-ctl
了export PATH=$PATH:/opt/gitlab/embedded
使用命令:架構
gitlab-ctl
I don't know that command.
/opt/gitlab/embedded/bin/omnibus-ctl: command (subcommand)
config
reconfig for gitlab server
General Commands:
cleanse
Delete *all* my data, and start from scratch.
help
Print this help message.
reconfigure
Reconfigure the application.
show-config
Show the configuration that would be generated by reconfigure.
uninstall
Kill all processes and uninstall the process supervisor (data will be preserved).
Service Management Commands:
graceful-kill
Attempt a graceful stop, then SIGKILL the entire process group.
hup
Send the services a HUP.
int
Send the services an INT.
kill
Send the services a KILL.
once
Start the services if they are down. Do not restart them if they stop.
restart
Stop the services if they are running, then start them again.
service-list
List all the services (enabled services appear with a *.)
start
Start services if they are down, and restart them if they stop.
status
Show the status of all the services.
stop
Stop the services, and do not restart them.
tail
Watch the service logs of all enabled services.
term
Send the services a TERM.
omnibus-ctl
,只是裏面功能更復雜而已。 omnibus-ctl
的用法https://github.com/gitlabhq/omnibus-gitlab
https://blog.chef.io/2015/05/26/omnibus-ctl-what-is-it-and-what-can-it-do-for-you/
https://github.com/rongfengliang/omnibus-ctl-demoapp