Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.
Merged
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
3 changes: 2 additions & 1 deletion resources/cookbook_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
action_class do
def create_file(folder, user, filename, cookbook_file)
cookbook_file 'create file from cookbook_file' do
mode '0640'
mode '0770'
owner user
group user
path "#{folder}/.bashrc.d/#{filename}"
source cookbook_file
cookbook new_resource.cookbook
Expand Down
3 changes: 2 additions & 1 deletion resources/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ def create_file(folder, user, filename, file_content)
# Managed by Chef. Local changes will be overwritten.
#{file_content}
FILE
mode '0640'
mode '0770'
owner user
group user
path "#{folder}/.bashrc.d/#{filename}"
end
end
Expand Down
9 changes: 6 additions & 3 deletions resources/manage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
def init(folder, user)
directory 'create .bashrc.d folder' do
path "#{folder}/.bashrc.d"
mode '0640'
mode '0770'
owner user
group user
end

file 'copy default .bashrc to init in dropfolder' do
path "#{folder}/.bashrc.d/000-init"
mode '0640'
mode '0770'
owner user
group user
content(lazy { ::File.read("#{folder}/.bashrc") })
action :create_if_missing
end
Expand All @@ -32,8 +34,9 @@ def init(folder, user)
path "#{folder}/.bashrc"
source '.bashrc.erb'
cookbook 'codenamephp_bash'
mode '0640'
mode '0770'
owner user
group user
end
end

Expand Down
3 changes: 2 additions & 1 deletion resources/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
action_class do
def create_file(folder, user, filename, source)
template 'create file from template' do
mode '0640'
mode '0770'
owner user
group user
path "#{folder}/.bashrc.d/#{filename}"
source source
cookbook new_resource.cookbook
Expand Down
36 changes: 24 additions & 12 deletions test/smoke/default/default_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,53 @@
it { should exist }
it { should be_file }
its('content') { should match(%r{# To manually add resources to the bashrc, create a file in the \~\/\.bashrc\.d folder and add your changes there\.}) }
its('mode') { should cmp '0640' }
its('mode') { should cmp '0770' }
its('owner') { should eq 'root' }
its('group') { should eq 'root' }
end

describe file('/etc/skel/.bashrc.d') do
it { should exist }
it { should be_directory }
its('mode') { should cmp '0640' }
its('mode') { should cmp '0770' }
its('owner') { should eq 'root' }
its('group') { should eq 'root' }
end

describe file('/etc/skel/.bashrc.d/000-init') do
it { should exist }
it { should be_file }
its('content') { should match(%r{# \~\/\.bashrc: executed by bash\(1\) for non-login shells\.}) }
its('mode') { should cmp '0640' }
its('mode') { should cmp '0770' }
its('owner') { should eq 'root' }
its('group') { should eq 'root' }
end

describe file('/etc/skel/.bashrc.d/100-content') do
it { should exist }
it { should be_file }
its('content') { should match('just some test') }
its('mode') { should cmp '0640' }
its('mode') { should cmp '0770' }
its('owner') { should eq 'root' }
its('group') { should eq 'root' }
end

describe file('/etc/skel/.bashrc.d/200-file') do
it { should exist }
it { should be_file }
its('content') { should match('just some test file') }
its('mode') { should cmp '0640' }
its('mode') { should cmp '0770' }
its('owner') { should eq 'root' }
its('group') { should eq 'root' }
end

describe file('/etc/skel/.bashrc.d/300-template') do
it { should exist }
it { should be_file }
its('content') { should match('just some test template') }
its('mode') { should cmp '0640' }
its('mode') { should cmp '0770' }
its('owner') { should eq 'root' }
its('group') { should eq 'root' }
end
describe file('/etc/skel/.bashrc.d/400-content') do
it { should_not exist }
Expand All @@ -70,47 +76,53 @@
it { should exist }
it { should be_file }
its('content') { should match(%r{# To manually add resources to the bashrc, create a file in the \~\/\.bashrc\.d folder and add your changes there\.}) }
its('mode') { should cmp '0640' }
its('mode') { should cmp '0770' }
its('owner') { should eq 'user1' }
its('group') { should eq 'user1' }
end

describe file('/home/user1/.bashrc.d') do
it { should exist }
it { should be_directory }
its('mode') { should cmp '0640' }
its('mode') { should cmp '0770' }
its('owner') { should eq 'user1' }
its('group') { should eq 'user1' }
end

describe file('/home/user1/.bashrc.d/000-init') do
it { should exist }
it { should be_file }
its('content') { should match(%r{# \~\/\.bashrc: executed by bash\(1\) for non-login shells\.}) }
its('mode') { should cmp '0640' }
its('mode') { should cmp '0770' }
its('owner') { should eq 'user1' }
its('group') { should eq 'user1' }
end

describe file('/home/user1/.bashrc.d/100-content') do
it { should exist }
it { should be_file }
its('content') { should match('just some test') }
its('mode') { should cmp '0640' }
its('mode') { should cmp '0770' }
its('owner') { should eq 'user1' }
its('group') { should eq 'user1' }
end

describe file('/home/user1/.bashrc.d/200-file') do
it { should exist }
it { should be_file }
its('content') { should match('just some test file') }
its('mode') { should cmp '0640' }
its('mode') { should cmp '0770' }
its('owner') { should eq 'user1' }
its('group') { should eq 'user1' }
end

describe file('/home/user1/.bashrc.d/300-template') do
it { should exist }
it { should be_file }
its('content') { should match('just some test template') }
its('mode') { should cmp '0640' }
its('mode') { should cmp '0770' }
its('owner') { should eq 'user1' }
its('group') { should eq 'user1' }
end
describe file('/home/user1/.bashrc.d/400-content') do
it { should_not exist }
Expand Down