Skip to content

Commit 4ea5cf8

Browse files
Bastian Schmidtekohl
andcommitted
Add parameter autosign_key_file and Salt Master configuration
* Add parameter autosign_key_file * Add docs for autosign_key_file * Add Salt Master configuration Co-authored-by: Ewoud Kohl van Wijngaarden <[email protected]>
1 parent 574a320 commit 4ea5cf8

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed

manifests/plugin/salt.pp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#
77
# $autosign_file:: File to use for salt autosign
88
#
9+
# $autosign_key_file:: File to use for salt autosign via grains
10+
#
911
# $user:: User to run salt commands under
1012
#
1113
# $api:: Use Salt API
@@ -28,6 +30,7 @@
2830
#
2931
class foreman_proxy::plugin::salt (
3032
Stdlib::Absolutepath $autosign_file = $foreman_proxy::plugin::salt::params::autosign_file,
33+
Stdlib::Absolutepath $autosign_key_file = $foreman_proxy::plugin::salt::params::autosign_key_file,
3134
Boolean $enabled = $foreman_proxy::plugin::salt::params::enabled,
3235
Foreman_proxy::ListenOn $listen_on = $foreman_proxy::plugin::salt::params::listen_on,
3336
String $user = $foreman_proxy::plugin::salt::params::user,
@@ -38,8 +41,23 @@
3841
String $api_password = $foreman_proxy::plugin::salt::params::api_password,
3942
Optional[Stdlib::Absolutepath] $saltfile = $foreman_proxy::plugin::salt::params::saltfile,
4043
) inherits foreman_proxy::plugin::salt::params {
44+
$foreman_ssl_cert = pick($foreman_proxy::foreman_ssl_cert, $foreman_proxy::ssl_cert)
45+
$foreman_ssl_key = pick($foreman_proxy::foreman_ssl_key, $foreman_proxy::ssl_key)
46+
$reactor_path = '/usr/share/foreman-proxy/salt/reactors'
47+
4148
foreman_proxy::plugin::module { 'salt':
4249
enabled => $enabled,
4350
listen_on => $listen_on,
4451
}
52+
53+
file {"${foreman_proxy::etc}/salt/master.d":
54+
ensure => directory,
55+
mode => '0755',
56+
}
57+
file {"${foreman_proxy::etc}/salt/master.d/foreman.conf":
58+
ensure => file,
59+
content => template('foreman_proxy/plugin/salt_master.conf.erb'),
60+
owner => 'root',
61+
mode => '0640',
62+
}
4563
}

manifests/plugin/salt/params.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
$enabled = true
77
$listen_on = 'https'
88
$autosign_file = "${foreman_proxy::params::etc}/salt/autosign.conf"
9+
$autosign_grains_dir = '/var/lib/foreman-proxy/salt/grains'
10+
$autosign_key_file = "${autosign_grains_dir}/autosign_key"
911
$user = 'root'
1012

1113
$api = false

spec/classes/foreman_proxy__plugin__salt_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
let :params do {
2525
:user => 'example',
2626
:autosign_file => '/etc/salt/example.conf',
27+
:autosign_key_file => '/var/lib/foreman-proxy/salt/grains/autosign_key',
2728
:api => true,
2829
:api_url => 'http://foreman.example.com',
2930
:api_auth => 'ldap',
@@ -36,6 +37,7 @@
3637
should contain_file('/etc/foreman-proxy/settings.d/salt.yml').
3738
with_content(%r{:salt_command_user: example}).
3839
with_content(%r{:autosign_file: /etc/salt/example.conf}).
40+
with_content(%r{:autosign_key_file: /var/lib/foreman-proxy/salt/grains/autosign_key}).
3941
with_content(%r{:use_api: true}).
4042
with_content(%r{:api_url: http://foreman.example.com}).
4143
with_content(%r{:api_auth: ldap}).

templates/plugin/salt.yml.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
:enabled: <%= @module_enabled %>
33
:autosign_file: <%= scope.lookupvar('::foreman_proxy::plugin::salt::autosign_file') %>
4+
:autosign_key_file: <%= scope.lookupvar('::foreman_proxy::plugin::salt::autosign_key_file') %>
45
:salt_command_user: <%= scope.lookupvar('::foreman_proxy::plugin::salt::user') %>
56
# Some features require using the Salt API - such as listing environments and retrieving state info
67
:use_api: <%= scope.lookupvar('::foreman_proxy::plugin::salt::api') %>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# /etc/salt/master.d/foreman.config Master configuration
2+
#
3+
# This file summarizes configurations for the salt-master.
4+
# Have a look at the [Foreman Salt Plugin Documentation](https://theforeman.org/plugins/foreman_salt/) for detailed explanations.
5+
#
6+
# After editing this file, run the following command to active the changes:
7+
# systemctl restart salt-master
8+
9+
10+
##
11+
# Autosign
12+
autosign_grains_dir: <%= scope.lookupvar('foreman_proxy::plugin::salt::autosign_grains_dir') %>
13+
autosign_file: <%= scope.lookupvar('foreman_proxy::plugin::salt::autosign_file') %>
14+
# Uncomment the next line to make use of the autosign host name file (not recommended)
15+
# permissive_pki_access: True
16+
17+
18+
##
19+
# Node classifier
20+
master_tops:
21+
ext_nodes: /usr/bin/foreman-node
22+
23+
24+
##
25+
# Pillar data access
26+
ext_pillar:
27+
- puppet: /usr/bin/foreman-node
28+
29+
30+
##
31+
# Salt API access
32+
external_auth:
33+
<%= scope.lookupvar('foreman_proxy::plugin::salt::api_auth') %>:
34+
<%= scope.lookupvar('foreman_proxy::plugin::salt::api_username') %>:
35+
- '@runner'
36+
37+
rest_cherrypy:
38+
port: 9191
39+
ssl_key: <%= @foreman_ssl_key %>
40+
ssl_crt: <%= @foreman_ssl_cert %>
41+
42+
43+
##
44+
# Remote execution provider
45+
publisher_acl:
46+
foreman-proxy:
47+
- state.template_str
48+
49+
50+
##
51+
# Reactors
52+
reactor:
53+
- 'salt/auth': # Autosign reactor
54+
- <%= @reactor_path %>/foreman_minion_auth.sls
55+
- 'salt/job/*/ret/*': # Report reactor
56+
- <%= @reactor_path %>/foreman_report_upload.sls

0 commit comments

Comments
 (0)