diff --git a/files/otel/grafana.gpg b/files/apt/grafana.gpg similarity index 100% rename from files/otel/grafana.gpg rename to files/apt/grafana.gpg diff --git a/manifests/apt/repo_grafana.pp b/manifests/apt/repo_grafana.pp new file mode 100644 index 000000000..696b5d04b --- /dev/null +++ b/manifests/apt/repo_grafana.pp @@ -0,0 +1,22 @@ +# Expose the grafana apt repo. +# E.g used for alloy and grafana +define sunet::apt::repo_grafana ( +) { + file { '/etc/apt/keyrings' : + ensure => 'directory', + mode => '0644', + group => 'root' + } + file { '/etc/apt/keyrings/grafana.gpg' : + ensure => 'file', + mode => '0644', + group => 'root', + content => file( 'sunet/apt/grafana.gpg' ), + } + file { '/etc/apt/sources.list.d/grafana.list' : + ensure => 'file', + mode => '0644', + group => 'root', + content => 'deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main', + } +} diff --git a/manifests/otel/alloy.pp b/manifests/otel/alloy.pp index c9423537c..8b3ad7269 100644 --- a/manifests/otel/alloy.pp +++ b/manifests/otel/alloy.pp @@ -3,26 +3,9 @@ class sunet::otel::alloy ( String $otel_receiver = undef, ) { - file { '/etc/apt/keyrings' : - ensure => 'directory', - notify => Service['alloy'], - mode => '0644', - group => 'root' - } - file { '/etc/apt/keyrings/grafana.gpg' : - ensure => 'file', - notify => Service['alloy'], - mode => '0644', - group => 'root', - content => file( 'sunet/otel/grafana.gpg' ), - } - file { '/etc/apt/sources.list.d/grafana.list' : - ensure => 'file', - notify => Service['alloy'], - mode => '0644', - group => 'root', - content => 'deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main', - } + + ensure_resource('sunet::apt::repo_grafana', 'sunet-otel-alloy-grafana-repo') + exec { 'alloy_update': command => 'apt update', unless => 'dpkg -l alloy',