Skip to content

Commit f785418

Browse files
committed
allow to run service without root privileges
1 parent 101de4d commit f785418

File tree

6 files changed

+34
-6
lines changed

6 files changed

+34
-6
lines changed

manifests/config.pp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
file { $orchestrator::config:
77
ensure => file,
8-
owner => 0,
9-
group => 0,
10-
mode => '0644',
8+
owner => $orchestrator::service_user,
9+
group => $orchestrator::service_group,
10+
mode => '0640',
1111
content => template($orchestrator::config_template),
1212
}
1313
}

manifests/init.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
# if true module willl manage service
2525
# @param service_name
2626
# service name to manage. Default 'orchestrator'
27+
# @param service_user
28+
# user to own the service. Default 'root'
29+
# @param service_group
30+
# group to own the service. Default 'root'
2731
class orchestrator (
2832
String $config = $orchestrator::params::config,
2933
Hash[String[1], Any] $config_defaults = $orchestrator::params::config_defaults,
@@ -37,6 +41,8 @@
3741
String $service_ensure = $orchestrator::params::service_ensure,
3842
Boolean $service_manage = $orchestrator::params::service_manage,
3943
String $service_name = $orchestrator::params::service_name,
44+
String $service_user = $orchestrator::params::service_user,
45+
String $service_group = $orchestrator::params::service_group,
4046
) inherits orchestrator::params {
4147
validate_absolute_path($config)
4248
validate_string($config_template)

manifests/my_cnf.pp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33
$cnf_erb = 'orchestrator/orchestrator.cnf.erb'
44

55
file { $orchestrator::topology_cnf:
6+
ensure => file,
7+
owner => $orchestrator::service_user,
8+
group => $orchestrator::service_group,
9+
mode => '0640',
610
content => template($cnf_erb),
7-
mode => '0644',
811
}
912
file { $orchestrator::srv_cnf:
13+
ensure => file,
14+
owner => $orchestrator::service_user,
15+
group => $orchestrator::service_group,
16+
mode => '0640',
1017
content => template($cnf_erb),
11-
mode => '0644',
1218
}
1319
}

manifests/params.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
$service_ensure = 'running'
1111
$service_manage = true
1212
$service_name = 'orchestrator'
13+
$service_user = 'root'
14+
$service_group = 'root'
1315
$srv_cnf = '/etc/orchestrator_srv.cnf'
1416
$topology_cnf = '/etc/orchestrator.cnf'
1517

manifests/service.pp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@
55
}
66

77
if $orchestrator::service_manage == true {
8+
if 'systemd' in $facts['init_systems'] {
9+
include systemd
10+
11+
systemd::manage_dropin { '10_user.conf':
12+
ensure => 'present',
13+
unit => 'orchestrator.service',
14+
service_entry => {
15+
'User' => $orchestrator::service_user,
16+
'Group' => $orchestrator::service_group,
17+
},
18+
}
19+
}
20+
821
service { 'orchestrator':
922
ensure => $orchestrator::service_ensure,
1023
enable => $orchestrator::service_enable,

metadata.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
],
5858
"dependencies": [
5959
{ "name": "puppetlabs/stdlib", "version_requirement": ">= 3.2.0 <5.0.0" },
60-
{ "name": "computology/packagecloud", "version_requirement": ">= 0.2.0" }
60+
{ "name": "computology/packagecloud", "version_requirement": ">= 0.2.0" },
61+
{ "name": "voxpupuli/systemd", "version_requirement": ">= 4.1.0" }
6162
]
6263
}

0 commit comments

Comments
 (0)