Skip to content

Commit 6ec9558

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 32de4bd commit 6ec9558

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

manifests/plugin/salt.pp

Lines changed: 3 additions & 0 deletions
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)

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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
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_content(%r{autosign_grains_dir: /var/lib/foreman-proxy/salt/grains}).
25+
with_content(%r{autosign_file: /etc/salt/autosign.conf}).
26+
with_content(%r{user: root}).
27+
with_content(%r{netapi_enable_clients:\n - runner}).
28+
with_content(%r{external_auth:\n pam:\n saltuser:\n - '@runner'})
29+
end
2130
end
2231

2332
describe 'with overwritten parameters' do
@@ -30,6 +39,7 @@
3039
:api_auth => 'ldap',
3140
:api_username => 'saltapi',
3241
:api_password => 'letmein',
42+
:api_interfaces => ['runner', 'local', 'ssh', 'wheel'],
3343
:saltfile => '/etc/salt/Saltfile',
3444
} end
3545

@@ -45,6 +55,15 @@
4555
with_content(%r{:api_password: letmein}).
4656
with_content(%r{:saltfile: /etc/salt/Saltfile})
4757
end
58+
59+
it 'should change master.d/foreman.conf parameters' do
60+
should contain_file('/etc/salt/master.d/foreman.conf').
61+
with_content(%r{user: example}).
62+
with_content(%r{autosign_grains_dir: /var/lib/foreman-proxy/salt/grains}).
63+
with_content(%r{autosign_file: /etc/salt/example.conf}).
64+
with_content(%r{netapi_enable_clients:\n - runner\n - local\n - ssh\n - wheel}).
65+
with_content(%r{external_auth:\n ldap:\n saltuser:\n - '@runner'})
66+
end
4867
end
4968
end
5069
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)