Ask Your Question
0

how to multiple values for single resource in serverspec

asked 2016-01-11 05:20:41 -0500

Chutki gravatar image

Hi,

I have puppet manifest for user creation like the below one

$db_usr = {
    'dbusr' => {
      'ensure'   => 'present',
      'uid'      => '5453',
      'gid'      => 'db_group',
      'shell'    => '/usr/bin/ksh',
      'home'     => '/home/dbusr'
}
}

I have to check the user setup by using server spec, please find the below

$test = { "uid" => "5453", "gid" => "db_group" }

$test.each|key|

describe user(key[0]) do
 it { should be_present }
 it { should have_gid key[1] }

but I am getting error, Do we have this option in server spec.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-01-11 09:47:22 -0500

I guess you probably are trying to do something like:

users = {
  'dbusr' => {
    'uid' => '5453',
    'gid' => 'db_group',
  },
  'some_other_user' => {
    'uid' => '30000',
    'gid' => 'some_group',
  },
}

users.each do |user, data|
  expected_uid = data["uid"]
  expected_gid = data["gid"]
  describe user(user) do
    it { should be_present }
    it { should have_uid expected_uid }
    it { should have_gid expected_gid }
  end
end

If what you really want to understand is how to use Hashes in Ruby, try googling. :)

Seriously, you need to do that.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-01-11 05:20:41 -0500

Seen: 34 times

Last updated: Jan 11 '16