diff --git a/.fixtures.yml b/.fixtures.yml index 8db6b4f..d565dc3 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -5,6 +5,7 @@ fixtures: forge_modules: archive: "puppet/archive" yumrepo: "puppetlabs/yumrepo_core" + apt: "puppetlabs/apt" repositories: facts: 'https://github.com/puppetlabs/puppetlabs-facts' puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent' diff --git a/data/common.yaml b/data/common.yaml index e744e01..54b37d0 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -3,4 +3,6 @@ influxdb::host: "%{facts.fqdn}" influxdb::port: 8086 influxdb::initial_org: 'puppetlabs' influxdb::initial_bucket: 'puppet_data' +influxdb::repo_gpg_key_id: '05CE15085FC09D18E99EFB22684A14CF2582E0C5' influxdb::repo_gpg_key_url: 'https://repos.influxdata.com/influxdb2.key https://repos.influxdata.com/influxdb.key' +influxdb::manage_repo: false diff --git a/data/os/Debian.yaml b/data/os/Debian.yaml new file mode 100644 index 0000000..72d3dde --- /dev/null +++ b/data/os/Debian.yaml @@ -0,0 +1,4 @@ +influxdb::repo_url: 'https://repos.influxdata.com/debian' +influxdb::manage_repo: true +influxdb::repo_gpg_key_url: 'https://repos.influxdata.com/influxdb.key' +influxdb::version: latest diff --git a/data/os/RedHat.yaml b/data/os/RedHat.yaml index e4e371c..7983603 100644 --- a/data/os/RedHat.yaml +++ b/data/os/RedHat.yaml @@ -1,2 +1,3 @@ --- influxdb::repo_url: 'https://repos.influxdata.com/rhel/$releasever/$basearch/stable' +influxdb::manage_repo: true diff --git a/data/os/Ubuntu.yaml b/data/os/Ubuntu.yaml new file mode 100644 index 0000000..1a66dd9 --- /dev/null +++ b/data/os/Ubuntu.yaml @@ -0,0 +1 @@ +influxdb::repo_url: 'https://repos.influxdata.com/debian' diff --git a/hiera.yaml b/hiera.yaml index 49fdc4d..545fff3 100644 --- a/hiera.yaml +++ b/hiera.yaml @@ -9,7 +9,6 @@ hierarchy: - name: "osfamily/major release" paths: # Used to distinguish between Debian and Ubuntu - - "os/%{facts.os.name}.yaml" - "os/%{facts.os.name}/%{facts.os.release.major}.yaml" - "os/%{facts.os.family}/%{facts.os.release.major}.yaml" # Used for Solaris diff --git a/manifests/init.pp b/manifests/init.pp index 6e8933d..6c049c6 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -43,6 +43,8 @@ # @param token_file # File on disk containing an administrative token. This class will write the token generated as part of initial setup to this file. # Note that functions or code run in Puppet server will not be able to use this file, so setting $token after setup is recommended. +# @param repo_gpg_key_id +# ID of the GPG signing key # @param repo_url # URL of the Package repository # @param repo_gpg_key_url @@ -53,9 +55,10 @@ Integer $port, String $initial_org, String $initial_bucket, + String $repo_gpg_key_id, String $repo_gpg_key_url, + Boolean $manage_repo, - Boolean $manage_repo = true, Boolean $manage_setup = true, Optional[String] $repo_url = undef, @@ -82,7 +85,7 @@ } # If we are managing the repository, set it up and install the package with a require on the repo - if $manage_repo and $facts['os']['family'] in ['Redhat'] { + if $manage_repo { #TODO: other distros case $facts['os']['family'] { 'RedHat': { @@ -96,6 +99,22 @@ gpgcheck => '1', target => '/etc/yum.repos.d/influxdb2.repo', } + $package_require = Yumrepo[$repo_name] + } + 'Debian': { + include apt + apt::source { $repo_name: + ensure => 'present', + comment => 'The InfluxDB2 repository', + location => $repo_url, + release => 'stable', + repos => 'main', + key => { + 'id' => $repo_gpg_key_id, + 'source' => $repo_gpg_key_url, + }, + } + $package_require = Apt::Source[$repo_name] } default: { notify { 'influxdb_repo_warn': @@ -107,7 +126,7 @@ package { 'influxdb2': ensure => $version, - require => Yumrepo[$repo_name], + require => $package_require, before => Service['influxdb'], } } diff --git a/metadata.json b/metadata.json index e49c7e8..2aa668d 100644 --- a/metadata.json +++ b/metadata.json @@ -8,7 +8,11 @@ "dependencies": [ { "name": "puppet/archive", - "version_requirement": ">= 6.0.0 <7.0" + "version_requirement": ">= 6.0.0 <7.0.0" + }, + { + "name": "puppetlabs/apt", + "version_requirement": ">= 9.0.0 <10.0.0" } ], "operatingsystem_support": [