-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
Enhanced acl policy files with rundeck::config::aclpolicyfile #76
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Author:: Johannes Graf (mailto:graf@synyx.de) | ||
# Copyright:: Copyright (c) 2015 synyx GmbH & Co. KG | ||
# License:: MIT | ||
|
||
# == Define rundeck::config::aclpolicyfile | ||
# | ||
# Use this define to create a custom acl policy file | ||
# | ||
# === Parameters | ||
# | ||
# [*acl_policies*] | ||
# An array containing acl policies. See rundeck::params::acl_policies / rundeck::params::api_policies as an example. | ||
# | ||
# [*$owner*] | ||
# The user that rundeck is installed as. | ||
# | ||
# [*$group*] | ||
# The group permission that rundeck is installed as. | ||
# | ||
# [*$properties_dir*] | ||
# The rundeck configuration directory. | ||
# | ||
# === Examples | ||
# | ||
# Create the admin.aclpolicy file: | ||
# | ||
# rundeck::config::aclpolicyfile { 'myPolicyFile': | ||
# acl_policies => [ | ||
# { | ||
# 'description' => 'Admin, all access', | ||
# 'context' => { | ||
# 'type' => 'project', | ||
# 'rule' => '.*' | ||
# }, | ||
# 'resource_types' => [ | ||
# { 'type' => 'resource', 'rules' => [{ 'name' => 'allow','rule' => '*' }] }, | ||
# { 'type' => 'adhoc', 'rules' => [{ 'name' => 'allow','rule' => '*' }] }, | ||
# { 'type' => 'job', 'rules' => [{ 'name' => 'allow','rule' => '*' }] }, | ||
# { 'type' => 'node', 'rules' => [{ 'name' => 'allow','rule' => '*' }] } | ||
# ], | ||
# 'by' => { | ||
# 'groups' => ['admin'], | ||
# 'usernames' => undef | ||
# } | ||
# }, | ||
# { | ||
# 'description' => 'Admin, all access', | ||
# 'context' => { | ||
# 'type' => 'application', | ||
# 'rule' => 'rundeck' | ||
# }, | ||
# 'resource_types' => [ | ||
# { 'type' => 'resource', 'rules' => [{ 'name' => 'allow','rule' => '*' }] }, | ||
# { 'type' => 'project', 'rules' => [{ 'name' => 'allow','rule' => '*' }] }, | ||
# { 'type' => 'storage', 'rules' => [{ 'name' => 'allow','rule' => '*' }] }, | ||
# ], | ||
# 'by' => { | ||
# 'groups' => ['admin'], | ||
# 'usernames' => undef | ||
# } | ||
# } | ||
# ], | ||
# } | ||
# | ||
define rundeck::config::aclpolicyfile( | ||
$acl_policies, | ||
$owner = $rundeck::user, | ||
$group = $rundeck::group, | ||
$properties_dir = $rundeck::framework_config['framework.etc.dir'], | ||
) { | ||
|
||
validate_array($acl_policies) | ||
|
||
file { "${properties_dir}/${name}.aclpolicy": | ||
owner => $owner, | ||
group => $group, | ||
mode => '0640', | ||
content => template("${module_name}/aclpolicy.erb"), | ||
require => File[$properties_dir], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require 'spec_helper' | ||
|
||
describe 'rundeck::config::aclpolicyfile', :type => :define do | ||
|
||
let(:title) {'myPolicy'} | ||
let(:params) {{ | ||
:acl_policies => | ||
[ | ||
{ | ||
'description' => 'Admin, all access', | ||
'context' => { | ||
'type' => 'project', | ||
'rule' => '.*' | ||
}, | ||
'resource_types' => [ | ||
{ 'type' => 'resource', 'rules' => [{'name' => 'allow','rule' => '*'}] } | ||
], | ||
'by' => { | ||
'groups' => ['admin'], | ||
} | ||
}, | ||
{ | ||
'description' => 'Admin, all access', | ||
'context' => { | ||
'type' => 'application', | ||
'rule' => 'rundeck' | ||
}, | ||
'resource_types' => [ | ||
{ 'type' => 'resource', 'rules' => [{'name' => 'allow','rule' => '*'}] } | ||
], | ||
'by' => { | ||
'groups' => ['admin'], | ||
} | ||
} | ||
], | ||
:properties_dir => '/etc/rundeck', | ||
:owner => 'myUser', | ||
:group => 'myGroup', | ||
}} | ||
|
||
it { should contain_file('/etc/rundeck/myPolicy.aclpolicy').with( | ||
{ | ||
'owner' => 'myUser', | ||
'group' => 'myGroup', | ||
'mode' => '0640', | ||
} | ||
)} | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a problem here in that it misses the
deep_merge
that happens inrundeck::config
, which merges theframework_config
parameter fromrundeck
andrundeck::params::framework_config
. I haven't had time to test if just insertingconfig::
is sufficient or not.