Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(BOLT-1104) Unify task implementation output #117

Merged
merged 7 commits into from
Apr 9, 2019

Conversation

donoghuc
Copy link
Contributor

This PR adds improvements to the task implementations making them more robust across platforms. It also ensures that each of the implementations return consistent result keys.

Return information from the package command itself, i.e. yum or apt.
Also provide the error message as part of the json object.
Directly check the return code of commands instead of storing
$? in a variable when we can.  Use mktmp and exec to manage stderr.
For example, `yum install vim` will install `vim-enhanced`, but `rpm -q
vim` will fail to resolve this.
@donoghuc donoghuc force-pushed the BOLT-1104 branch 3 times, most recently from 1c421db to 1d0a5a1 Compare March 22, 2019 00:46
tasks/linux.sh Outdated
fi

# Determine if newer package is available to mirror the ruby/puppet implementation
upgradable_list=($(sudo apt-get -u -V --assume-no upgrade | grep "\\${PT_name}\\b"))
Copy link
Contributor

@m0dular m0dular Mar 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could probably be simplified to just check the output of apt-get with grep and use the return code. Also, a specific package can be given to apt-get. For example, with an up-to-date puppet-agent

$ cat foo.sh
#!/bin/bash

if sudo apt-get --assume-no upgrade puppet-agent | grep -q 'already the newest version'; then
  echo "latest"
else
  echo "upgradable"
fi
./foo.sh
latest

Make the bash task implementation more consistent with the ruby/puppet task output. This includes calculating a `latest_version` when a newer version of a packages is available. Note that the important update is to unify the result keys, the values can contain different information based on the implementation.
This commit updates the powershell implementation to report similar keys to the ruby/bash implementations. Similarly the error handling and parameter validation is handled more in line with the service task.
Bolt 1.15.0 includes a new feature for BoltSpec::Run that allows inventory and config to be set by defining bolt_{inventory,config} methods in scope when run_* functions are invoked. This commit refactors acceptance tests to take advantage of the new feature resulting in cleaner code.
Copy link
Contributor

@m0dular m0dular left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to refactor the bash task a bit with some helper functions, but we think it's more important to get this into the upcoming release than a mostly cosmetic improvement.

@donoghuc donoghuc merged commit 5666c95 into puppetlabs:master Apr 9, 2019
@donoghuc donoghuc deleted the BOLT-1104 branch April 9, 2019 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants