summaryrefslogtreecommitdiffstats
path: root/acceptance
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-06-02 16:24:16 -0700
committerNick Lewis <nick@puppetlabs.com>2011-06-06 15:49:38 -0700
commit1c70f0ce54022b55119b9e2d6d60cd1ae9bc019e (patch)
tree35a7c2372773859c688cc4778a7c5507221553fa /acceptance
parentc629958fb45f9ae3581f01835bf89654dd7967b7 (diff)
downloadpuppet-1c70f0ce54022b55119b9e2d6d60cd1ae9bc019e.tar.gz
puppet-1c70f0ce54022b55119b9e2d6d60cd1ae9bc019e.tar.xz
puppet-1c70f0ce54022b55119b9e2d6d60cd1ae9bc019e.zip
(#2128) Add support for setting node name based on a fact
This adds the node_name_fact setting, which specifies a fact to use to determine the node name. This allows dynamically determining the node name without having to modify puppet.conf or command line options. Using this setting requires modifying auth.conf to allow nodes to request catalogs not matching their certnames. For example, this would allow any authenticated node to retrieve any catalog: # $confdir/auth.conf path ~ /catalog/.+ allow * The node_name_fact and node_name_value options are mutually exclusive, because it is ambiguous which setting should take precedence. Paired-With: Jacob Helwig <jacob@puppetlabs.com>
Diffstat (limited to 'acceptance')
-rw-r--r--acceptance/tests/allow_arbitrary_node_name_fact_for_agent.rb46
-rw-r--r--acceptance/tests/allow_arbitrary_node_name_fact_for_apply.rb30
2 files changed, 76 insertions, 0 deletions
diff --git a/acceptance/tests/allow_arbitrary_node_name_fact_for_agent.rb b/acceptance/tests/allow_arbitrary_node_name_fact_for_agent.rb
new file mode 100644
index 000000000..2e89d765f
--- /dev/null
+++ b/acceptance/tests/allow_arbitrary_node_name_fact_for_agent.rb
@@ -0,0 +1,46 @@
+test_name "node_name_fact should be used to determine the node name for puppet agent"
+
+success_message = "node_name_fact setting was correctly used to determine the node name"
+
+node_names = []
+
+on agents, facter('kernel') do
+ node_names << stdout.chomp
+end
+
+node_names.uniq!
+
+authfile = "/tmp/auth.conf-2128-#{$$}"
+authconf = node_names.map do |node_name|
+ %Q[
+path /catalog/#{node_name}
+auth yes
+allow *
+]
+end.join("\n")
+
+manifest_file = "/tmp/node_name_value-test-#{$$}.pp"
+manifest = %Q[
+ Exec { path => "/usr/bin:/bin" }
+ node default {
+ exec { "false": }
+ }
+]
+manifest << node_names.map do |node_name|
+ %Q[
+ node "#{node_name}" {
+ exec { "echo #{success_message}": }
+ }
+ ]
+end.join("\n")
+
+create_remote_file master, authfile, authconf
+create_remote_file master, manifest_file, manifest
+
+on master, "chmod 644 #{authfile} #{manifest_file}"
+
+with_master_running_on(master, "--rest_authconfig #{authfile} --manifest #{manifest_file} --daemonize --autosign true") do
+ run_agent_on(agents, "--no-daemonize --verbose --onetime --node_name_fact kernel --server #{master}") do
+ assert_match(success_message, stdout)
+ end
+end
diff --git a/acceptance/tests/allow_arbitrary_node_name_fact_for_apply.rb b/acceptance/tests/allow_arbitrary_node_name_fact_for_apply.rb
new file mode 100644
index 000000000..d7cf2dcac
--- /dev/null
+++ b/acceptance/tests/allow_arbitrary_node_name_fact_for_apply.rb
@@ -0,0 +1,30 @@
+test_name "node_name_fact should be used to determine the node name for puppet apply"
+
+success_message = "node_name_fact setting was correctly used to determine the node name"
+
+node_names = []
+
+on agents, facter('kernel') do
+ node_names << stdout.chomp
+end
+
+node_names.uniq!
+
+manifest = %Q[
+ Exec { path => "/usr/bin:/bin" }
+ node default {
+ exec { "false": }
+ }
+]
+
+node_names.each do |node_name|
+ manifest << %Q[
+ node "#{node_name}" {
+ exec { "echo #{success_message}": }
+ }
+ ]
+end
+
+on agents, puppet_apply("--verbose --node_name_fact kernel"), :stdin => manifest do
+ assert_match(success_message, stdout)
+end