RHEL9 ServerSpecをインストールする手順
環境
Red Hat Enterprise Linux release 9.2 (Plow)
操作方法
1.rubyのインストール
# dnf install ruby
略 インストール済み: ruby-3.0.4-160.el9_0.x86_64 ruby-default-gems-3.0.4-160.el9_0.noarch ruby-libs-3.0.4-160.el9_0.x86_64 rubygem-bigdecimal-3.0.0-160.el9_0.x86_64 rubygem-bundler-2.2.33-160.el9_0.noarch rubygem-io-console-0.5.7-160.el9_0.x86_64 rubygem-json-2.5.1-160.el9_0.x86_64 rubygem-psych-3.3.2-160.el9_0.x86_64 rubygem-rdoc-6.3.3-160.el9_0.noarch rubygems-3.2.33-160.el9_0.noarch 完了しました!
2.rakeのインストール
$gem install rake
Fetching rake-13.1.0.gem Successfully installed rake-13.1.0 Parsing documentation for rake-13.1.0 Installing ri documentation for rake-13.1.0 Done installing documentation for rake after 0 seconds 1 gem installed
3. serverspecのインストール
$ gem install serverspec
4.ruby-develのインストール
# dnf install ruby-devel
5.初期設定を行う
$cd / $mkdir serverspec $cd serverspec $ serverspec $serverspec-init Select OS type: 1) UN*X 2) Windows Select number: 1 Select a backend type: 1) SSH 2) Exec (local) Select number: 2 + spec/ + spec/localhost/ + spec/localhost/sample_spec.rb + spec/spec_helper.rb + Rakefile + .rspec
6.テスト用rbの用意
spec/localhost
$cat sample_spec.rb
require 'spec_helper' describe package('glibc-langpack-ja') do it { should be_installed } end
実行結果
$rake spec (in /serverspec) /usr/bin/ruby -I/usr/local/share/gems/gems/rspec-support-3.12.1/lib:/usr/local/share/gems/gems/rspec-core-3.12.2/lib /usr/local/share/gems/gems/rspec-core-3.12.2/exe/rspec --pattern spec/localhost/\*_spec.rb Package "glibc-langpack-ja" is expected to be installed Finished in 0.10014 seconds (files took 0.40943 seconds to load) 1 example, 0 failures