Skip to content

Commit

Permalink
Merge pull request #1 from bonusbits/dev
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
LevonBecker authored Oct 28, 2017
2 parents 8a33dfc + fc1c82e commit 7c90873
Show file tree
Hide file tree
Showing 17 changed files with 275 additions and 47 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGE LOG

## 1.1.0 - 10/27/2017 - Levon Becker
* Added Backups Tests
* Added CloudWatch Tests
* Simplified configure args local variable to be named the same
* Added Gemfile.lock to keep CircleCI in-line for testing
* Added Java Install Tests

## 1.0.5 - 04/17/2017 - Levon Becker
* Switch attribute/arg for inside_aws to discovery method.

Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
source 'https://rubygems.org'

gem 'inspec', '~> 1.11'
gem 'rake', '~> 12.0.0'
gem 'inspec', '~> 1.25.0'
gem 'rake', '~> 10.4'

group :style do
gem 'rubocop', '~> 0.46.0'
gem 'rubocop', '~> 0.47.0'
end
134 changes: 134 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.4.0)
ast (2.3.0)
blankslate (2.1.2.4)
builder (3.2.3)
coderay (1.1.1)
diff-lcs (1.3)
docker-api (1.33.3)
excon (>= 0.38.0)
json
erubis (2.7.0)
excon (0.55.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.18)
gssapi (1.2.0)
ffi (>= 1.0.1)
gyoku (1.3.1)
builder (>= 2.1.2)
hashie (3.5.6)
httpclient (2.8.3)
inspec (1.25.1)
addressable (~> 2.4)
faraday (>= 0.9.0)
hashie (~> 3.4)
json (>= 1.8, < 3.0)
method_source (~> 0.8)
mixlib-log
parallel (~> 1.9)
parslet (~> 1.5)
pry (~> 0)
rainbow (~> 2)
rspec (~> 3)
rspec-its (~> 1.2)
rubyzip (~> 1.1)
semverse
sslshake (~> 1.2)
thor (~> 0.19)
toml (~> 0.1)
train (>= 0.22.0, < 1.0)
json (1.8.6)
little-plugger (1.1.4)
logging (2.2.0)
little-plugger (~> 1.1)
multi_json (~> 1.10)
method_source (0.8.2)
mixlib-log (1.7.1)
mixlib-shellout (2.3.2)
multi_json (1.12.1)
multipart-post (2.0.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (4.1.0)
nori (2.6.0)
parallel (1.11.1)
parser (2.4.0.0)
ast (~> 2.2)
parslet (1.5.0)
blankslate (~> 2.0)
powerpack (0.1.1)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rainbow (2.2.2)
rake
rake (10.5.0)
rspec (3.6.0)
rspec-core (~> 3.6.0)
rspec-expectations (~> 3.6.0)
rspec-mocks (~> 3.6.0)
rspec-core (3.6.0)
rspec-support (~> 3.6.0)
rspec-expectations (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-its (1.2.0)
rspec-core (>= 3.0.0)
rspec-expectations (>= 3.0.0)
rspec-mocks (3.6.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.6.0)
rspec-support (3.6.0)
rubocop (0.47.1)
parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
rubyntlm (0.6.1)
rubyzip (1.2.1)
semverse (2.0.0)
slop (3.6.0)
sslshake (1.2.0)
thor (0.19.1)
toml (0.1.2)
parslet (~> 1.5.0)
train (0.23.0)
docker-api (~> 1.26)
json (>= 1.8, < 3.0)
mixlib-shellout (~> 2.0)
net-scp (~> 1.2)
net-ssh (>= 2.9, < 5.0)
winrm (~> 2.0)
winrm-fs (~> 1.0)
unicode-display_width (1.3.0)
winrm (2.2.1)
builder (>= 2.1.2)
erubis (~> 2.7)
gssapi (~> 1.2)
gyoku (~> 1.0)
httpclient (~> 2.2, >= 2.2.0.2)
logging (>= 1.6.1, < 3.0)
nori (~> 2.0)
rubyntlm (~> 0.6.0, >= 0.6.1)
winrm-fs (1.0.1)
erubis (~> 2.7)
logging (>= 1.6.1, < 3.0)
rubyzip (~> 1.1)
winrm (~> 2.0)

PLATFORMS
ruby

DEPENDENCIES
inspec (~> 1.25.0)
rake (~> 10.4)
rubocop (~> 0.47.0)

BUNDLED WITH
1.12.5
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# InSpec Bonus Bits Base Cookbook Profile
[![Project Release](https://img.shields.io/badge/release-v1.1.0-blue.svg)](https://github.com/bonusbits/inspec_bonusbits_base)
[![CircleCI](https://circleci.com/gh/bonusbits/inspec_bonusbits_base.svg?style=shield)](https://circleci.com/gh/bonusbits/inspec_bonusbits_base)
[![Join the chat at https://gitter.im/bonusbits](https://badges.gitter.im/bonusbits/bonusbits.svg)](https://gitter.im/bonusbits?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![GitHub issues](https://img.shields.io/github/issues/bonusbits/inspec_bonusbits_base.svg)](https://github.com/bonusbits/inspec_bonusbits_base/issues)

Used to run integration tests for when using the [bonusbits_base](https://github.com/bonusbits/bonusbits_base) Chef Cookbook.

Expand Down Expand Up @@ -44,10 +46,16 @@ suites:
| all | debug | Boolean | false | true/false |
| aws | inside_aws | Boolean | false | true/false |
| aws | configure_aws_profile | Boolean | true | true/false |
| backups | configure_backups | Boolean | false | true/false |
| cloudwatch | configure_cloudwatch | Boolean | false | true/false |
| cloudwatch_logs | inside_aws | Boolean | false | true/false |
| cloudwatch_logs | configure_cloudwatch_logs | Boolean | true | true/false |
| epel | configure_epel | Boolean | false | true/false |
| epel | install_epel_packages | Boolean | false | true/false |
| java | install_java | Boolean | false | true/false |
| java | java_package_name | String | java-1.8.0-openjdk | N/A |
| java | specify_version | Boolean | false | true/false |
| java | java_version | String | 1.8.0.151-1.b12.35.amzn1 | N/A |
| node_info | configure_node_info | Boolean | true | true/false |
| packages | install_packages | Boolean | true | true/false |
| packages | amazon_packages | Array | long list | array of package names |
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
build:
working_directory: ~/circulate
docker:
- image: chef/chefdk:1.2.22
- image: chef/chefdk:1.6.1
steps:
- checkout
- run:
Expand Down
6 changes: 3 additions & 3 deletions controls/aws.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
require_relative '../helpers/os_queries'

inside_aws = ec2?
configure_aws_profile = attribute('configure_aws_profile', default: true, description: 'Configure Proxy').to_s.eql?('true') ? true : false
configure = attribute('configure_aws_profile', default: true, description: 'Configure Proxy').to_s.eql?('true') ? true : false

debug = attribute('debug', default: false, description: 'Enable Debugging').to_s.eql?('true') ? true : false
puts "ATTR: Configure AWS Profile (#{configure_aws_profile})" if debug
puts "ATTR: Configure AWS Profile (#{configure})" if debug

profile_settings = %w(
AWS_REGION
)

if os.linux? && inside_aws
if configure_aws_profile
if configure
describe 'AWS Profile' do
it 'Configured' do
profile_settings.each do |value|
Expand Down
19 changes: 19 additions & 0 deletions controls/backups.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require_relative '../helpers/os_queries'

inside_aws = ec2?
configure = attribute('configure_backups', default: false, description: 'Configure Backups').to_s.eql?('true') ? true : false

debug = attribute('debug', default: false, description: 'Enable Debugging').to_s.eql?('true') ? true : false
if debug
puts "ATTR: Inside AWS (#{inside_aws})"
puts "ATTR: Configure Backups (#{configure})"
end

if os.linux? && configure
describe 'Backup Script' do
it '/usr/bin/backup_to_s3.rb' do
expect(file('/usr/bin/backup_to_s3.rb')).to exist
expect(file('/usr/bin/backup_to_s3.rb')).to be_owned_by('root')
end
end
end
26 changes: 26 additions & 0 deletions controls/cloudwatch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require_relative '../helpers/os_queries'

inside_aws = ec2?
configure = attribute('configure_cloudwatch', default: true, description: 'Configure CloudWatch Monitoring').to_s.eql?('true') ? true : false

debug = attribute('debug', default: false, description: 'Enable Debugging').to_s.eql?('true') ? true : false
if debug
puts "ATTR: Inside AWS (#{inside_aws})"
puts "ATTR: Configure CloudWatch (#{configure})"
end

if os.linux? && configure
describe 'CloudWatch Monitoring' do
it 'Scripts' do
expect(file('/opt/aws-scripts-mon/mon-put-instance-data.pl')).to exist
expect(file('/opt/aws-scripts-mon/mon-put-instance-data.pl')).to be_owned_by('root')
end

if inside_aws
it 'Cron' do
expect(service('awslogs')).to be_enabled
expect(service('awslogs')).to be_running
end
end
end
end
30 changes: 17 additions & 13 deletions controls/cloudwatch_logs.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
require_relative '../helpers/os_queries'

# Can not call method in Describe call, but can use local variable as condition.
inside_aws = ec2?
configure_cloudwatch_logs = attribute('configure_cloudwatch_logs', default: true, description: 'Configure CloudWatch Logs').to_s.eql?('true') ? true : false
amazon = amazon?
configure = attribute('configure_cloudwatch_logs', default: true, description: 'Configure CloudWatch Logs').to_s.eql?('true') ? true : false

debug = attribute('debug', default: false, description: 'Enable Debugging').to_s.eql?('true') ? true : false
if debug
puts "ATTR: Inside AWS (#{inside_aws})"
puts "ATTR: Configure CloudWatch Logs (#{configure_cloudwatch_logs})"
puts "ATTR: Inside AWS (#{inside_aws})"
puts "ATTR: Configure CloudWatch Logs (#{configure})"
end

if os.linux? && configure_cloudwatch_logs
if os.linux? && configure
describe 'CloudWatch Logs' do
it 'awslogs installed' do
expect(package('awslogs')).to be_installed
if amazon
it 'Agent RPM' do
expect(package('awslogs')).to be_installed
end
end

it 'has awscli.conf' do
it 'awscli.conf' do
expect(file('/etc/awslogs/awscli.conf')).to exist
expect(file('/etc/awslogs/awscli.conf')).to be_owned_by('root')
end

it 'has awslogs.conf' do
expect(file('/etc/awslogs/awslogs.conf')).to exist
expect(file('/etc/awslogs/awslogs.conf')).to be_owned_by('root')
end

if inside_aws
it 'awslogs service' do
it 'awslogs.conf' do
expect(file('/etc/awslogs/awslogs.conf')).to exist
expect(file('/etc/awslogs/awslogs.conf')).to be_owned_by('root')
end

it 'Service' do
expect(service('awslogs')).to be_enabled
expect(service('awslogs')).to be_running
end
Expand Down
6 changes: 3 additions & 3 deletions controls/epel.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
require_relative '../helpers/os_queries'

configure_epel = attribute('configure_epel', default: false, description: 'Configure EPEL').to_s.eql?('true') ? true : false
configure = attribute('configure_epel', default: false, description: 'Configure EPEL').to_s.eql?('true') ? true : false
install_epel_packages = attribute('install_epel_packages', default: false, description: 'Install EPEL Packages').to_s.eql?('true') ? true : false

debug = attribute('debug', default: false, description: 'Enable Debugging').to_s.eql?('true') ? true : false
if debug
puts "ATTR: Configure EPEL (#{configure_epel})"
puts "ATTR: Configure EPEL (#{configure})"
puts "ATTR: Install EPEL Packages (#{install_epel_packages})"
end

if os.redhat?
if configure_epel
if configure
# Verify EPEL is setup
describe 'EPEL Repo' do
it 'Setup' do
Expand Down
30 changes: 30 additions & 0 deletions controls/java.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require_relative '../helpers/os_queries'

install_java = attribute('install_java', default: false, description: 'Install Java').to_s.eql?('true') ? true : false
java_package_name = attribute('java_package_name', default: 'java-1.8.0-openjdk', description: 'Java Version')
specify_version = attribute('specify_version', default: false, description: 'Specify Version').to_s.eql?('true') ? true : false
java_version = attribute('java_version', default: '1.8.0.151-1.b12.35.amzn1', description: 'Java Version')

debug = attribute('debug', default: false, description: 'Enable Debugging').to_s.eql?('true') ? true : false
if debug
puts "ATTR: Install Java (#{install_java})"
puts "ATTR: Java Package (#{java_package_name})"
puts "ATTR: Specify Version (#{specify_version})"
puts "ATTR: Java Version (#{java_version})"
end

# Check if Installed
if install_java
if os.linux?
describe 'Java Install' do
it 'Installed' do
expect(package(java_package_name)).to be_installed
end
if specify_version
it "Version: (#{java_version})" do
expect(package(java_package_name).version).to match(java_version)
end
end
end
end
end
10 changes: 5 additions & 5 deletions controls/node_info.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
require_relative '../helpers/os_queries'

configure_node_info = attribute('configure_node_info', default: true, description: 'Configure Node Info').to_s.eql?('true') ? true : false
configure = attribute('configure_node_info', default: true, description: 'Configure Node Info').to_s.eql?('true') ? true : false

debug = attribute('debug', default: false, description: 'Enable Debugging').to_s.eql?('true') ? true : false
puts "ATTR: Configure NodeInfo (#{configure_node_info})" if debug
puts "ATTR: Configure NodeInfo (#{configure})" if debug

if configure_node_info
if configure
if os.linux?
describe 'Nodeinfo Script' do
it 'has /usr/local/bin/nodeinfo' do
it '/usr/local/bin/nodeinfo' do
expect(file('/usr/local/bin/nodeinfo')).to exist
end
end
elsif os.windows?
describe 'Nodeinfo Script' do
it 'has C:/Windows/System32/nodeinfo.cmd' do
it 'C:/Windows/System32/nodeinfo.cmd' do
expect(file('C:/Windows/System32/nodeinfo.cmd')).to exist
end
end
Expand Down
Loading

0 comments on commit 7c90873

Please sign in to comment.