How can a puppet resource check for a data source on the puppetmaster without failing to compile?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am writing a puppet Ceph deployment module and need to generate keys on an admin node and distribute them to the monitor nodes. I have written server-side functions to retrieve the keys once they are generated, but would like to only distribute those keys once they exist.
- The manifest for the admin node generates the cluster keys
- Manifests for the monitor and management nodes need to include those keys as file resources
- The manifests should not fail to compile (or generate undue log volume) if they keys have not yet been generated
- The file resources need to be named as they are per-requisites for other resources
n.b. The examples are from Puppet3 so no Ruby dispatch :(
What is the philosophically pure approach to gather and distribute keys?
Sample code:
manifests/admin_node.pp:
exec { "make_${cluster[name]}_${name}_keyring":
command => "/usr/bin/ceph-authtool --create-keyring ${ring[file]} --gen-key -n ${ring[name]} ${ring[auth]}",
require => [ File[$confdir, $bootdir], Package['ceph-common'], ],
creates => $ring[file],
}
lib/puppet/parser/functions/get_remote_file.rb:
module Puppet::Parser::Functions
newfunction(:get_remote_file, :type => :rvalue) do |args|
return "Error 3: " + args.length.to_s + " arguments were provided to get_remote_file.rb. Required is 3 to 5." if args.length < 3 or args.length > 5
remote_host = args[0]
remote_path = args[1]
local_path = args[2]
local_user = (args.length > 3) ? 'runuser -l ' + args[3] + ' ' : ''
remote_user = (args.length > 4) ? args[4] + '@' : ''
# Is the file already down?
return 0 if File.exist?(local_path)
`"#{local_user}bash -c 'scp #{remote_user}#{remote_host}:#{remote_path} #{local_path} 2> /dev/null'"`
return $?.exitstatus
end
end
manifests/monitor_node.pp:
unless file_exists($master_key) {
get_remote_file($adm_node, $monitor_keyring, $master_key)
}
exec { "check_${cluster[name]}.mon.keyring":
command => '/bin/yes',
onlyif => "/usr/bin/test -e $master_key",
}
file { "$libdir/${cluster[name]}.mon.keyring":
ensure => $f_action,
source => "puppet:///modules/ceph$libdir/${cluster[name]}.mon.keyring",
require => Exec["check_${cluster[name]}.mon.keyring"],
}
Thanks for any ideas on how to tackle this. I understand that this is... dis-incentivized in Puppet. What is a good approach?
puppet
add a comment |
I am writing a puppet Ceph deployment module and need to generate keys on an admin node and distribute them to the monitor nodes. I have written server-side functions to retrieve the keys once they are generated, but would like to only distribute those keys once they exist.
- The manifest for the admin node generates the cluster keys
- Manifests for the monitor and management nodes need to include those keys as file resources
- The manifests should not fail to compile (or generate undue log volume) if they keys have not yet been generated
- The file resources need to be named as they are per-requisites for other resources
n.b. The examples are from Puppet3 so no Ruby dispatch :(
What is the philosophically pure approach to gather and distribute keys?
Sample code:
manifests/admin_node.pp:
exec { "make_${cluster[name]}_${name}_keyring":
command => "/usr/bin/ceph-authtool --create-keyring ${ring[file]} --gen-key -n ${ring[name]} ${ring[auth]}",
require => [ File[$confdir, $bootdir], Package['ceph-common'], ],
creates => $ring[file],
}
lib/puppet/parser/functions/get_remote_file.rb:
module Puppet::Parser::Functions
newfunction(:get_remote_file, :type => :rvalue) do |args|
return "Error 3: " + args.length.to_s + " arguments were provided to get_remote_file.rb. Required is 3 to 5." if args.length < 3 or args.length > 5
remote_host = args[0]
remote_path = args[1]
local_path = args[2]
local_user = (args.length > 3) ? 'runuser -l ' + args[3] + ' ' : ''
remote_user = (args.length > 4) ? args[4] + '@' : ''
# Is the file already down?
return 0 if File.exist?(local_path)
`"#{local_user}bash -c 'scp #{remote_user}#{remote_host}:#{remote_path} #{local_path} 2> /dev/null'"`
return $?.exitstatus
end
end
manifests/monitor_node.pp:
unless file_exists($master_key) {
get_remote_file($adm_node, $monitor_keyring, $master_key)
}
exec { "check_${cluster[name]}.mon.keyring":
command => '/bin/yes',
onlyif => "/usr/bin/test -e $master_key",
}
file { "$libdir/${cluster[name]}.mon.keyring":
ensure => $f_action,
source => "puppet:///modules/ceph$libdir/${cluster[name]}.mon.keyring",
require => Exec["check_${cluster[name]}.mon.keyring"],
}
Thanks for any ideas on how to tackle this. I understand that this is... dis-incentivized in Puppet. What is a good approach?
puppet
It sounds like a job for exported resources. For that purpose, do the wanted files have distinct names for each node?
– John Bollinger
Nov 17 '18 at 12:43
Would heavily recommend using a native API and not a raw shell command forscp
in that function if you want to go that route.
– Matt Schuchard
Nov 17 '18 at 13:59
Thanks John, yes, the files are unique across the namespace. I have installed puppetDB and am looking to use Exported Resources, but it seems a pretty heavy lift to transfer a key file. I'll comment back here once I get things running.
– littlelion
Nov 18 '18 at 2:24
I agree Matt, that was a quick hack to see if I could get something working. Turned out to be a dead end which is why I posted here to see if there was a better approach someone could recommend.
– littlelion
Nov 18 '18 at 2:25
add a comment |
I am writing a puppet Ceph deployment module and need to generate keys on an admin node and distribute them to the monitor nodes. I have written server-side functions to retrieve the keys once they are generated, but would like to only distribute those keys once they exist.
- The manifest for the admin node generates the cluster keys
- Manifests for the monitor and management nodes need to include those keys as file resources
- The manifests should not fail to compile (or generate undue log volume) if they keys have not yet been generated
- The file resources need to be named as they are per-requisites for other resources
n.b. The examples are from Puppet3 so no Ruby dispatch :(
What is the philosophically pure approach to gather and distribute keys?
Sample code:
manifests/admin_node.pp:
exec { "make_${cluster[name]}_${name}_keyring":
command => "/usr/bin/ceph-authtool --create-keyring ${ring[file]} --gen-key -n ${ring[name]} ${ring[auth]}",
require => [ File[$confdir, $bootdir], Package['ceph-common'], ],
creates => $ring[file],
}
lib/puppet/parser/functions/get_remote_file.rb:
module Puppet::Parser::Functions
newfunction(:get_remote_file, :type => :rvalue) do |args|
return "Error 3: " + args.length.to_s + " arguments were provided to get_remote_file.rb. Required is 3 to 5." if args.length < 3 or args.length > 5
remote_host = args[0]
remote_path = args[1]
local_path = args[2]
local_user = (args.length > 3) ? 'runuser -l ' + args[3] + ' ' : ''
remote_user = (args.length > 4) ? args[4] + '@' : ''
# Is the file already down?
return 0 if File.exist?(local_path)
`"#{local_user}bash -c 'scp #{remote_user}#{remote_host}:#{remote_path} #{local_path} 2> /dev/null'"`
return $?.exitstatus
end
end
manifests/monitor_node.pp:
unless file_exists($master_key) {
get_remote_file($adm_node, $monitor_keyring, $master_key)
}
exec { "check_${cluster[name]}.mon.keyring":
command => '/bin/yes',
onlyif => "/usr/bin/test -e $master_key",
}
file { "$libdir/${cluster[name]}.mon.keyring":
ensure => $f_action,
source => "puppet:///modules/ceph$libdir/${cluster[name]}.mon.keyring",
require => Exec["check_${cluster[name]}.mon.keyring"],
}
Thanks for any ideas on how to tackle this. I understand that this is... dis-incentivized in Puppet. What is a good approach?
puppet
I am writing a puppet Ceph deployment module and need to generate keys on an admin node and distribute them to the monitor nodes. I have written server-side functions to retrieve the keys once they are generated, but would like to only distribute those keys once they exist.
- The manifest for the admin node generates the cluster keys
- Manifests for the monitor and management nodes need to include those keys as file resources
- The manifests should not fail to compile (or generate undue log volume) if they keys have not yet been generated
- The file resources need to be named as they are per-requisites for other resources
n.b. The examples are from Puppet3 so no Ruby dispatch :(
What is the philosophically pure approach to gather and distribute keys?
Sample code:
manifests/admin_node.pp:
exec { "make_${cluster[name]}_${name}_keyring":
command => "/usr/bin/ceph-authtool --create-keyring ${ring[file]} --gen-key -n ${ring[name]} ${ring[auth]}",
require => [ File[$confdir, $bootdir], Package['ceph-common'], ],
creates => $ring[file],
}
lib/puppet/parser/functions/get_remote_file.rb:
module Puppet::Parser::Functions
newfunction(:get_remote_file, :type => :rvalue) do |args|
return "Error 3: " + args.length.to_s + " arguments were provided to get_remote_file.rb. Required is 3 to 5." if args.length < 3 or args.length > 5
remote_host = args[0]
remote_path = args[1]
local_path = args[2]
local_user = (args.length > 3) ? 'runuser -l ' + args[3] + ' ' : ''
remote_user = (args.length > 4) ? args[4] + '@' : ''
# Is the file already down?
return 0 if File.exist?(local_path)
`"#{local_user}bash -c 'scp #{remote_user}#{remote_host}:#{remote_path} #{local_path} 2> /dev/null'"`
return $?.exitstatus
end
end
manifests/monitor_node.pp:
unless file_exists($master_key) {
get_remote_file($adm_node, $monitor_keyring, $master_key)
}
exec { "check_${cluster[name]}.mon.keyring":
command => '/bin/yes',
onlyif => "/usr/bin/test -e $master_key",
}
file { "$libdir/${cluster[name]}.mon.keyring":
ensure => $f_action,
source => "puppet:///modules/ceph$libdir/${cluster[name]}.mon.keyring",
require => Exec["check_${cluster[name]}.mon.keyring"],
}
Thanks for any ideas on how to tackle this. I understand that this is... dis-incentivized in Puppet. What is a good approach?
puppet
puppet
asked Nov 17 '18 at 3:16
littlelionlittlelion
11
11
It sounds like a job for exported resources. For that purpose, do the wanted files have distinct names for each node?
– John Bollinger
Nov 17 '18 at 12:43
Would heavily recommend using a native API and not a raw shell command forscp
in that function if you want to go that route.
– Matt Schuchard
Nov 17 '18 at 13:59
Thanks John, yes, the files are unique across the namespace. I have installed puppetDB and am looking to use Exported Resources, but it seems a pretty heavy lift to transfer a key file. I'll comment back here once I get things running.
– littlelion
Nov 18 '18 at 2:24
I agree Matt, that was a quick hack to see if I could get something working. Turned out to be a dead end which is why I posted here to see if there was a better approach someone could recommend.
– littlelion
Nov 18 '18 at 2:25
add a comment |
It sounds like a job for exported resources. For that purpose, do the wanted files have distinct names for each node?
– John Bollinger
Nov 17 '18 at 12:43
Would heavily recommend using a native API and not a raw shell command forscp
in that function if you want to go that route.
– Matt Schuchard
Nov 17 '18 at 13:59
Thanks John, yes, the files are unique across the namespace. I have installed puppetDB and am looking to use Exported Resources, but it seems a pretty heavy lift to transfer a key file. I'll comment back here once I get things running.
– littlelion
Nov 18 '18 at 2:24
I agree Matt, that was a quick hack to see if I could get something working. Turned out to be a dead end which is why I posted here to see if there was a better approach someone could recommend.
– littlelion
Nov 18 '18 at 2:25
It sounds like a job for exported resources. For that purpose, do the wanted files have distinct names for each node?
– John Bollinger
Nov 17 '18 at 12:43
It sounds like a job for exported resources. For that purpose, do the wanted files have distinct names for each node?
– John Bollinger
Nov 17 '18 at 12:43
Would heavily recommend using a native API and not a raw shell command for
scp
in that function if you want to go that route.– Matt Schuchard
Nov 17 '18 at 13:59
Would heavily recommend using a native API and not a raw shell command for
scp
in that function if you want to go that route.– Matt Schuchard
Nov 17 '18 at 13:59
Thanks John, yes, the files are unique across the namespace. I have installed puppetDB and am looking to use Exported Resources, but it seems a pretty heavy lift to transfer a key file. I'll comment back here once I get things running.
– littlelion
Nov 18 '18 at 2:24
Thanks John, yes, the files are unique across the namespace. I have installed puppetDB and am looking to use Exported Resources, but it seems a pretty heavy lift to transfer a key file. I'll comment back here once I get things running.
– littlelion
Nov 18 '18 at 2:24
I agree Matt, that was a quick hack to see if I could get something working. Turned out to be a dead end which is why I posted here to see if there was a better approach someone could recommend.
– littlelion
Nov 18 '18 at 2:25
I agree Matt, that was a quick hack to see if I could get something working. Turned out to be a dead end which is why I posted here to see if there was a better approach someone could recommend.
– littlelion
Nov 18 '18 at 2:25
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347866%2fhow-can-a-puppet-resource-check-for-a-data-source-on-the-puppetmaster-without-fa%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347866%2fhow-can-a-puppet-resource-check-for-a-data-source-on-the-puppetmaster-without-fa%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It sounds like a job for exported resources. For that purpose, do the wanted files have distinct names for each node?
– John Bollinger
Nov 17 '18 at 12:43
Would heavily recommend using a native API and not a raw shell command for
scp
in that function if you want to go that route.– Matt Schuchard
Nov 17 '18 at 13:59
Thanks John, yes, the files are unique across the namespace. I have installed puppetDB and am looking to use Exported Resources, but it seems a pretty heavy lift to transfer a key file. I'll comment back here once I get things running.
– littlelion
Nov 18 '18 at 2:24
I agree Matt, that was a quick hack to see if I could get something working. Turned out to be a dead end which is why I posted here to see if there was a better approach someone could recommend.
– littlelion
Nov 18 '18 at 2:25