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

Enhanced acl policy files with rundeck::config::aclpolicyfile #76

Merged
merged 1 commit into from
May 23, 2015
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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ A hash of the rundeck security configuration.
#####`manage_yum_repo`
Whether to manage the YUM repository containing the Rundeck rpm. Defaults to true.

####Define: `aclpolicyfile`
A definition for creating custom acl policy files

#####`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.

####Define: `rundeck::plugin`
A definition for installing rundeck plugins

Expand Down Expand Up @@ -226,6 +241,7 @@ The group permission that rundeck is installed as.

###Defines
####Public Defines
* [`rundeck::config::aclpolicyfile`](#define-aclpolicyfile): Manages a acl policy file
* [`rundeck::config::plugin`](#define-rundeckplugin): Manages the installation of rundeck plugins
* [`rundeck::config::project`](#define-rundeckproject): Manages the configuration of rundeck projects
* [`rundeck::config::resource_source`](#define-resourcesource): Manages resource sources for each project
Expand Down
16 changes: 4 additions & 12 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,12 @@
require => File[$properties_dir]
}

file { "${properties_dir}/admin.aclpolicy":
owner => $user,
group => $group,
mode => '0640',
content => template($rundeck::acl_template),
require => File[$properties_dir]
rundeck::config::aclpolicyfile { 'admin':
acl_policies => $acl_policies,
}

file { "${properties_dir}/apitoken.aclpolicy":
owner => $user,
group => $group,
mode => '0640',
content => template('rundeck/apitoken.aclpolicy.erb'),
require => File[$properties_dir]
rundeck::config::aclpolicyfile { 'apitoken':
acl_policies => $api_policies,
}

file { "${properties_dir}/profile":
Expand Down
81 changes: 81 additions & 0 deletions manifests/config/aclpolicyfile.pp
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'],
Copy link
Contributor

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 in rundeck::config, which merges the framework_config parameter from rundeck and rundeck::params::framework_config. I haven't had time to test if just inserting config:: is sufficient or not.

) {

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],
}
}
4 changes: 2 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
$auth_users = {}
$auth_template = 'rundeck/jaas-auth.conf.erb'

$acl_template = 'rundeck/admin.aclpolicy.erb'
$api_template = 'rundeck/apitoken.aclpolicy.erb'
$acl_template = 'rundeck/aclpolicy.erb'
$api_template = 'rundeck/aclpolicy.erb'

$acl_policies = [
{
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
end


it { should contain_file('/etc/rundeck/admin.aclpolicy') }
it { should contain_file('/etc/rundeck/apitoken.aclpolicy') }
it { should contain_rundeck__config__aclpolicyfile('admin') }
it { should contain_rundeck__config__aclpolicyfile('apitoken') }

end
end
Expand Down
50 changes: 50 additions & 0 deletions spec/defines/config/aclpolicyfile_spec.rb
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

4 changes: 2 additions & 2 deletions templates/apitoken.aclpolicy.erb → templates/aclpolicy.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%- @api_policies.each_with_index do |policy, index| -%>
<%- @acl_policies.each_with_index do |policy, index| -%>
description: <%= policy['description'] %>
context:
<%= policy['context']['type'] %>: '<%= policy['context']['rule'] %>'
Expand Down Expand Up @@ -31,7 +31,7 @@ by:
- '<%= username %>'
<%- end -%>
<%- end -%>
<%- if index != (@api_policies.length-1) -%>
<%- if index != (@acl_policies.length-1) -%>

---

Expand Down
30 changes: 0 additions & 30 deletions templates/admin.aclpolicy.erb

This file was deleted.