Skip to content

Commit

Permalink
Merge pull request voxpupuli#172 from voxpupuli/archlinux
Browse files Browse the repository at this point in the history
Add Archlinux support
  • Loading branch information
bastelfreak authored Mar 17, 2018
2 parents 31775e8 + f829cd3 commit b9e9bf4
Show file tree
Hide file tree
Showing 19 changed files with 71 additions and 23 deletions.
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
$shared_dir = $::prometheus::params::shared_dir,
$arch = $::prometheus::params::arch,
$version = $::prometheus::params::version,
$install_method = $::prometheus::params::install_method,
$install_method = $::prometheus::params::prometheus_install_method,
$os = $::prometheus::params::os,
$download_url = undef,
$download_url_base = $::prometheus::params::download_url_base,
Expand Down
32 changes: 30 additions & 2 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
$alertmanager_user = 'alertmanager'
$alertmanager_version = '0.5.1'
$alerts = {}
$bin_dir = '/usr/local/bin'
$config_dir = '/etc/prometheus'
$config_mode = '0660'
$config_template = 'prometheus/prometheus.yaml.erb'
Expand Down Expand Up @@ -205,7 +204,6 @@
$redis_exporter_user = 'redis-exporter'
$redis_exporter_version = '0.11.2'
$user = 'prometheus'
$version = '1.5.2'
case $::architecture {
'x86_64', 'amd64': { $arch = 'amd64' }
'i386': { $arch = '386' }
Expand All @@ -217,6 +215,9 @@
$os = downcase($::kernel)

if $::operatingsystem == 'Ubuntu' {
$version = '1.5.2'
$bin_dir = '/usr/local/bin'
$prometheus_install_method = 'url'
$env_file_path = '/etc/default'
if versioncmp($::operatingsystemrelease, '8.04') < 1 {
$init_style = 'debian'
Expand All @@ -226,46 +227,73 @@
$init_style = 'systemd'
}
} elsif $::operatingsystem =~ /Scientific|CentOS|RedHat|OracleLinux/ {
$version = '1.5.2'
$bin_dir = '/usr/local/bin'
$prometheus_install_method = 'url'
$env_file_path = '/etc/sysconfig'
if versioncmp($::operatingsystemrelease, '7.0') < 0 {
$init_style = 'sysv'
} else {
$init_style = 'systemd'
}
} elsif $::operatingsystem == 'Fedora' {
$version = '1.5.2'
$bin_dir = '/usr/local/bin'
$prometheus_install_method = 'url'
$env_file_path = '/etc/sysconfig'
if versioncmp($::operatingsystemrelease, '12') < 0 {
$init_style = 'sysv'
} else {
$init_style = 'systemd'
}
} elsif $::operatingsystem == 'Debian' {
$version = '1.5.2'
$bin_dir = '/usr/local/bin'
$prometheus_install_method = 'url'
$env_file_path = '/etc/default'
if versioncmp($::operatingsystemrelease, '8.0') < 0 {
$init_style = 'debian'
} else {
$init_style = 'systemd'
}
} elsif $::operatingsystem == 'Archlinux' {
$version = '2.2.0'
$bin_dir = '/usr/bin'
$prometheus_install_method = 'package'
$env_file_path = '/etc/default'
$init_style = 'systemd'
} elsif $::operatingsystem == 'OpenSuSE' {
$version = '1.5.2'
$bin_dir = '/usr/local/bin'
$prometheus_install_method = 'url'
$env_file_path = '/etc/sysconfig'
$init_style = 'systemd'
} elsif $::operatingsystem =~ /SLE[SD]/ {
$version = '1.5.2'
$bin_dir = '/usr/local/bin'
$prometheus_install_method = 'url'
$env_file_path = '/etc/sysconfig'
if versioncmp($::operatingsystemrelease, '12.0') < 0 {
$init_style = 'sles'
} else {
$init_style = 'systemd'
}
} elsif $::operatingsystem == 'Darwin' {
$version = '1.5.2'
$bin_dir = '/usr/local/bin'
$prometheus_install_method = 'url'
$env_file_path = undef
$init_style = 'launchd'
} elsif $::operatingsystem == 'Amazon' {
$version = '1.5.2'
$bin_dir = '/usr/local/bin'
$prometheus_install_method = 'url'
$env_file_path = '/etc/sysconfig'
$init_style = 'sysv'
} else {
$version = '1.5.2'
$bin_dir = '/usr/local/bin'
$prometheus_install_method = 'url'
$init_style = undef
}
if $init_style == undef {
Expand Down
3 changes: 3 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
"6",
"7"
]
},
{
"operatingsystem": "Archlinux"
}
],
"requirements": [
Expand Down
3 changes: 2 additions & 1 deletion spec/classes/alertmanager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
{
version: '0.9.1',
arch: 'amd64',
os: 'linux'
os: 'linux',
bin_dir: '/usr/local/bin'
}
end

Expand Down
3 changes: 2 additions & 1 deletion spec/classes/beanstalkd_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
{
version: '1.0.0',
arch: 'amd64',
os: 'linux'
os: 'linux',
bin_dir: '/usr/local/bin'
}
end

Expand Down
1 change: 1 addition & 0 deletions spec/classes/blackbox_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
version: '0.6.0',
arch: 'amd64',
os: 'linux',
bin_dir: '/usr/local/bin',
modules: {
'http_2xx' => {
'prober' => 'http'
Expand Down
3 changes: 2 additions & 1 deletion spec/classes/consul_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
{
version: '0.3.0',
arch: 'amd64',
os: 'linux'
os: 'linux',
bin_dir: '/usr/local/bin'
}
end

Expand Down
3 changes: 2 additions & 1 deletion spec/classes/elasticsearch_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
{
version: '1.0.0',
arch: 'amd64',
os: 'linux'
os: 'linux',
bin_dir: '/usr/local/bin'
}
end

Expand Down
3 changes: 2 additions & 1 deletion spec/classes/haproxy_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
{
version: '0.7.1',
arch: 'amd64',
os: 'linux'
os: 'linux',
bin_dir: '/usr/local/bin'
}
end

Expand Down
3 changes: 2 additions & 1 deletion spec/classes/mongodb_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
{
version: '0.3.0',
arch: 'amd64',
os: 'linux'
os: 'linux',
bin_dir: '/usr/local/bin'
}
end

Expand Down
3 changes: 2 additions & 1 deletion spec/classes/nginx_vts_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
{
version: '0.6',
arch: 'amd64',
os: 'linux'
os: 'linux',
bin_dir: '/usr/local/bin'
}
end

Expand Down
3 changes: 2 additions & 1 deletion spec/classes/node_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
{
version: '0.13.0',
arch: 'amd64',
os: 'linux'
os: 'linux',
bin_dir: '/usr/local/bin'
}
end

Expand Down
9 changes: 5 additions & 4 deletions spec/classes/prometheus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
facts
end

[{}, { version: '2.0.0-rc.1' }].each do |parameters|
[{ version: '2.0.0-rc.1', bin_dir: '/usr/local/bin', install_method: 'url' }].each do |parameters|
context "with parameters #{parameters}" do
let(:params) do
parameters
Expand Down Expand Up @@ -116,7 +116,7 @@
'content' => File.read(fixtures('files', "prometheus#{prom_major}.sysv"))
)
}
elsif ['centos-7-x86_64', 'debian-8-x86_64', 'redhat-7-x86_64', 'ubuntu-16.04-x86_64'].include?(os)
elsif ['centos-7-x86_64', 'debian-8-x86_64', 'redhat-7-x86_64', 'ubuntu-16.04-x86_64', 'archlinux-4-x86_64'].include?(os)
# init_style = 'systemd'

it { is_expected.to contain_class('systemd') }
Expand Down Expand Up @@ -149,7 +149,7 @@
}
else
it {
is_expected.to raise_error(Puppet::Error, %r{I don.t know how to create an init script for style})
is_expected.to raise_error(Puppet::Error, %r{I don't know how to create an init script for style})
}
end

Expand Down Expand Up @@ -203,6 +203,7 @@
context 'with alerts configured', alerts: true do
[
{
version: '1.5.3',
alerts: [{
'name' => 'alert_name',
'condition' => 'up == 0',
Expand Down Expand Up @@ -236,7 +237,7 @@
parameters
end

prom_version = parameters[:version] || '1.5.2'
prom_version = parameters[:version]
prom_major = prom_version[0]

it {
Expand Down
3 changes: 2 additions & 1 deletion spec/classes/pushgateway_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
{
version: '0.4.0',
arch: 'amd64',
os: 'linux'
os: 'linux',
bin_dir: '/usr/local/bin'
}
end

Expand Down
3 changes: 2 additions & 1 deletion spec/classes/rabbitmq_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
{
version: '1.0.0',
arch: 'amd64',
os: 'linux'
os: 'linux',
bin_dir: '/usr/local/bin'
}
end

Expand Down
3 changes: 2 additions & 1 deletion spec/classes/redis_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
{
version: '0.11.2',
arch: 'amd64',
os: 'linux'
os: 'linux',
bin_dir: '/usr/local/bin'
}
end

Expand Down
3 changes: 2 additions & 1 deletion spec/classes/snmp_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
{
version: '0.6.0',
arch: 'amd64',
os: 'linux'
os: 'linux',
bin_dir: '/usr/local/bin'
}
end

Expand Down
3 changes: 2 additions & 1 deletion spec/defines/alerts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

[
{
version: '1.5.2',
alerts: [
{
'name' => 'alert_name',
Expand Down Expand Up @@ -62,7 +63,7 @@
parameters
end

prom_version = parameters[:version] || '1.5.2'
prom_version = parameters[:version]
prom_major = prom_version[0]

it {
Expand Down
8 changes: 5 additions & 3 deletions spec/defines/daemon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@
notify_service: 'Service[smurf_exporter]',
user: 'smurf_user',
group: 'smurf_group',
env_vars: { SOMEVAR: 42 }
env_vars: { SOMEVAR: 42 },
bin_dir: '/usr/local/bin'
}
].each do |parameters|
context "with parameters #{parameters}" do
let(:params) do
parameters
end

it { is_expected.to contain_class('prometheus::params') }
prom_os = facts[:kernel].downcase
prom_arch = facts[:architecture] == 'i386' ? '386' : 'amd64'

Expand Down Expand Up @@ -102,7 +104,7 @@
%r{daemon --user=smurf_user \\\n --pidfile="\$PID_FILE" \\\n "\$DAEMON" '' >> "\$LOG_FILE" &}
)
}
elsif ['centos-7-x86_64', 'debian-8-x86_64', 'redhat-7-x86_64', 'ubuntu-16.04-x86_64'].include?(os)
elsif ['centos-7-x86_64', 'debian-8-x86_64', 'redhat-7-x86_64', 'ubuntu-16.04-x86_64', 'archlinux-4-x86_64'].include?(os)
# init_style = 'systemd'

it { is_expected.to contain_class('systemd') }
Expand Down Expand Up @@ -142,7 +144,7 @@
}
else
it {
is_expected.to raise_error(Puppet::Error, %r{I don.t know how to create an init script for style})
is_expected.to raise_error(Puppet::Error, %r{I don't know how to create an init script for style})
}
end

Expand Down

0 comments on commit b9e9bf4

Please sign in to comment.