Skip to content

Commit 75147b5

Browse files
author
deepakt7340
committed
fix the bug for common::service::systemd
1 parent d298e3f commit 75147b5

File tree

20 files changed

+518
-397
lines changed

20 files changed

+518
-397
lines changed

modules/enableit/common/manifests/backup/borg.pp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,26 @@
9999
authorized_keys => $authorized_keys,
100100
}
101101
} else {
102-
## services
103-
common::services::systemd { 'obmondo-backup-borg@.service':
104-
ensure => false,
102+
## Define the Templated Borg Backup Service
103+
$_borg_backup_content = @("EOT"/)
104+
[Unit]
105+
Description=Obmondo borg backup
106+
107+
[Service]
108+
Type=oneshot
109+
ExecStart=/bin/bash ${__dir}/repo_%i.sh run
110+
ExecStartPost=/bin/bash ${__dir}/repo_%i.sh check_icinga
111+
TimeoutSec=3600
112+
113+
[Install]
114+
WantedBy=default.target
115+
| EOT
116+
117+
systemd::unit_file { 'obmondo-backup-borg@.service':
118+
ensure => 'absent',
105119
enable => false,
106-
unit => {
107-
'Description' => 'Obmondo borg backup',
108-
},
109-
service => {
110-
'Type' => 'oneshot',
111-
'ExecStart' => "/bin/bash ${__dir}/repo_%i.sh run",
112-
'ExecStartPost' => "/bin/bash ${__dir}/repo_%i.sh check_icinga",
113-
'TimeoutSec' => 3600,
114-
},
115-
install => {
116-
'WantedBy' => 'default.target',
117-
},
120+
active => false,
121+
content => $_borg_backup_content,
118122
}
119123
$repos.each |$k, $v| {
120124
common::backup::borg::push { $k:

modules/enableit/common/manifests/backup/borg/push.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
env_vars => {
4141
'BORG_RSH' => "ssh -i ${_ssh_key_file} -o BatchMode=yes",
4242
},
43-
crontab_define => 'common::services::systemd',
43+
crontab_define => 'systemd::unit_file',
4444
crontabs => {
4545
"obmondo-backup-borg@${_reponame}.timer" => {
4646
ensure => true, #lint:ignore:ensure_first_param

modules/enableit/common/manifests/backup/db/mysql.pp

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -74,38 +74,49 @@
7474
dump_dir => $dump_dir,
7575
}),
7676
}
77-
common::services::systemd { 'mysql-backup.timer':
78-
ensure => true,
79-
enable => true,
80-
timer => {
81-
'OnCalendar' => systemd_make_timespec({
82-
'year' => '*',
83-
'month' => '*',
84-
'day' => '*',
85-
'hour' => $backup_hour,
86-
'minute' => 0,
87-
'second' => 0,
88-
}),
89-
'Unit' => 'mysql-backup.service',
90-
},
91-
unit => {
92-
'Requires' => 'mysql-backup.service',
93-
},
94-
install => {
95-
'WantedBy' => 'timers.target',
96-
},
77+
# Define the MySQL Backup Service
78+
$_mysql_service_content = @("EOT"/)
79+
[Unit]
80+
Description=MySQL Backup Service
81+
Wants=mysql-backup.timer
82+
83+
[Service]
84+
Type=oneshot
85+
ExecStart=/bin/sh -c '/opt/obmondo/bin/mysqlbackup.sh'
86+
87+
[Install]
88+
WantedBy=multi-user.target
89+
| EOT
90+
91+
systemd::unit_file { 'mysql-backup.service':
92+
ensure => 'present',
93+
content => $_mysql_service_content,
9794
require => File['/opt/obmondo/bin/mysqlbackup.sh'],
9895
}
99-
common::services::systemd { 'mysql-backup.service':
96+
97+
# Define the MySQL Backup Timer
98+
$_mysql_timer_content = @("EOT"/)
99+
[Unit]
100+
Description=Run MySQL Backup daily at ${backup_hour}:00
101+
Requires=mysql-backup.service
102+
103+
[Timer]
104+
OnCalendar=*-*-* ${backup_hour}:00:00
105+
Unit=mysql-backup.service
106+
107+
[Install]
108+
WantedBy=timers.target
109+
| EOT
110+
111+
systemd::unit_file { 'mysql-backup.timer':
100112
ensure => 'present',
101-
unit => {
102-
'Wants' => 'mysql-backup.timer',
103-
},
104-
service => {
105-
'Type' => 'oneshot',
106-
'ExecStart' => "/bin/sh -c '/opt/obmondo/bin/mysqlbackup.sh'",
107-
},
108-
require => File['/opt/obmondo/bin/mysqlbackup.sh'],
113+
enable => true,
114+
active => true,
115+
content => $_mysql_timer_content,
116+
require => [
117+
File['/opt/obmondo/bin/mysqlbackup.sh'],
118+
Systemd::Unit_file['mysql-backup.service'],
119+
],
109120
}
110121
}
111122
}

modules/enableit/common/manifests/network/tcpshaker.pp

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,27 @@
4848
noop => $noop_value,
4949
}
5050

51-
common::services::systemd { 'tcpshaker.service':
52-
ensure => $enable,
53-
enable => $enable,
54-
noop_value => $noop_value,
55-
unit => {
56-
'Description' => 'TCP Shaker Daemon Mode',
57-
},
58-
service => {
59-
'Type' => 'simple',
60-
'ExecStart' => "/opt/obmondo/bin/tcp_shaker -d -f ${config_location} -n ${requests_per_check} -c ${concurrency}",
61-
},
62-
require => [
51+
# Define the TCP Shaker Service content
52+
$_tcpshaker_content = @("EOT"/)
53+
[Unit]
54+
Description=TCP Shaker Daemon Mode
55+
56+
[Service]
57+
Type=simple
58+
ExecStart=/opt/obmondo/bin/tcp_shaker -d -f ${config_location} -n ${requests_per_check} -c ${concurrency}
59+
60+
[Install]
61+
WantedBy=multi-user.target
62+
| EOT
63+
64+
# Deploy the systemd unit file
65+
systemd::unit_file { 'tcpshaker.service':
66+
ensure => $enable ? { true => 'present', default => 'absent' },
67+
enable => $enable,
68+
active => $enable,
69+
content => $_tcpshaker_content,
70+
noop => $noop_value,
71+
require => [
6372
Package[$package_name],
6473
File[$config_location],
6574
],

modules/enableit/common/manifests/software.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@
7171
}
7272

7373
if lookup('common::software::openvmtools::manage', Boolean, undef, false) {
74-
include common::software::opemvmtools
74+
include common::software::openvmtools
7575
}
7676

7777
if lookup('common::software::nivisa::manage', Boolean, undef, false) {
78-
include common::software::opemvmtools
78+
include common::software::openvmtools
7979
}
8080
}

modules/enableit/common/manifests/system/updates.pp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@
6161
},
6262
]): ensure => 'absent', }
6363

64-
common::services::systemd { 'yum-system-upgrade.service':
65-
ensure => 'absent',
64+
# Ensure the service is stopped and disabled
65+
service { 'yum-system-upgrade.service':
66+
ensure => 'stopped',
67+
enable => false,
6668
}
6769

6870
package { 'obmondo-system-update':

modules/enableit/lxd/manifests/init.pp

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,40 @@
135135
# Make lxd-containers depend on the required filesystems, if any. Filesystems
136136
# refer to devices instantiated with our own services. These are named
137137
# `disk@%i.service`.
138-
$_service_units = $requires_filesystems.reduce([]) |$acc, $name| {
138+
# Generate the list of systemd service names for the dependencies
139+
$_dep_list = $requires_filesystems.map |$name| {
139140
$filesystem = $_filesystems[$name]
140-
141-
unless $filesystem {
142-
fail("Required filesystem '${name}' is not defined.")
143-
}
144-
145-
$_service = "${filesystem['type']}-mount-${name}.service"
146-
147-
$acc + [
148-
{'After' => $_service},
149-
{'BindsTo' => $_service},
150-
]
141+
if !$filesystem { fail("Required filesystem '${name}' is not defined.") }
142+
"${filesystem['type']}-mount-${name}.service"
151143
}
152144

153-
common::services::systemd { 'lxd-containers.service':
154-
override => true,
155-
unit => flatten($_service_units),
145+
# Join them into space-separated strings for the systemd unit file
146+
$_after_deps = join($_dep_list, ' ')
147+
$_bindsto_deps = join($_dep_list, ' ')
148+
149+
# Define the full service content
150+
$_service_content = @("EOT"/)
151+
# THIS FILE IS MANAGED BY LINUXAID. CHANGES WILL BE LOST.
152+
[Unit]
153+
Description=LXD - Container Management Service
154+
After=network.target syslog.target ${_after_deps}
155+
BindsTo=${_bindsto_deps}
156+
157+
[Service]
158+
Type=simple
159+
ExecStart=/usr/bin/lxd --group lxd --debug
160+
Restart=on-failure
161+
KillMode=process
162+
163+
[Install]
164+
WantedBy=multi-user.target
165+
| EOT
166+
167+
# Use systemd::unit_file to manage the service
168+
systemd::unit_file { 'lxd-containers.service':
169+
ensure => 'present',
170+
enable => true,
171+
active => true,
172+
content => $_service_content,
156173
}
157-
158-
159174
}

modules/enableit/profile/manifests/collector/splunk/forwarder.pp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@
8383
} else {
8484

8585
if $facts['init_system'] == 'systemd' {
86-
common::services::systemd { 'SplunkForwarder.service':
87-
ensure => 'absent',
88-
enable => false,
89-
noop_value => $noop_value,
86+
# Ensure the SplunkForwarder service is stopped and disabled
87+
service { 'SplunkForwarder.service':
88+
ensure => 'stopped',
89+
enable => false,
90+
noop => $noop_value,
9091
}
9192
}
9293

modules/enableit/profile/manifests/package_management/guix.pp

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -105,29 +105,34 @@
105105
require => File['/var/guix'],
106106
}
107107

108-
common::services::systemd { 'guix-daemon.service':
109-
unit => {
110-
'Description' => 'Build daemon for GNU Guix',
111-
},
112-
service => {
113-
'EnvironmentFile' => '-/etc/default/guix-daemon',
114-
'Environment' => 'GUIX_LOCPATH=/root/.guix-profile/lib/locale',
115-
'ExecStart' => '/var/guix/profiles/per-user/root/guix-profile/bin/guix-daemon --build-users-group=guixbuild --listen=0.0.0.0 --listen=/var/guix/daemon-socket/socket', #lint:ignore:140chars
116-
'RemainAfterExit' => 'yes',
117-
'StandardOutput' => 'syslog',
118-
'StandardError' => 'syslog',
119-
'Restart' => 'always',
120-
'RestartSec' => '2m',
121-
# See
122-
# <https://lists.gnu.org/archive/html/guix-devel/2016-04/msg00608.html>.
123-
# Some package builds (for example, go@1.8.1) may require even more than
124-
# 1024 tasks.
125-
'TasksMax' => '8192',
126-
},
127-
install => {
128-
'WantedBy' => 'multi-user.target',
129-
},
108+
# Define the GNU Guix Build Daemon content
109+
$_guix_daemon_content = @("EOT"/)
110+
[Unit]
111+
Description=Build daemon for GNU Guix
112+
113+
[Service]
114+
EnvironmentFile=-/etc/default/guix-daemon
115+
Environment=GUIX_LOCPATH=/root/.guix-profile/lib/locale
116+
ExecStart=/var/guix/profiles/per-user/root/guix-profile/bin/guix-daemon --build-users-group=guixbuild --listen=0.0.0.0 --listen=/var/guix/daemon-socket/socket
117+
RemainAfterExit=yes
118+
StandardOutput=syslog
119+
StandardError=syslog
120+
Restart=always
121+
RestartSec=2m
122+
# See <https://lists.gnu.org/archive/html/guix-devel/2016-04/msg00608.html>.
123+
# Some package builds may require more than 1024 tasks.
124+
TasksMax=8192
125+
126+
[Install]
127+
WantedBy=multi-user.target
128+
| EOT
129+
130+
# Deploy the unit file and manage the service
131+
systemd::unit_file { 'guix-daemon.service':
132+
ensure => 'present',
133+
enable => true,
134+
active => true,
135+
content => $_guix_daemon_content,
130136
require => User[$_guix_builder_users],
131137
}
132-
133138
}

0 commit comments

Comments
 (0)