-
Notifications
You must be signed in to change notification settings - Fork 131
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
improve error handling around obtaining the user's Group ID #89
Conversation
During `why_run` mode, the user has not been created yet. As such, calls to `Etc.getpwnam()` result in an `ArgumentError` being thrown. Add a `user_gid` method that either returns the gid or nil, and use it where the gid is required.
6bcb4a0
to
7d445ed
Compare
I wonder if taking into account the converged_by logic in http://dougireton.com/blog/2013/01/07/creating-an-lwrp-part-2/ is relevant here...? Also, getting the below when running a converge with this:
Chef 12.2.1 |
I have a fix for the above error, will PR it to @theckman to merge together :) |
Fix for Chef 12.x / Ruby 2.x for this PR in theckman#1, so it can be merged together with this PR |
Fix whyrun on Chef 12.x / Ruby 2.x
chef provides some built-in classes to deal with such scenarios, im thinking whether to convert the provider to leverage them. aka, define_resource_requirements |
also, cant we just use new_resource.username as the value of group attribute, instead of computing the gid? |
@@ -94,6 +94,14 @@ def normalize_bool(val) | |||
end | |||
end | |||
|
|||
def user_gid | |||
# this check is needed as the new user won't exit yet |
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.
Spell 'exist' correctly.
improve error handling around obtaining the user's Group ID
This project has been dormant for awhile, and I wanted to have a nice recap of things introduced since `0.4.2` was released: * fix an error in the LWRP when a `--why-run` invocation is invoked before the user has been created (PR #89 by Tim Heckman). * add a `groups` resource to the LWRP to allow the user to be added to additional groups upon creation (PR #96 by acqant)
This project has been dormant for awhile, and I wanted to have a nice recap of things introduced since `0.4.2` was released: * fix an error in the LWRP when a `--why-run` invocation is invoked before the user has been created (PR #89 by Tim Heckman). * add a `groups` resource to the LWRP to allow the user to be added to additional groups upon creation (PR #96 by acqant)
This project has been dormant for awhile, and I wanted to have a nice recap of things introduced since `0.4.2` was released: * fix an error in the LWRP when a `--why-run` invocation is invoked before the user has been created (PR #89 by Tim Heckman). * add a `groups` resource to the LWRP to allow the user to be added to additional groups upon creation (PR #96 by acqant) * fix tests and dependencies to work with Ruby 2.1.4 (version shipped with Chef 12.1.0)
This project has been dormant for awhile, and I wanted to have a nice recap of things introduced since `0.4.2` was released: * fix an error in the LWRP when a `--why-run` invocation is invoked before the user has been created (PR #89 by Tim Heckman). * add a `groups` resource to the LWRP to allow the user to be added to additional groups upon creation (PR #96 by acqant) * add `issues_url` and `source_url` to the metadata file * fix tests and dependencies to work with Ruby 2.1.4 (version shipped with Chef 12.1.0)
During
why_run
mode, the user has not been created yet. As such, calls toEtc.getpwnam()
result in anArgumentError
being thrown.Add a
user_gid
method that either returns the gid or nil, and use it where the gid is required.