diff --git a/.gitignore b/.gitignore index af2850b..2466a17 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,9 @@ tmp/ # rbenv .ruby-version +# rubocop +.rubocop_todo.yml + # Test Kitchen .kitchen/ .kitchen.local.yml diff --git a/.kitchen.yml b/.kitchen.yml new file mode 100644 index 0000000..0649838 --- /dev/null +++ b/.kitchen.yml @@ -0,0 +1,44 @@ +--- +driver: + name: vagrant + +provisioner: + name: chef_solo + +verifier: + name: inspec + format: progress + +platforms: + - name: ubuntu-12.04 + - name: ubuntu-14.04 + - name: ubuntu-16.04 + - name: centos-6.8 + - name: centos-7.2 + +suites: + - name: default + run_list: + - recipe[auto-patch::default] + attributes: + auto-patch: + hour: 9 + minute: 25 + monthly: 'third saturday' + - name: update-now + run_list: + - recipe[auto-patch::update_now] + attributes: + auto-patch: + now: true + once: true + - name: once + run_list: + - recipe[auto-patch::default] + attributes: + auto-patch: + once: true + month: 9 + day: 16 + hour: 1 + minute: 00 \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml index 243c1b2..a195a5b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,6 +9,13 @@ AllCops: - vendor/**/* - ruby/**/* +Style/ConditionalAssignment: + Exclude: + - 'libraries/auto_patch.rb' + +Metrics/AbcSize: + Max: 18 + AlignParameters: Enabled: false Encoding: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..bb1b005 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,25 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2016-06-08 04:10:57 -0500 using RuboCop version 0.39.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +# Cop supports --auto-correct. +Lint/UnneededDisable: + Exclude: + - 'Guardfile' + +# Offense count: 1 +Metrics/AbcSize: + Max: 18 + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly. +# SupportedStyles: assign_to_condition, assign_inside_condition +Style/ConditionalAssignment: + Exclude: + - 'libraries/auto_patch.rb' diff --git a/.travis.yml b/.travis.yml index 16282b9..3741994 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,11 @@ language: ruby bundler_args: --without integration rvm: - - 1.9.3 + - 2.2.2 + +# Don't `bundle install` which takes about 1.5 mins +# install: echo "skip bundle install" + before_script: - bundle exec berks install script: diff --git a/Berksfile b/Berksfile index 52dc4f4..131422e 100644 --- a/Berksfile +++ b/Berksfile @@ -1,4 +1,4 @@ -site :opscode +source 'https://supermarket.chef.io' metadata diff --git a/CHANGELOG.md b/CHANGELOG.md index b873636..efe8db2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.0 + +* Add features update_once and update_now + ## 0.1.10 * Bugfix: #2 check if constants are already defined diff --git a/Gemfile b/Gemfile index 8274c35..0a374fd 100644 --- a/Gemfile +++ b/Gemfile @@ -3,19 +3,21 @@ source 'https://rubygems.org' gem 'rake' group :test, :integration do - gem 'berkshelf', '~> 2.0.14' + gem 'berkshelf' end group :test do gem 'chefspec', '~> 4.0' gem 'foodcritic', '~> 3.0.3' gem 'rubocop', '~> 0.23' + gem 'rspec', '~> 3.0' end group :integration do gem 'busser-serverspec', '~> 0.2.6' gem 'kitchen-vagrant', '~> 0.14' gem 'test-kitchen', '~> 1.1' + gem 'buff-ignore', '= 1.2.0' end # group :development do diff --git a/Guardfile b/Guardfile index 4d87f31..a835f3b 100644 --- a/Guardfile +++ b/Guardfile @@ -1,7 +1,6 @@ # A sample Guardfile # More info at https://github.com/guard/guard#readme -# rubocop:disable RegexpLiteral guard 'kitchen' do watch(%r{test/.+}) watch(%r{^recipes/(.+)\.rb$}) @@ -11,4 +10,12 @@ guard 'kitchen' do watch(%r{^providers/(.+)\.rb}) watch(%r{^resources/(.+)\.rb}) end -# rubocop:enable RegexpLiteral + +guard 'foodcritc', :cookbook_paths => '.', :all_on_start => false do + watch(%r{attributes/.+\.rb$}) + watch(%r{providers/.+\.rb$}) + watch(%r{recipes/.+\.rb$}) + watch(%r{resources/.+\.rb$}) + watch(%r{^templates/(.+)}) + watch('metadata.rb') +end diff --git a/README.md b/README.md index 2c0d62c..49aff48 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# chef-auto-patch [![Build Status](https://secure.travis-ci.org/bflad/chef-auto-patch.png?branch=master)](http://travis-ci.org/bflad/chef-auto-patch) +# auto-patch [![Build Status](https://secure.travis-ci.org/bflad/chef-auto-patch.png?branch=master)](http://travis-ci.org/bflad/chef-auto-patch) ## Description @@ -40,6 +40,7 @@ and a [corresponding cookbook](https://github.com/firstbanco/chef-unattended-upg * `node["auto-patch"]["weekly"]` - auto patching occurs once a week on the corresponding textual weekday ("monday","tuesday",etc), overrides `node["auto-patch"]["monthly"]`, defaults to nil +* `node["auto-patch"]["now"]`, patches the system immediately, default to false ### Patch Preparation @@ -60,7 +61,7 @@ and a [corresponding cookbook](https://github.com/firstbanco/chef-unattended-upg * `node["auto-patch"]["prep"]["update_updater"]` - updates apt or yum before actual patching occurs, defaults to true -## Recipes +## Recipe * `recipe[auto-patch]` configures automatic patching @@ -71,6 +72,11 @@ and a [corresponding cookbook](https://github.com/firstbanco/chef-unattended-upg any splay!) * Add `recipe[auto-patch]` to your node's run list +### Update Once + +Set `node["auto-patch"]["once"]` attribute to true will set the system to update +and reboot by default a single instance at the date and time indicated. + ### Weekly automatic patching Just use the `node["auto-patch"]["weekly"]` attribute to override the monthly @@ -137,21 +143,27 @@ Example role that then could be added to 10pm nodes: * If necessary, specify `node["auto-patch"]["prep"]["disable"]` to true * Run chef-client on your node +## Recipe + +* `recipe[auto-patch::update-now]` performs patching + +### Update now + +* Specify `node["auto-patch"]["now"]` to true - node will install all updates during each chef run + ## Testing and Development -Here's how you can quickly get testing or developing against the cookbook thanks to [Vagrant](http://vagrantup.com/) and [Berkshelf](http://berkshelf.com/). +This repo includes a .kitchen.yml file which leverages [Test Kitchen](http://kitchen.ci/) and [Vagrant](http://docs.vagrantup.com/v2/cli/index.html) to test and verify. + +Test Kitchen is already included as part of [ChefDK](https://downloads.chef.io/chef-dk/). To start testing run: + + kitchen converge + +Only the system has finished converging you can log into it by using the command - vagrant plugin install vagrant-berkshelf - vagrant plugin install vagrant-cachier - vagrant plugin install vagrant-omnibus - git clone git://github.com/bflad/chef-auto-patch.git - cd chef-auto-patch - vagrant up BOX # BOX being centos5, centos6, debian7, fedora18, fedora19, fedora20, freebsd9, ubuntu1204, ubuntu1210, ubuntu1304, or ubuntu1310 + kitchen login -You can then SSH into the running VM using the `vagrant ssh BOX` # BOX being centos6 or ubuntu1204 command. -The VM can easily be stopped and deleted with the `vagrant destroy` -command. Please see the official [Vagrant documentation](http://docs.vagrantup.com/v2/cli/index.html) -for a more in depth explanation of available commands. +All rspec and integration tests are performed and the system can be manually verified. ## Contributing @@ -160,6 +172,7 @@ Please use standard Github issues/pull requests. ## License and Author Author:: Brian Flad () + Derek Groh () Copyright:: 2012-2013 diff --git a/attributes/default.rb b/attributes/default.rb index 7ff5b1e..6e8d60a 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -31,3 +31,7 @@ default['auto-patch']['prep']['splay'] = 1800 default['auto-patch']['prep']['weekly'] = nil default['auto-patch']['prep']['update_updater'] = true +default['auto-patch']['prep']['once'] = false + +default['auto-patch']['now'] = false +default['auto-patch']['once'] = false diff --git a/chefignore b/chefignore new file mode 100644 index 0000000..7be3c6d --- /dev/null +++ b/chefignore @@ -0,0 +1 @@ +.kitchen diff --git a/libraries/auto_patch.rb b/libraries/auto_patch.rb index 92411a1..a678fed 100644 --- a/libraries/auto_patch.rb +++ b/libraries/auto_patch.rb @@ -24,8 +24,8 @@ class Chef class Recipe # Chef::Recipe::AutoPatch class class AutoPatch - WEEKS = %w(first second third fourth) unless defined?(WEEKS) - WEEKDAYS = %w(sunday monday tuesday wednesday thursday friday saturday) unless defined?(WEEKDAYS) + WEEKS = %w(first second third fourth).freeze unless defined?(WEEKS) + WEEKDAYS = %w(sunday monday tuesday wednesday thursday friday saturday).freeze unless defined?(WEEKDAYS) def self.monthly_date(year, month, monthly_specifier) Date.new(year, month, monthly_day(year, month, monthly_specifier)) @@ -41,7 +41,7 @@ def self.monthly_day(year, month, monthly_specifier) while weekday(weekly_specifier) != Date.new(year, month, first_day_occurance).wday first_day_occurance += 1 end - first_day_occurance + ( WEEKS.index(week) * 7) + first_day_occurance + (WEEKS.index(week) * 7) end def self.next_monthly_date(monthly_specifier, hour, minute) diff --git a/metadata.rb b/metadata.rb index 927e0a9..f191fce 100644 --- a/metadata.rb +++ b/metadata.rb @@ -3,7 +3,7 @@ maintainer_email 'bflad@417@gmail.com' license 'Apache 2.0' description 'Configures node for automatic patching.' -version '0.1.10' +version '0.2.0' recipe 'auto-patch', 'Configures node for automatic patching.' %w(cron).each do |d| @@ -13,3 +13,6 @@ %w(amazon centos debian fedora redhat scientific ubuntu).each do |os| supports os end + +issues_url 'https://github.com/derekgroh/auto-patch/issues' +source_url 'https://github.com/derekgroh/auto-patch.git' diff --git a/recipes/default.rb b/recipes/default.rb index 2bcf274..b7a2d7f 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -16,6 +16,8 @@ # limitations under the License. include_recipe 'cron' +include_recipe 'auto-patch::update_now' if node['auto-patch']['now'] == true +include_recipe 'auto-patch::update_once' if node['auto-patch']['once'] == true unless node['auto-patch']['prep']['disable'] if node['platform_family'] == 'rhel' @@ -35,7 +37,8 @@ next_date = AutoPatch.next_monthly_date( node['auto-patch']['prep']['monthly'], node['auto-patch']['prep']['hour'], - node['auto-patch']['prep']['minute']) + node['auto-patch']['prep']['minute'] + ) node.set['auto-patch']['prep']['day'] = next_date.day node.set['auto-patch']['prep']['month'] = next_date.month node.set['auto-patch']['prep']['weekday'] = '*' @@ -73,7 +76,8 @@ next_date = AutoPatch.next_monthly_date( node['auto-patch']['monthly'], node['auto-patch']['hour'], - node['auto-patch']['minute']) + node['auto-patch']['minute'] + ) node.set['auto-patch']['day'] = next_date.day node.set['auto-patch']['month'] = next_date.month node.set['auto-patch']['weekday'] = '*' diff --git a/recipes/update_now.rb b/recipes/update_now.rb new file mode 100644 index 0000000..4bb3f14 --- /dev/null +++ b/recipes/update_now.rb @@ -0,0 +1,36 @@ +# +# Cookbook Name:: chef-auto-patch +# Recipe:: update_now +# +# Copyright (c) 2016 The Authors, All Rights Reserved. + +if node['auto-patch']['now'] + case node['platform_family'] + when 'rhel' + execute 'Yum update' do + command 'yum -y update' + end + log 'rhel' do + level :info + message 'yum update performed' + end + when 'debian' + execute 'apt-get update' do + command 'apt-get -q update' + end + log 'debian' do + level :info + message 'apt-get update performed' + end + else + log 'update-now failed - platform_family' do + level :warn + message '***** WARNING platform_family not recognized - update failed *****' + end + end +else + log 'update-now failed' do + level :warn + message "***** WARNING node['auto-patch']['now'] set to false, system not patched *****" + end +end diff --git a/recipes/update_once.rb b/recipes/update_once.rb new file mode 100644 index 0000000..7a5ef79 --- /dev/null +++ b/recipes/update_once.rb @@ -0,0 +1,42 @@ +# +# Cookbook Name:: auto-patch +# Recipe:: update_once +# +# Copyright (c) 2016 The Authors, All Rights Reserved. + +if node['auto-patch']['once'] + case node['platform_family'] + when 'rhel' + package 'at' do + action :install + end + service 'atd' do + action :start + end + execute 'at yum update' do + command 'echo "sudo yum -y update" | at now' + end + log 'rhel' do + level :info + message 'echo "sudo yum -y update" | at now executed' + end + when 'ubuntu' + execute 'at apt-get -q update' do + command 'echo "sudo apt-get -q update" | at now' + end + log 'debian' do + level :info + message 'echo "sudo apt-get -q update" | at now' + end + else + log 'update-once failed - platform_family' do + level :warn + message '***** WARNING platform_family not recognized - update failed *****' + end + end +else + log 'update-once failed' do + level :warn + message "***** WARNING node['auto-patch']['once'] set to false, system not patched *****" + end +end diff --git a/spec/default_spec.rb b/spec/default_spec.rb deleted file mode 100644 index 7dfc502..0000000 --- a/spec/default_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'spec_helper' - -describe 'auto-patch::default' do - let(:chef_run) do - ChefSpec::Runner.new.converge(described_recipe) - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8dbc292..ba8d688 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,7 +2,7 @@ require 'chefspec/berkshelf' # See https://github.com/sethvargo/chefspec/issues/393 -# ChefSpec::Coverage.start! +ChefSpec::Coverage.start! RSpec.configure do |config| config.log_level = :error diff --git a/spec/unit/recipes/default_spec.rb b/spec/unit/recipes/default_spec.rb new file mode 100644 index 0000000..7d28cfc --- /dev/null +++ b/spec/unit/recipes/default_spec.rb @@ -0,0 +1,122 @@ +# +# Cookbook Name:: auto-patch +# Spec:: default +# +# Copyright (c) 2016 The Authors, All Rights Reserved. + +require 'spec_helper' + +describe 'auto-patch::default' do + context 'When all attributes are default, on an unspecified platform' do + let(:chef_run) do + ChefSpec::ServerRunner.new do |node| + node.set['auto-patch']['prep']['disable'] = true + node.set['auto-patch']['disable'] = true + end.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run.to_not raise_error } + end + + it 'includes the `cron` recipe' do + expect(chef_run).to include_recipe('cron::default') + end + + it 'deletes the template `/usr/local/sbin/auto-patch-prep` if node[\'auto-patch\'][\'prep\'][\'disable\'] is true' do + expect(chef_run).to delete_template('/usr/local/sbin/auto-patch-prep').with( + :source => 'auto-patch-prep.sh.erb', + :owner => 'root', + :group => 'root', + :mode => '0700' + ) + end + + it 'deletes the cron `auto-patch-prep` if node[\'auto-patch\'][\'prep\'][\'disable\'] is true' do + expect(chef_run).to delete_cron_d('auto-patch-prep').with( + #:hour => '', + #:minute => '', + #:weekday => '', + #:day => '', + #:month => '', + :command => '/usr/local/sbin/auto-patch-prep' + ) + end + + it 'deletes the template `/usr/local/sbin/auto-patch` if node[\'auto-patch\'][\'disable\']' do + expect(chef_run).to delete_template('/usr/local/sbin/auto-patch').with( + :source => 'auto-patch.sh.erb', + :owner => 'root', + :group => 'root', + :mode => '0700' + ) + end + + it 'deletes the cron `auto-patch` if node[\'auto-patch\'][\'disable\'] is true' do + expect(chef_run).to delete_cron_d('auto-patch').with( + #:hour => '', + #:minute => '', + #:weekday => '', + #:day => '', + #:month => '', + :command => '/usr/local/sbin/auto-patch' + ) + end + end +end + +describe 'auto-patch::default' do + context 'When `node[\'auto-patch\'][\'now\']` is true, on an unspecified platform' do + let(:chef_run) do + ChefSpec::ServerRunner.new do |node| + node.set['auto-patch']['now'] = true + end.converge(described_recipe) + end + + it 'includes the `auto-patch::update_now` recipe' do + expect(chef_run.node['auto-patch']['now']).to eq(true) + expect(chef_run).to include_recipe('auto-patch::update_now') + end + end +end + +describe 'auto-patch::default' do + context 'when `node[\'auto-patch\'][\'once\']` is true, on an unspecified platform' do + let(:chef_run) do + ChefSpec::ServerRunner.new do |node| + node.set['auto-patch']['once'] = true + end.converge(described_recipe) + end + + it 'includes the `auto-patch::update_once` recipe' do + expect(chef_run.node['auto-patch']['once']).to eq(true) + expect(chef_run).to include_recipe('auto-patch::update_once') + end + end +end + +describe 'auto-patch::default' do + context 'When all attributes are default, on a `rhel < 6.0` platform' do + let(:chef_run) do + runner = ChefSpec::ServerRunner.new(platform: 'rhel', version: '<6.0') + runner.converge(described_recipe) + end + + it 'installs a package `yum-downloadonly' do + expect { chef_run.to install_package('yum-downloadonly') } + end + end +end + +describe 'auto-patch::default' do + context 'When all attributes are default, on a `rhel > 6.0` platform' do + let(:chef_run) do + runner = ChefSpec::ServerRunner.new(platform: 'rhel', version: '>6.0') + runner.converge(described_recipe) + end + + it 'installs a package `yum-plugin-downloadonly' do + expect { chef_run.to install_package('yum-plugin-downloadonly') } + end + end +end diff --git a/spec/unit/recipes/update_now_spec.rb b/spec/unit/recipes/update_now_spec.rb new file mode 100644 index 0000000..1b83ba2 --- /dev/null +++ b/spec/unit/recipes/update_now_spec.rb @@ -0,0 +1,65 @@ +# +# Cookbook Name:: chef-auto-patch +# Spec:: default +# +# Copyright (c) 2016 The Authors, All Rights Reserved. + +require 'spec_helper' + +describe 'auto-patch::update_now' do + context 'when on CentOS' do + let(:chef_run) do + runner = ChefSpec::ServerRunner.new(platform: 'rhel') + runner.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run.to_not raise_error } + end + + it 'runs an execute `Yum update`' do + expect do + chef_run.to run_execute('Yum update').with( + :command => 'yum -y update' + ) + end + end + + it 'writes a log `rhel`' do + expect do + chef_run.to write_log('rhel').with( + :level => ':info', + :message => 'yum update performed' + ) + end + end + end + + context 'when on Ubuntu' do + let(:chef_run) do + runner = ChefSpec::ServerRunner.new(platform: 'ubuntu') + runner.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run.to_not raise_error } + end + + it 'runs an execute `apt-get update`' do + expect do + chef_run.to run_execute('apt-get update').with( + :command => 'apt-get -q update' + ) + end + end + + it 'writes a log `debian`' do + expect do + chef_run.to write_log('debian').with( + :level => ':info', + :message => 'apt-get update performed' + ) + end + end + end +end diff --git a/spec/unit/recipes/update_once_spec.rb b/spec/unit/recipes/update_once_spec.rb new file mode 100644 index 0000000..b31e526 --- /dev/null +++ b/spec/unit/recipes/update_once_spec.rb @@ -0,0 +1,73 @@ +# +# Cookbook Name:: auto-patch +# Spec:: default +# +# Copyright (c) 2016 The Authors, All Rights Reserved. + +require 'spec_helper' + +describe 'auto-patch::update_once' do + context 'when on CentOS' do + let(:chef_run) do + runner = ChefSpec::ServerRunner.new(platform: 'rhel') + runner.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run.to_not raise_error } + end + + it 'installs a package `at`' do + expect { chef_run.to install_package('at') } + end + + it 'starts a service `atd`' do + expect { chef_run.to start_service('atd') } + end + + it 'runs an execute `at yum update`' do + expect do + chef_run.to run_execute('at yum update').with( + :command => 'echo "sudo yum -y update" | at now' + ) + end + end + + it 'writes a log `rhel`' do + expect do + chef_run.to write_log('rhel').with( + :level => ':info', + :message => 'echo "sudo yum -y update" | at now executed' + ) + end + end + end + + context 'when on Ubuntu' do + let(:chef_run) do + runner = ChefSpec::ServerRunner.new(platform: 'ubuntu') + runner.converge(described_recipe) + end + + it 'converges successfully' do + expect { chef_run.to_not raise_error } + end + + it 'runs an execute `at apt-get -q update`' do + expect do + chef_run.to run_execute('at apt-get -q update').with( + :command => 'echo "sudo apt-get -q update" | at now' + ) + end + end + + it 'writes a log `debian`' do + expect do + chef_run.to write_log('debian').with( + :level => ':info', + :message => 'echo "sudo apt-get -q update" | at now' + ) + end + end + end +end diff --git a/templates/default/auto-patch-prep.sh.erb b/templates/default/auto-patch-prep.sh.erb index 47df799..69c00bb 100644 --- a/templates/default/auto-patch-prep.sh.erb +++ b/templates/default/auto-patch-prep.sh.erb @@ -40,3 +40,7 @@ sleep $[ ( $RANDOM % <%= node["auto-patch"]["prep"]["splay"] %> ) + 1 ]s /usr/bin/apt-get -q=2 upgrade apt > /dev/null <% end -%> <% end -%> + +<% if node["auto-patch"]["prep"]["once"] -%> +rm -f /usr/local/sbin/auto-patch +<% end -%> diff --git a/templates/default/auto-patch.sh.erb b/templates/default/auto-patch.sh.erb index 89a5968..f22c586 100644 --- a/templates/default/auto-patch.sh.erb +++ b/templates/default/auto-patch.sh.erb @@ -18,7 +18,11 @@ sleep $[ ( $RANDOM % <%= node["auto-patch"]["splay"] %> ) + 1 ]s <% end -%> <% if node["auto-patch"]["reboot"] -%> -/sbin/init 6 +reboot -h 1 +<% end -%> + +<% if node["auto-patch"]["once"] -%> +rm -f /usr/local/sbin/auto-patch <% end -%> exit 0 diff --git a/test/integration/default/inspec/default_spec.rb b/test/integration/default/inspec/default_spec.rb new file mode 100644 index 0000000..0947154 --- /dev/null +++ b/test/integration/default/inspec/default_spec.rb @@ -0,0 +1,7 @@ +describe 'auto-patch::default' do + # Serverspec examples can be found at + # http://serverspec.org/resource_types.html + it 'configures automatic patching' do + skip 'To do' + end +end \ No newline at end of file diff --git a/test/integration/update-now/inspec/update_now_spec.rb b/test/integration/update-now/inspec/update_now_spec.rb new file mode 100644 index 0000000..f01ac2c --- /dev/null +++ b/test/integration/update-now/inspec/update_now_spec.rb @@ -0,0 +1,13 @@ +# Expect all patches to be applied +case os[:family] +when 'centos' + describe bash('yum -y update') do + its('stderr') { should eq '' } + its(:exit_status) { should eq 0 } + end +when 'ubuntu' + describe bash('apt-get -q update') do + its('stderr') { should eq '' } + its(:exit_status) { should eq 0 } + end +end diff --git a/test/integration/update-once/inspec/update_once_spec.rb b/test/integration/update-once/inspec/update_once_spec.rb new file mode 100644 index 0000000..f01ac2c --- /dev/null +++ b/test/integration/update-once/inspec/update_once_spec.rb @@ -0,0 +1,13 @@ +# Expect all patches to be applied +case os[:family] +when 'centos' + describe bash('yum -y update') do + its('stderr') { should eq '' } + its(:exit_status) { should eq 0 } + end +when 'ubuntu' + describe bash('apt-get -q update') do + its('stderr') { should eq '' } + its(:exit_status) { should eq 0 } + end +end