summaryrefslogtreecommitdiff
path: root/lib/chef/resource/sudo.rb
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-06-18 14:35:58 -0700
committerTim Smith <tsmith84@gmail.com>2020-06-18 14:35:58 -0700
commitf9a33ac5e42a29d7362bf4a55c8ac262c935651c (patch)
tree58d2252614a1e217a5fbbe6d0c234ca241c27476 /lib/chef/resource/sudo.rb
parent9230b00dd39481728576254f52d35424c0c40eb2 (diff)
downloadchef-f9a33ac5e42a29d7362bf4a55c8ac262c935651c.tar.gz
Add more examples to the resource code
Also update the sudo resource command description based on an escalation. The commands need to be the full path to the command not just the comand. Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/resource/sudo.rb')
-rw-r--r--lib/chef/resource/sudo.rb29
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/chef/resource/sudo.rb b/lib/chef/resource/sudo.rb
index 377e0e432e..4dd56fd311 100644
--- a/lib/chef/resource/sudo.rb
+++ b/lib/chef/resource/sudo.rb
@@ -34,6 +34,33 @@ class Chef
" installation of the required sudo version. Chef-supported releases of Ubuntu, SuSE, Debian,"\
" and RHEL (6+) all support this feature."
introduced "14.0"
+ examples <<~DOC
+ **Grant a user sudo privileges for any command**
+
+ ```ruby
+ sudo 'admin' do
+ user 'admin'
+ end
+ ```
+
+ **Grant a user and groups sudo privileges for any command**
+
+ ```ruby
+ sudo 'admins' do
+ users 'bob'
+ groups 'sysadmins, superusers'
+ end
+ ```
+
+ **Grant passwordless sudo privileges for specific commands**
+
+ ```ruby
+ sudo 'passwordless-access' do
+ commands ['/bin/systemctl restart httpd', '/bin/systemctl restart mysql']
+ nopasswd true
+ end
+ ```
+ DOC
# According to the sudo man pages sudo will ignore files in an include dir that have a `.` or `~`
# We convert either to `__`
@@ -53,7 +80,7 @@ class Chef
coerce: proc { |x| coerce_groups(x) }
property :commands, Array,
- description: "An array of commands this sudoer can execute.",
+ description: "An array of full paths to commands this sudoer can execute.",
default: ["ALL"]
property :host, String,