Skip to content

Instantly share code, notes, and snippets.

@scalp42
Forked from jellybob/set_password.rb
Created July 16, 2012 03:04
Show Gist options
  • Save scalp42/3120169 to your computer and use it in GitHub Desktop.
Save scalp42/3120169 to your computer and use it in GitHub Desktop.

Revisions

  1. @jellybob jellybob created this gist Oct 6, 2010.
    19 changes: 19 additions & 0 deletions set_password.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    unless ARGV[0] && ARGV[1]
    puts "Usage: set_password.rb username password"
    exit 1
    end

    require 'chef'
    require 'chef/config'
    require 'chef/webui_user'

    Chef::Config.from_file(File.expand_path("~/.chef/knife.rb"))

    user = Chef::WebUIUser.load(ARGV[0])
    if user
    user.set_password(ARGV[1])
    user.save
    else
    puts "Could not find user #{ARGV[0]}."
    exit 2
    end