Skip to content

Commit 66a4e47

Browse files
committed
restructure the module a bit so that the order of execution clear
should also prevent issues with apt::update being scheduled after we try to install the package
1 parent 9993886 commit 66a4e47

File tree

4 files changed

+43
-16
lines changed

4 files changed

+43
-16
lines changed

manifests/config.pp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# @summary Configure the Alloy service
2+
#
3+
# @api private
4+
class grafana_alloy::config (
5+
Optional[String[1]] $config = undef,
6+
) {
7+
assert_private()
8+
9+
if $config {
10+
file { '/etc/alloy/config.alloy':
11+
content => $config,
12+
mode => '0640',
13+
owner => 'root',
14+
group => 'alloy',
15+
}
16+
}
17+
}

manifests/init.pp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,14 @@
55
class grafana_alloy (
66
Optional[String[1]] $config = undef,
77
) {
8-
require grafana_alloy::repo
9-
package { 'alloy': }
8+
contain grafana_alloy::repo
9+
contain grafana_alloy::install
1010

11-
if $config {
12-
file { '/etc/alloy/config.alloy':
13-
content => $config,
14-
mode => '0640',
15-
owner => 'root',
16-
group => 'alloy',
17-
require => Package['alloy'],
18-
notify => Service['alloy'],
19-
}
11+
class { 'grafana_alloy::config':
12+
config => $config,
2013
}
2114

22-
service { 'alloy':
23-
ensure => 'running',
24-
enable => true,
25-
require => Package['alloy'],
26-
}
15+
contain grafana_alloy::service
16+
17+
Class['grafana_alloy::repo'] -> Class['grafana_alloy::install'] -> Class['grafana_alloy::config'] ~> Class['grafana_alloy::service']
2718
}

manifests/install.pp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# @summary Install the Alloy package
2+
#
3+
# @api private
4+
class grafana_alloy::install () {
5+
assert_private()
6+
7+
package { 'alloy': }
8+
}

manifests/service.pp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# @summary Manage the Alloy service
2+
#
3+
# @api private
4+
class grafana_alloy::service () {
5+
assert_private()
6+
7+
service { 'alloy':
8+
ensure => 'running',
9+
enable => true,
10+
}
11+
}

0 commit comments

Comments
 (0)