Sha256: 33e2bc380e86ab51df7f7d328eb005261959102f84f754a745811734ebbd5a54

Contents?: true

Size: 1.42 KB

Versions: 7

Compression:

Stored size: 1.42 KB

Contents

# Create Users through the API
ruby_block "Create Delivery Users" do
  block do
    # Per User
    node['demo']['users'].each do |username, info|
      # Get SSH-KEY wheter is the actual key or a path
      ssh_pub_key = return_key(info['ssh_key'])

      # Create User
      if username == "admin"
        delivery_api.put("/users/admin",
          {
            "name"        => username,
            "first"       => info['first'],
            "last"        => info['last'],
            "email"       => info['email'],
            "user_type"   => "internal",
            "ssh_pub_key" => ssh_pub_key
          })
      else
        delivery_api.put("/users/#{username}",
          {
            "name"        => username,
            "first"       => info['first'],
            "last"        => info['last'],
            "email"       => info['email'],
	          "user_type"   => "internal",
            "ssh_pub_key" => ssh_pub_key
          })
      end

      # Grant Roles
      delivery_api.post("/authz/users/#{username}", { "grant" => info['roles'] })

      # Set Password
      if info['password']
        delivery_api.post("/internal-users/#{username}/reset-password", { "password" => info['password'] })
      end
    end
  end
end

# Create Organization
ruby_block "Create #{node['demo']['org']} organization" do
  block do
    delivery_api.post("/e/#{node['demo']['enterprise']}/orgs", { "name" => node['demo']['org'] })
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wombat-cli-0.3.4 generator_files/cookbooks/automate/recipes/update-users.rb
wombat-cli-0.3.3 generator_files/cookbooks/automate/recipes/update-users.rb
wombat-cli-0.3.2 generator_files/cookbooks/automate/recipes/update-users.rb
wombat-cli-0.3.1 generator_files/cookbooks/automate/recipes/update-users.rb
wombat-cli-0.3.0 generator_files/cookbooks/automate/recipes/update-users.rb
wombat-cli-0.2.1 cookbooks/automate/recipes/update-users.rb
wombat-cli-0.2.0 cookbooks/automate/recipes/update-users.rb