adding acceptance setup

This commit is contained in:
Bram Vogelaar 2021-01-11 23:31:35 +01:00
parent 1822503711
commit fe9ef733e1
No known key found for this signature in database
GPG key ID: 02374F82C00E4984
4 changed files with 103 additions and 5 deletions

View file

@ -1,2 +1,30 @@
# puppet-hashi_stack
This module contains shared code for various HashiCorp modules
[![Puppet Forge](https://img.shields.io/puppetforge/v/puppet/hashi_stack.svg)](https://forge.puppetlabs.com/puppet/hashi_stack)
[![Puppet Forge - downloads](https://img.shields.io/puppetforge/dt/puppet/hashi_stack.svg)](https://forge.puppetlabs.com/puppet/hashi_stack)
[![Puppet Forge - endorsement](https://img.shields.io/puppetforge/e/puppet/hashi_stack.svg)](https://forge.puppetlabs.com/puppet/hashi_stack)
[![Puppet Forge - scores](https://img.shields.io/puppetforge/f/puppet/hashi_stack.svg)](https://forge.puppetlabs.com/puppet/hashi_stack)
[![puppetmodule.info docs](http://www.puppetmodule.info/images/badge.png)](http://www.puppetmodule.info/m/puppet-hashi_stack)
[![Apache-2.0 License](https://img.shields.io/github/license/voxpupuli/puppet-hashi_stack.svg)](LICENSE)
### What This Module Affects
* Installs the hashicorp repositories
## Reference
See [REFERENCE](REFERENCE.md).
## Limitations
Depends on the JSON gem, or a modern ruby. (Ruby 2.5 and newer are supported)
## Development
Vox Pupuli welcomes new contributions to this
module, especially those that include documentation and rspec tests. We are
happy to provide guidance if necessary.
Open an [issue](https://github.com/voxpupuli/puppet-hashi_stack/issues) or
[fork](https://github.com/voxpupuli/puppet-hashi_stack/fork) and open a
[Pull Request](https://github.com/voxpupuli/puppet-hashi_stack/pulls)

View file

@ -1,2 +1,56 @@
# hashi_stack::repo
#
class hashi_stack::repo {}
# @summary Set up the package repository for the HashiCorp Stack components
#
# @example
# include hashi_stack::repo
#
# @param priority A numeric priority for the repo, passed to the package management system
# @param proxy The URL of a HTTP proxy to use for package downloads (YUM only)
# @param base_repo_url The base url for the repo path
class hashi_stack::repo (
Optional[Integer] $priority = undef,
String $proxy = 'absent',
) {
$key_id='E8A032E094D8EB4EA189D270DA418C88A3219F7B'
$key_source='https://apt.releases.hashicorp.com/gpg'
$description='HashiCorp package repository.'
case $facts['os']['family'] {
'Debian': {
include apt
apt::source { 'HashiCorp':
ensure => 'present',
architecture => 'amd64',
comment => $description,
location => 'https://apt.releases.hashicorp.com',
release => 'stable',
repos => 'main',
key => {
'id' => $key_id,
'source' => $key_source,
},
include => {
'deb' => true,
'src' => false,
},
pin => $priority,
}
}
'RedHat', 'Linux': {
yumrepo { 'HashiCorp':
descr => $description,
baseurl => 'https://rpm.releases.hashicorp.com/RHEL/$releasever/$basearch/stable',
gpgcheck => 1,
gpgkey => $key_source,
enabled => 1,
proxy => $proxy,
priority => $priority,
}
}
default: {
fail("\"${module_name}\" provides no repository information for OSfamily \"${facts['os']['family']}\"")
}
}
}

View file

@ -0,0 +1,17 @@
require 'spec_helper_acceptance'
describe 'hashi_stack::repo class' do
context 'default parameters' do
# Using puppet_apply as a helper
it 'should work with no errors based on the example' do
pp = <<-EOS
class { 'hashi_stack::repo': }
EOS
# Run it twice and test for idempotency
expect(apply_manifest(pp).exit_code).to_not eq(1)
expect(apply_manifest(pp).exit_code).to eq(0)
end
end
end

View file

@ -1,9 +1,8 @@
require 'spec_helper'
describe 'nomad' do
describe 'hashi_stack::repo' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts.merge(service_provider: 'systemd') }
end
end
end