Skip to content

Commit

Permalink
Merge pull request #28 from PaytmLabs/feature-control-updates
Browse files Browse the repository at this point in the history
make it possible to control which phase package upgrades occur
  • Loading branch information
flaccid committed Sep 26, 2015
2 parents 16bfb7a + 2b79094 commit 9b92cf2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ See `attributes/default.rb` for default values.
- `node['system']['workgroup']` - the NetBIOS workgroup name to set on the node, default is `WORKGROUP` (OS X only)
- `node['system']['static_hosts']` - a hash of static hosts to add to `/etc/hosts`
- `node['system']['upgrade_packages']` - whether to upgrade the system's packages, default `true`
- `node['system']['upgrade_packages_at_compile']` - whether upgrade of the system's packages in Chef's compilation phase, default `true`
- `node['system']['enable_cron']` - whether to include the cron recipe, default `true`
- `node['system']['packages']['install']` - an array of packages to install (also supports remote package URLs)
- `node['system']['packages']['install_compile_time']` - an array of packages to install in Chef's compilation phase (also supports remote package URLs)
Expand Down
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
default['system']['static_hosts'] = {}
default['system']['manage_hostsfile'] = true
default['system']['upgrade_packages'] = true
default['system']['upgrade_packages_at_compile'] = true
default['system']['permanent_ip'] = true
default['system']['primary_interface'] = node['network']['default_interface']
default['system']['enable_cron'] = true
Expand Down
11 changes: 10 additions & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,16 @@

attribute 'system/upgrade_packages',
display_name: 'Upgrade Packages',
description: "Whether or not the system::upgrade_packages recipe will physically update the system's installed packages (in compile time).",
description: "Whether or not the system::upgrade_packages recipe will physically update the system's installed packages.",
required: 'optional',
type: 'boolean',
choice: [true, false],
default: true,
recipes: ['system::upgrade_packages']

attribute 'system/upgrade_packages_at_compile',
display_name: 'Upgrade Packages at compile time',
description: "Whether or not the system::upgrade_packages recipe will update the system's installed packages at compile time.",
required: 'optional',
type: 'boolean',
choice: [true, false],
Expand Down
7 changes: 4 additions & 3 deletions recipes/upgrade_packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@

e = execute 'upgrade system packages' do
command upgrade_cmd
action :nothing
action(node['system']['upgrade_packages_at_compile'] ? :nothing : :run)
only_if { node['system']['upgrade_packages'] }
end

if node['system']['upgrade_packages']
if node['system']['upgrade_packages_at_compile']
# supports type string if defined through metadata
e.run_action(:run) unless node['system']['upgrade_packages'] == 'false'
e.run_action(:run)
end

0 comments on commit 9b92cf2

Please sign in to comment.