Ansible Amazon Linuxかどうか判定するサンプル

環境
Serverspec
Ansible

操作方法
1.spec_helper.rbの定義

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
def os_platform_amazon?
Specinfra.backend.run_command('uname -r').stdout.include?("amzn1")
end
def os_platform_amazon? Specinfra.backend.run_command('uname -r').stdout.include?("amzn1") end
def os_platform_amazon?
  Specinfra.backend.run_command('uname -r').stdout.include?("amzn1")
end

2.Amazon Linuxかどうか判定するコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
require 'spec_helper'
if os_platform_amazon?
%w{aws-cli s3cmd}.each do |pkg|
describe package(pkg) do
it { should be_installed }
end
end
end
require 'spec_helper' if os_platform_amazon? %w{aws-cli s3cmd}.each do |pkg| describe package(pkg) do it { should be_installed } end end end
require 'spec_helper'

if os_platform_amazon?
  %w{aws-cli s3cmd}.each do |pkg|
    describe package(pkg) do
      it { should be_installed }
    end
  end
end

 

Ansible

Posted by arkgame