Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ Should the server reboot after patching has been applied? (Defaults to 'never')

##### `timeout`

Data type: `Optional[Integer]`
Data type: `Integer`

How many seconds should we wait until timing out the patch run? (Defaults to 3600 seconds)

Expand Down
3 changes: 2 additions & 1 deletion tasks/patch_server.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
},
"timeout": {
"description": "How many seconds should we wait until timing out the patch run? (Defaults to 3600 seconds)",
"type": "Optional[Integer]"
"type": "Integer",
"default": 3600
},
"security_only": {
"description": "Limit patches to those tagged as security related? (Defaults to false)",
Expand Down
17 changes: 6 additions & 11 deletions tasks/patch_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,11 @@ def gather_facts(log, starttime)
err('110', 'os_patching/zypper_params', 'Unsafe content in zypper_params', starttime)
end
# Set the timeout for the patch run
if params['timeout']
if params['timeout'] > 0
timeout = params['timeout']
else
err('121', 'os_patching/timeout', "timeout set to #{timeout} seconds - invalid", starttime)
end

if params['timeout'].positive?
timeout = params['timeout']
else
timeout = 3600
err('121', 'os_patching/timeout', "timeout set to #{timeout} seconds - invalid", starttime)
end

# Is the patching blocker flag set?
Expand Down Expand Up @@ -573,8 +570,6 @@ def gather_facts(log, starttime)
log.info 'Patching complete'
elsif os['family'] == 'Debian'
# Are we doing security only patching?
apt_mode = ''
pkg_list = []
if security_only == true
pkg_list = os_patching['security_package_updates']
apt_mode = 'install ' + pkg_list.join(' ')
Expand All @@ -587,8 +582,8 @@ def gather_facts(log, starttime)
log.debug "Running apt #{apt_mode}"
deb_front = 'DEBIAN_FRONTEND=noninteractive'
deb_opts = '-o Apt::Get::Purge=false -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-confdef --no-install-recommends'
apt_std_out, stderr, status = Open3.capture3("#{deb_front} apt-get #{dpkg_params} -y #{deb_opts} #{apt_mode}")
err(status, 'os_patching/apt', stderr, starttime) if status != 0
apt_std_out, status = run_with_timeout("#{deb_front} apt-get #{dpkg_params} -y #{deb_opts} #{apt_mode}", timeout, 2)
err(status, 'os_patching/apt', apt_std_out, starttime) if status != 0

output('Success', reboot, security_only, 'Patching complete', pkg_list, apt_std_out, '', pinned_pkgs, starttime, log)
log.info 'Patching complete'
Expand Down
Loading