Skip to content

Commit 8482827

Browse files
author
Bastian Schmidt
committed
Fixes #37835 - Add user and netapi to Salt config
* Set user for running Salt Master service due to 3006 changes https://docs.saltproject.io/en/3006/topics/releases/3006.0.html#linux-packaging-salt-master-salt-user-and-group Salt API * Add netapi_enable_clients explicitly due to 3006 changes https://docs.saltproject.io/en/master/topics/netapi/netapi-enable-clients.html#select-client-interfaces-to-enable * Add api_interfaces parameter to enable configuration of API accessibility. However, smart_proxy_salt utilizes only the "runner" API interface.
1 parent 907200b commit 8482827

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

manifests/plugin/salt.pp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#
2323
# $api_password:: Salt API password
2424
#
25+
# $api_interfaces:: Salt API interfaces
26+
#
2527
# $saltfile:: Path to Saltfile
2628
#
2729
# === Advanced parameters:
@@ -42,6 +44,7 @@
4244
String $api_auth = $foreman_proxy::plugin::salt::params::api_auth,
4345
String $api_username = $foreman_proxy::plugin::salt::params::api_username,
4446
String $api_password = $foreman_proxy::plugin::salt::params::api_password,
47+
Array[String] $api_interfaces = $foreman_proxy::plugin::salt::params::api_interfaces,
4548
Optional[Stdlib::Absolutepath] $saltfile = $foreman_proxy::plugin::salt::params::saltfile,
4649
) inherits foreman_proxy::plugin::salt::params {
4750
$foreman_ssl_cert = pick($foreman_proxy::foreman_ssl_cert, $foreman_proxy::ssl_cert)
@@ -55,7 +58,7 @@
5558
~> file { "${foreman_proxy::etc}/salt/master.d/foreman.conf":
5659
ensure => file,
5760
content => template('foreman_proxy/plugin/salt_master.conf.erb'),
58-
owner => 'root',
61+
owner => pick($user, $foreman_proxy::user),
5962
group => pick($group, $foreman_proxy::user),
6063
mode => '0640',
6164
}

manifests/plugin/salt/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
$api_auth = 'pam'
1616
$api_username = 'saltuser'
1717
$api_password = 'saltpassword'
18+
$api_interfaces = ['runner']
1819
$saltfile = undef
1920
}

spec/classes/foreman_proxy__plugin__salt_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818
:content => /:enabled: https/
1919
})
2020
end
21+
22+
it 'should configure master.d/foreman.conf' do
23+
should contain_file('/etc/salt/master.d/foreman.conf').
24+
with_mode('0640').
25+
with_owner('root').
26+
with_group('foreman-proxy').
27+
with_content(%r{user: root}).
28+
with_content(%r{autosign_grains_dir: /var/lib/foreman-proxy/salt/grains}).
29+
with_content(%r{autosign_file: /etc/salt/autosign.conf}).
30+
with_content(%r{netapi_enable_clients:\n - runner}).
31+
with_content(%r{external_auth:\n pam:\n saltuser:\n - '@runner'})
32+
end
2133
end
2234

2335
describe 'with overwritten parameters' do
@@ -30,6 +42,7 @@
3042
:api_auth => 'ldap',
3143
:api_username => 'saltapi',
3244
:api_password => 'letmein',
45+
:api_interfaces => ['runner', 'local', 'ssh', 'wheel'],
3346
:saltfile => '/etc/salt/Saltfile',
3447
} end
3548

@@ -45,6 +58,18 @@
4558
with_content(%r{:api_password: letmein}).
4659
with_content(%r{:saltfile: /etc/salt/Saltfile})
4760
end
61+
62+
it 'should change master.d/foreman.conf parameters' do
63+
should contain_file('/etc/salt/master.d/foreman.conf').
64+
with_mode('0640').
65+
with_owner('example').
66+
with_group('foreman-proxy').
67+
with_content(%r{user: example}).
68+
with_content(%r{autosign_grains_dir: /var/lib/foreman-proxy/salt/grains}).
69+
with_content(%r{autosign_file: /etc/salt/example.conf}).
70+
with_content(%r{netapi_enable_clients:\n - runner\n - local\n - ssh\n - wheel}).
71+
with_content(%r{external_auth:\n ldap:\n saltapi:\n - '@runner'})
72+
end
4873
end
4974
end
5075
end

templates/plugin/salt_master.conf.erb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ autosign_file: <%= scope.lookupvar('foreman_proxy::plugin::salt::autosign_file')
1515
# permissive_pki_access: True
1616

1717

18+
##
19+
# Salt Master service user
20+
user: <%= scope.lookupvar('::foreman_proxy::plugin::salt::user') %>
21+
22+
1823
##
1924
# Node classifier
2025
master_tops:
@@ -39,6 +44,13 @@ rest_cherrypy:
3944
ssl_key: <%= @foreman_ssl_key %>
4045
ssl_crt: <%= @foreman_ssl_cert %>
4146

47+
<% if scope.lookupvar('foreman_proxy::plugin::salt::api_interfaces').any? -%>
48+
netapi_enable_clients:
49+
<%- scope.lookupvar('foreman_proxy::plugin::salt::api_interfaces').each do |api_item| -%>
50+
- <%= api_item %>
51+
<%- end -%>
52+
<% end -%>
53+
4254

4355
##
4456
# Remote execution provider

0 commit comments

Comments
 (0)