mirror of
https://github.com/voxpupuli/puppet-hashi_stack.git
synced 2025-05-24 10:55:00 +01:00
moving parameters into appropriate place, adding meaning unit test, first pass on reference file, expanding acceptance test to include meaningful example
using codename as release
This commit is contained in:
parent
46678ae310
commit
ea3e115bd0
6 changed files with 108 additions and 12 deletions
8
.fixtures.yml
Normal file
8
.fixtures.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
fixtures:
|
||||
forge_modules:
|
||||
stdlib: puppetlabs/stdlib
|
||||
apt: puppetlabs/apt
|
||||
yum: puppet/yum
|
||||
yumrepo_core:
|
||||
repo: puppetlabs/yumrepo_core
|
||||
puppet_version: ">= 6.0.0"
|
74
REFERENCE.md
Normal file
74
REFERENCE.md
Normal file
|
@ -0,0 +1,74 @@
|
|||
# Reference
|
||||
|
||||
<!-- DO NOT EDIT: This document was generated by Puppet Strings -->
|
||||
|
||||
## Table of Contents
|
||||
|
||||
### Classes
|
||||
|
||||
* [`hashi_stack::repo`](#hashi_stackrepo): Set up the package repository for the HashiCorp Stack components
|
||||
|
||||
## Classes
|
||||
|
||||
### `hashi_stack::repo`
|
||||
|
||||
This class installs the hashicorp repository
|
||||
|
||||
#### Examples
|
||||
|
||||
#####
|
||||
|
||||
```puppet
|
||||
include hashi_stack::repo
|
||||
```
|
||||
|
||||
#####
|
||||
|
||||
```puppet
|
||||
class { 'hashi_stack::repo': } -> package { 'packer': ensure => installed }
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
The following parameters are available in the `hashi_stack::repo` class.
|
||||
|
||||
##### `priority`
|
||||
|
||||
Data type: `Optional[Integer]`
|
||||
|
||||
A numeric priority for the repo, passed to the package management system
|
||||
|
||||
Default value: ``undef``
|
||||
|
||||
##### `proxy`
|
||||
|
||||
Data type: `String`
|
||||
|
||||
The URL of a HTTP proxy to use for package downloads (YUM only)
|
||||
|
||||
Default value: `'absent'`
|
||||
|
||||
##### `key_id`
|
||||
|
||||
Data type: `String`
|
||||
|
||||
GPG key to authenticate Apt package signatures.
|
||||
|
||||
Default value: `'E8A032E094D8EB4EA189D270DA418C88A3219F7B'`
|
||||
|
||||
##### `key_source`
|
||||
|
||||
Data type: `Stdlib::HTTPSUrl`
|
||||
|
||||
The location of an existing GPG key file to copy.
|
||||
|
||||
Default value: `'https://apt.releases.hashicorp.com/gpg'`
|
||||
|
||||
##### `description`
|
||||
|
||||
Data type: `String`
|
||||
|
||||
Repository description
|
||||
|
||||
Default value: `'HashiCorp package repository.'`
|
||||
|
2
example/init.pp
Normal file
2
example/init.pp
Normal file
|
@ -0,0 +1,2 @@
|
|||
class { 'hashi_stack::repo': }
|
||||
-> package { 'packer': ensure => installed }
|
|
@ -5,17 +5,21 @@
|
|||
# @example
|
||||
# include hashi_stack::repo
|
||||
#
|
||||
# @example
|
||||
# class { 'hashi_stack::repo': } -> package { 'packer': ensure => installed }
|
||||
#
|
||||
# @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
|
||||
# @param key_id GPG key to authenticate Apt package signatures.
|
||||
# @param key_source The location of an existing GPG key file to copy.
|
||||
# @param description Repository description
|
||||
class hashi_stack::repo (
|
||||
Optional[Integer] $priority = undef,
|
||||
String $proxy = 'absent',
|
||||
String $key_id = 'E8A032E094D8EB4EA189D270DA418C88A3219F7B',
|
||||
Stdlib::HTTPSUrl $key_source = 'https://apt.releases.hashicorp.com/gpg',
|
||||
String $description = 'HashiCorp package repository.',
|
||||
) {
|
||||
$key_id='E8A032E094D8EB4EA189D270DA418C88A3219F7B'
|
||||
$key_source='https://apt.releases.hashicorp.com/gpg'
|
||||
$description='HashiCorp package repository.'
|
||||
|
||||
case $facts['os']['family'] {
|
||||
'Debian': {
|
||||
include apt
|
||||
|
@ -25,7 +29,7 @@ class hashi_stack::repo (
|
|||
architecture => 'amd64',
|
||||
comment => $description,
|
||||
location => 'https://apt.releases.hashicorp.com',
|
||||
release => 'stable',
|
||||
release => $facts['os']['distro']['codename'],
|
||||
repos => 'main',
|
||||
key => {
|
||||
'id' => $key_id,
|
||||
|
|
|
@ -6,12 +6,12 @@ describe 'hashi_stack::repo class' do
|
|||
# Using puppet_apply as a helper
|
||||
it 'should work with no errors based on the example' do
|
||||
pp = <<-EOS
|
||||
class { 'hashi_stack::repo': }
|
||||
class { 'hashi_stack::repo': } -> package { 'packer': ensure => installed }
|
||||
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)
|
||||
apply_manifest(pp, catch_failures: true)
|
||||
apply_manifest(pp, catch_changes: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'hashi_stack::repo' do
|
||||
describe 'hashi_stack::repo', type: 'class' do
|
||||
on_supported_os.each do |os, os_facts|
|
||||
context "on #{os}" do
|
||||
let(:facts) { os_facts }
|
||||
|
||||
case os_facts[:os]['family']
|
||||
when 'Debian'
|
||||
it { is_expected.to contain_apt__source('HashiCorp') }
|
||||
when 'RedHat'
|
||||
it { is_expected.to contain_yumrepo('HashiCorp') }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue