Skip to content

Commit 56bddc8

Browse files
authored
Merge pull request #40 from m0dular/aph/debian-repo
Aph/debian repo
2 parents bc57861 + d6f06d0 commit 56bddc8

File tree

9 files changed

+58
-8
lines changed

9 files changed

+58
-8
lines changed

.fixtures.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ fixtures:
55
forge_modules:
66
archive: "puppet/archive"
77
yumrepo: "puppetlabs/yumrepo_core"
8+
apt: "puppetlabs/apt"
89
repositories:
910
facts: 'https://github.com/puppetlabs/puppetlabs-facts'
1011
puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent'

data/common.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ influxdb::host: "%{facts.fqdn}"
33
influxdb::port: 8086
44
influxdb::initial_org: 'puppetlabs'
55
influxdb::initial_bucket: 'puppet_data'
6+
influxdb::repo_gpg_key_id: '05CE15085FC09D18E99EFB22684A14CF2582E0C5'
67
influxdb::repo_gpg_key_url: 'https://repos.influxdata.com/influxdb2.key https://repos.influxdata.com/influxdb.key'
8+
influxdb::manage_repo: false

data/os/Debian.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
influxdb::repo_url: 'https://repos.influxdata.com/debian'
2+
influxdb::manage_repo: true
3+
influxdb::repo_gpg_key_url: 'https://repos.influxdata.com/influxdb.key'
4+
influxdb::version: latest

data/os/RedHat.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
---
22
influxdb::repo_url: 'https://repos.influxdata.com/rhel/$releasever/$basearch/stable'
3+
influxdb::manage_repo: true

data/os/Ubuntu.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
influxdb::repo_url: 'https://repos.influxdata.com/debian'

hiera.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ hierarchy:
99
- name: "osfamily/major release"
1010
paths:
1111
# Used to distinguish between Debian and Ubuntu
12-
- "os/%{facts.os.name}.yaml"
1312
- "os/%{facts.os.name}/%{facts.os.release.major}.yaml"
1413
- "os/%{facts.os.family}/%{facts.os.release.major}.yaml"
1514
# Used for Solaris

manifests/init.pp

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
# @param token_file
4444
# File on disk containing an administrative token. This class will write the token generated as part of initial setup to this file.
4545
# Note that functions or code run in Puppet server will not be able to use this file, so setting $token after setup is recommended.
46+
# @param repo_gpg_key_id
47+
# ID of the GPG signing key
4648
# @param repo_url
4749
# URL of the Package repository
4850
# @param repo_gpg_key_url
@@ -53,9 +55,10 @@
5355
Integer $port,
5456
String $initial_org,
5557
String $initial_bucket,
58+
String $repo_gpg_key_id,
5659
String $repo_gpg_key_url,
60+
Boolean $manage_repo,
5761

58-
Boolean $manage_repo = true,
5962
Boolean $manage_setup = true,
6063

6164
Optional[String] $repo_url = undef,
@@ -81,8 +84,19 @@
8184
fail("Unable to manage InfluxDB installation on host ${facts['networking']['fqdn']}")
8285
}
8386

87+
# If managing SSL, install the package before managing files under /etc/influxdb in order to ensure the directory exists
88+
$package_before = if $use_ssl and $manage_ssl {
89+
[
90+
File['/etc/influxdb/cert.pem', '/etc/influxdb/key.pem', '/etc/influxdb/ca.pem', '/etc/systemd/system/influxdb.service.d'],
91+
Service['influxdb']
92+
]
93+
}
94+
else {
95+
Service['influxdb']
96+
}
97+
8498
# If we are managing the repository, set it up and install the package with a require on the repo
85-
if $manage_repo and $facts['os']['family'] in ['Redhat'] {
99+
if $manage_repo {
86100
#TODO: other distros
87101
case $facts['os']['family'] {
88102
'RedHat': {
@@ -96,6 +110,22 @@
96110
gpgcheck => '1',
97111
target => '/etc/yum.repos.d/influxdb2.repo',
98112
}
113+
$package_require = Yumrepo[$repo_name]
114+
}
115+
'Debian': {
116+
include apt
117+
apt::source { $repo_name:
118+
ensure => 'present',
119+
comment => 'The InfluxDB2 repository',
120+
location => $repo_url,
121+
release => 'stable',
122+
repos => 'main',
123+
key => {
124+
'id' => $repo_gpg_key_id,
125+
'source' => $repo_gpg_key_url,
126+
},
127+
}
128+
$package_require = Apt::Source[$repo_name]
99129
}
100130
default: {
101131
notify { 'influxdb_repo_warn':
@@ -105,10 +135,10 @@
105135
}
106136
}
107137

108-
package { 'influxdb2':
138+
package {'influxdb2':
109139
ensure => $version,
110-
require => Yumrepo[$repo_name],
111-
before => Service['influxdb'],
140+
require => $package_require,
141+
before => $package_before,
112142
}
113143
}
114144
# If not managing the repo, install the package from archive source
@@ -167,7 +197,7 @@
167197
else {
168198
package { 'influxdb2':
169199
ensure => installed,
170-
before => Service['influxdb'],
200+
before => $package_before,
171201
}
172202
}
173203

metadata.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
"dependencies": [
99
{
1010
"name": "puppet/archive",
11-
"version_requirement": ">= 6.0.0 <7.0"
11+
"version_requirement": ">= 6.0.0 <7.0.0"
12+
},
13+
{
14+
"name": "puppetlabs/apt",
15+
"version_requirement": ">= 9.0.0 <10.0.0"
1216
}
1317
],
1418
"operatingsystem_support": [

spec/classes/init_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'spec_helper'
2+
require 'pry'
23

34
describe 'influxdb' do
45
let(:facts) { { os: { family: 'RedHat' }, identity: { user: 'root' } } }
@@ -25,6 +26,13 @@
2526
)
2627

2728
is_expected.to contain_service('influxdb').with_ensure('running')
29+
is_expected.to contain_package('influxdb2').that_comes_before([
30+
'File[/etc/influxdb/cert.pem]',
31+
'File[/etc/influxdb/key.pem]',
32+
'File[/etc/influxdb/ca.pem]',
33+
'File[/etc/systemd/system/influxdb.service.d]',
34+
'Service[influxdb]',
35+
])
2836
is_expected.to contain_package('influxdb2').with_ensure('2.1.1')
2937

3038
['/etc/influxdb/cert.pem', '/etc/influxdb/ca.pem', '/etc/influxdb/key.pem'].each do |file|

0 commit comments

Comments
 (0)