This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Wrapper #40
Merged
Merged
Wrapper #40
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
.*.sw? | ||
pkg | ||
spec/fixtures | ||
.rspec_system | ||
.vagrant/ | ||
log/ | ||
junit/ | ||
.yar* | ||
doc/ | ||
|
||
# Puppet | ||
coverage/ | ||
spec/fixtures/modules/* | ||
spec/fixtures/manifests/* | ||
Gemfile.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
classes: | ||
- swap_file | ||
|
||
swap_file::files: | ||
'from_common': | ||
ensure: 'present' | ||
swapfile: '/mnt/swap.common' | ||
|
||
# This will: | ||
# - call the class swap_file | ||
# - create a file '/mnt/swap.common' using /bin/dd with the default size taken from the $::memorysizeinbytes and create a mount for it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
swap_file::files_hiera_merge: false | ||
swap_file::files: | ||
'from_fqdn': | ||
ensure: 'present' | ||
swapfile: '/mnt/swap.fqdn' | ||
swapfilesize: '2 GB' | ||
cmd: 'fallocate' | ||
|
||
# Because files_hiera_merge is set to false, this will create only the swapfiles specified in the most specific hiera level. | ||
|
||
# This will: | ||
# - create a file '/mnt/swap.fqdn' using /usr/bin/fallocate with size set to '2 GB' and creates mount for it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
swap_file::files_hiera_merge: true | ||
swap_file::files: | ||
'from_fqdn': | ||
ensure: 'present' | ||
swapfile: '/mnt/swap.fqdn' | ||
swapfilesize: '2 GB' | ||
cmd: 'fallocate' | ||
|
||
# Because files_hiera_merge is set to true, this will create all swapfiles specified in different hiera levels. | ||
|
||
# This will: | ||
# - create a file '/mnt/swap.common' using /bin/dd with the default size taken from the $::memorysizeinbytes and create a mount for it. | ||
# - create a file '/mnt/swap.fqdn' using /usr/bin/fallocate with size set to '2 GB' and creates mount for it. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
:backends: | ||
- yaml | ||
:hierarchy: | ||
- fqdn/%{fqdn} | ||
- common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
node default { | ||
class { 'swap_file': | ||
files => { | ||
'swapfile' => { | ||
ensure => 'present', | ||
}, | ||
'use fallocate' => { | ||
swapfile => '/tmp/swapfile.fallocate', | ||
cmd => 'fallocate', | ||
}, | ||
'remove swap file' => { | ||
ensure => 'absent', | ||
swapfile => '/tmp/swapfile.old', | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# == Class: swap_file | ||
# | ||
# == Parameters | ||
# [*files*] | ||
# Hash of swap files to ensure with swap_file::files | ||
# [*files_hiera_merge*] | ||
# Boolean to merge all found instances of swap_file::files in Hiera. | ||
# This can be used to specify swap files at different levels an have | ||
# them all included in the catalog. | ||
# Defaults to false | ||
# | ||
# == Examples | ||
# | ||
# class { 'swap_file': | ||
# 'files' => { | ||
# 'resource_name' => { | ||
# ensure => present, | ||
# swapfile => '/mnt/swap', | ||
# }, | ||
# }, | ||
# } | ||
# Will create one swapfile in /mnt/swap using the defaults. | ||
# | ||
# class { 'swap_file': | ||
# 'files' => { | ||
# 'swap1' => { | ||
# ensure => present, | ||
# swapfile => '/mnt/swap.1', | ||
# swapfilesize => '1 GB', | ||
# }, | ||
# 'swap2' => { | ||
# ensure => present, | ||
# swapfile => '/mnt/swap.2', | ||
# swapfilesize => '2 GB', | ||
# cmd => 'fallocate', | ||
# }, | ||
# }, | ||
# } | ||
# Will create two swapfile with the given parameters | ||
# | ||
# class { 'swap_file': | ||
# files_hiera_merge: true, | ||
# } | ||
# Will merge all found instances of swap_file::files found in hiera and | ||
# create resources for these. | ||
# | ||
|
||
class swap_file ( | ||
$files = {}, | ||
$files_hiera_merge = false, | ||
) { | ||
|
||
# variable handling | ||
if is_bool($files_hiera_merge) == true { | ||
$files_hiera_merge_bool = $files_hiera_merge | ||
} else { | ||
$files_hiera_merge_bool = str2bool($files_hiera_merge) | ||
} | ||
validate_bool($files_hiera_merge_bool) | ||
|
||
# functionality | ||
if $files_hiera_merge_bool == true { | ||
$files_real = hiera_hash('swap_file::files', {}) | ||
} else { | ||
$files_real = $files | ||
} | ||
if $files_real != undef { | ||
validate_hash($files_real) | ||
create_resources('swap_file::files', $files_real) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guessing this was intended