-
Notifications
You must be signed in to change notification settings - Fork 26
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
Conversation
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.
1c421db
to
1d0a5a1
Compare
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")) |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
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.