RHEL8 Serverspecのインストールのサンプル
環境
RHEL8.6
操作方法
1.Serverspecのインストールを行う
gem install serverspec
2.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: 1
Vagrant instance y/n: n
Input target host name: {HOSTNAME}
+ spec/
+ spec/{HOSTNAME}/
+ spec/{HOSTNAME}/sample_spec.rb
+ spec/spec_helper.rb
3.SSHで接続してテストを実行する
% ssh-copy-id ${HOSTNAME}
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed — if you are prompted now it is to install the new keys
root@${HOSTNAME}’s password: ※パスワードを入力
4.ディレクトリ構成
spec/
spec/{HOSTNAME}/
spec/{HOSTNAME}/sample_spec.rb
spec/spec_helper.rb
5.Serverspecテストを実行する
rake spec