Skip to content
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

New define: augeasproviders_shellvar::bulk #15

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ values themselves.
uncomment => true,
}

### set many variables in the same file

augeasproviders_shellvar::bulk { [
'DEVICE=eth0',
'NAME=eth0',
"HWADDR=${hwaddress}",
]:
target => '/etc/sysconfig/network',
}

### array values

You can pass array values to the type.
Expand Down
20 changes: 20 additions & 0 deletions manifests/bulk.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
define augeasproviders_shellvar::bulk (
$target,
$quoted = undef,
) {

$arr = split($name, '=')
$k = $arr[0]
$v = $arr[1]

shellvar { "${target} ${k}":
ensure => present,
variable => $k,
value => $v,
target => $target,
quoted => $quoted,
}


}
36 changes: 36 additions & 0 deletions spec/defines/bulk_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'spec_helper'

describe 'augeasproviders_shellvar::bulk' do

describe 'default options' do
let(:title) { 'thekey=thevalue' }
let(:params) {{
:target => '/tmp/test.txt',
}}
it { should compile }
it { should contain_shellvar('/tmp/test.txt thekey').with(
:ensure => 'present',
:variable => 'thekey',
:value => 'thevalue',
:target => '/tmp/test.txt',
:quoted => nil
)}
end

describe 'with double-quotes enabled' do
let(:title) { 'thekey=thevalue' }
let(:params) {{
:target => '/tmp/test.txt',
:quoted => 'double',
}}
it { should compile }
it { should contain_shellvar('/tmp/test.txt thekey').with(
:ensure => 'present',
:variable => 'thekey',
:value => 'thevalue',
:target => '/tmp/test.txt',
:quoted => 'double',
)}
end

end