Issue #4780 has been updated by Nico Schottelius.
Added a test module for that at http://git.sans.ethz.ch/?p=puppet-modules/deftest_4780;a=summary, clonable via git://git.sans.ethz.ch/puppet-modules/deftest_4780. Test via undef using sources: node "sgv-nicosc-04" { deftest_4780::via_undef { "via_undef": source => "puppet:///deftest_4780/testfile", } } results into: r...@sgv-nicosc-04:~# puppetd --test --debug --trace debug: Failed to load library 'selinux' for feature 'selinux' debug: Puppet::Type::User::ProviderPw: file pw does not exist debug: Puppet::Type::User::ProviderDirectoryservice: file /usr/bin/dscl does not exist debug: Puppet::Type::User::ProviderLdap: true value when expecting false debug: Puppet::Type::User::ProviderUser_role_add: file roleadd does not exist debug: Failed to load library 'ldap' for feature 'ldap' debug: /File[/var/lib/puppet/state/graphs]: Autorequiring File[/var/lib/puppet/state] debug: /File[/var/lib/puppet/ssl/private_keys/sgv-nicosc-04.ethz.ch.pem]: Autorequiring File[/var/lib/puppet/ssl/private_keys] debug: /File[/var/lib/puppet/state/classes.txt]: Autorequiring File[/var/lib/puppet/state] debug: /File[/var/lib/puppet/clientbucket]: Autorequiring File[/var/lib/puppet] debug: /File[/var/lib/puppet/facts]: Autorequiring File[/var/lib/puppet] debug: /File[/var/lib/puppet/ssl/certificate_requests]: Autorequiring File[/var/lib/puppet/ssl] debug: /File[/var/lib/puppet/ssl/private]: Autorequiring File[/var/lib/puppet/ssl] debug: /File[/var/lib/puppet/ssl/certs/ca.pem]: Autorequiring File[/var/lib/puppet/ssl/certs] debug: /File[/var/lib/puppet/ssl/certs/sgv-nicosc-04.ethz.ch.pem]: Autorequiring File[/var/lib/puppet/ssl/certs] debug: /File[/var/lib/puppet/ssl/private_keys]: Autorequiring File[/var/lib/puppet/ssl] debug: /File[/var/lib/puppet/ssl]: Autorequiring File[/var/lib/puppet] debug: /File[/var/lib/puppet/state]: Autorequiring File[/var/lib/puppet] debug: /File[/var/lib/puppet/ssl/public_keys/sgv-nicosc-04.ethz.ch.pem]: Autorequiring File[/var/lib/puppet/ssl/public_keys] debug: /File[/var/lib/puppet/client_yaml]: Autorequiring File[/var/lib/puppet] debug: /File[/var/lib/puppet/ssl/certs]: Autorequiring File[/var/lib/puppet/ssl] debug: /File[/var/lib/puppet/lib]: Autorequiring File[/var/lib/puppet] debug: /File[/var/lib/puppet/state/state.yaml]: Autorequiring File[/var/lib/puppet/state] debug: /File[/var/lib/puppet/ssl/crl.pem]: Autorequiring File[/var/lib/puppet/ssl] debug: /File[/etc/puppet/puppet.conf]: Autorequiring File[/etc/puppet] debug: /File[/var/lib/puppet/ssl/public_keys]: Autorequiring File[/var/lib/puppet/ssl] debug: /File[/var/run/puppet/puppetd.pid]: Autorequiring File[/var/run/puppet] debug: Finishing transaction 70353485056040 with 0 changes debug: Using cached certificate for ca, good until Tue Sep 02 13:24:09 UTC 2014 debug: Using cached certificate for sgv-nicosc-04.ethz.ch, good until Sun Aug 30 13:50:23 UTC 2015 debug: Loaded state in 0.00 seconds info: Retrieving plugin debug: Using cached certificate for ca, good until Tue Sep 02 13:24:09 UTC 2014 debug: Using cached certificate for sgv-nicosc-04.ethz.ch, good until Sun Aug 30 13:50:23 UTC 2015 debug: Using cached certificate_revocation_list for ca, good until debug: file_metadata supports formats: b64_zlib_yaml marshal pson raw yaml; using pson /usr/lib/ruby/1.8/net/http.rb:1060:in `request' /usr/lib/ruby/1.8/net/http.rb:772:in `get' /usr/lib/ruby/1.8/puppet/indirector/rest.rb:73:in `search' /usr/lib/ruby/1.8/puppet/indirector/indirection.rb:240:in `search' /usr/lib/ruby/1.8/puppet/indirector.rb:59:in `search' /usr/lib/ruby/1.8/puppet/type/file.rb:595:in `perform_recursion' /usr/lib/ruby/1.8/puppet/type/file.rb:562:in `recurse_remote' /usr/lib/ruby/1.8/puppet/type/file.rb:561:in `collect' /usr/lib/ruby/1.8/puppet/type/file.rb:561:in `recurse_remote' /usr/lib/ruby/1.8/puppet/type/file.rb:483:in `recurse' /usr/lib/ruby/1.8/puppet/type/file.rb:385:in `eval_generate' /usr/lib/ruby/1.8/puppet/transaction.rb:349:in `send' /usr/lib/ruby/1.8/puppet/transaction.rb:349:in `generate_additional_resources' /usr/lib/ruby/1.8/puppet/transaction.rb:193:in `eval_generate' /usr/lib/ruby/1.8/puppet/transaction.rb:240:in `eval_children_and_apply_resource' /usr/lib/ruby/1.8/puppet/transaction.rb:207:in `eval_resource' /usr/lib/ruby/1.8/puppet/transaction.rb:296:in `evaluate' /usr/lib/ruby/1.8/puppet/util.rb:418:in `thinmark' /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime' /usr/lib/ruby/1.8/puppet/util.rb:417:in `thinmark' /usr/lib/ruby/1.8/puppet/transaction.rb:295:in `evaluate' /usr/lib/ruby/1.8/puppet/transaction.rb:289:in `collect' /usr/lib/ruby/1.8/puppet/transaction.rb:289:in `evaluate' /usr/lib/ruby/1.8/puppet/resource/catalog.rb:142:in `apply' /usr/lib/ruby/1.8/puppet/configurer/downloader.rb:32:in `evaluate' /usr/lib/ruby/1.8/timeout.rb:62:in `timeout' /usr/lib/ruby/1.8/puppet/configurer/downloader.rb:31:in `evaluate' /usr/lib/ruby/1.8/puppet/configurer/plugin_handler.rb:12:in `download_plugins' /usr/lib/ruby/1.8/puppet/configurer.rb:85:in `prepare' /usr/lib/ruby/1.8/puppet/configurer.rb:152:in `run' /usr/lib/ruby/1.8/puppet/agent.rb:53:in `run' /usr/lib/ruby/1.8/puppet/agent/locker.rb:21:in `lock' /usr/lib/ruby/1.8/puppet/agent.rb:53:in `run' /usr/lib/ruby/1.8/sync.rb:230:in `synchronize' /usr/lib/ruby/1.8/puppet/agent.rb:53:in `run' /usr/lib/ruby/1.8/puppet/agent.rb:134:in `with_client' /usr/lib/ruby/1.8/puppet/agent.rb:51:in `run' /usr/lib/ruby/1.8/puppet/application/puppetd.rb:103:in `onetime' /usr/lib/ruby/1.8/puppet/application.rb:226:in `send' /usr/lib/ruby/1.8/puppet/application.rb:226:in `run_command' /usr/lib/ruby/1.8/puppet/application.rb:217:in `run' /usr/lib/ruby/1.8/puppet/application.rb:306:in `exit_on_fail' /usr/lib/ruby/1.8/puppet/application.rb:217:in `run' /usr/sbin/puppetd:159 err: /File[/var/lib/puppet/lib]: Failed to generate additional resources using 'eval_generate': undefined method `closed?' for nil:NilClass debug: file_metadata supports formats: b64_zlib_yaml marshal pson raw yaml; using pson /usr/lib/ruby/1.8/puppet/parameter.rb:401:in `fail' /usr/lib/ruby/1.8/puppet/type/file/source.rb:157:in `init_metadata' /usr/lib/ruby/1.8/puppet/type/file/source.rb:149:in `each' /usr/lib/ruby/1.8/puppet/type/file/source.rb:149:in `init_metadata' /usr/lib/ruby/1.8/puppet/util/cacher.rb:106:in `send' /usr/lib/ruby/1.8/puppet/util/cacher.rb:106:in `cached_value' /usr/lib/ruby/1.8/puppet/util/cacher.rb:46:in `metadata' /usr/lib/ruby/1.8/puppet/type/file/source.rb:111:in `copy_source_values' /usr/lib/ruby/1.8/puppet/type/file.rb:630:in `retrieve' /usr/lib/ruby/1.8/puppet/type.rb:726:in `evaluate' /usr/lib/ruby/1.8/puppet/transaction.rb:62:in `apply' /usr/lib/ruby/1.8/puppet/transaction.rb:251:in `eval_children_and_apply_resource' /usr/lib/ruby/1.8/puppet/util.rb:418:in `thinmark' /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime' /usr/lib/ruby/1.8/puppet/util.rb:417:in `thinmark' /usr/lib/ruby/1.8/puppet/transaction.rb:250:in `eval_children_and_apply_resource' /usr/lib/ruby/1.8/puppet/transaction.rb:207:in `eval_resource' /usr/lib/ruby/1.8/puppet/transaction.rb:296:in `evaluate' /usr/lib/ruby/1.8/puppet/util.rb:418:in `thinmark' /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime' /usr/lib/ruby/1.8/puppet/util.rb:417:in `thinmark' /usr/lib/ruby/1.8/puppet/transaction.rb:295:in `evaluate' /usr/lib/ruby/1.8/puppet/transaction.rb:289:in `collect' /usr/lib/ruby/1.8/puppet/transaction.rb:289:in `evaluate' /usr/lib/ruby/1.8/puppet/resource/catalog.rb:142:in `apply' /usr/lib/ruby/1.8/puppet/configurer/downloader.rb:32:in `evaluate' /usr/lib/ruby/1.8/timeout.rb:62:in `timeout' /usr/lib/ruby/1.8/puppet/configurer/downloader.rb:31:in `evaluate' /usr/lib/ruby/1.8/puppet/configurer/plugin_handler.rb:12:in `download_plugins' /usr/lib/ruby/1.8/puppet/configurer.rb:85:in `prepare' /usr/lib/ruby/1.8/puppet/configurer.rb:152:in `run' /usr/lib/ruby/1.8/puppet/agent.rb:53:in `run' /usr/lib/ruby/1.8/puppet/agent/locker.rb:21:in `lock' /usr/lib/ruby/1.8/puppet/agent.rb:53:in `run' /usr/lib/ruby/1.8/sync.rb:230:in `synchronize' /usr/lib/ruby/1.8/puppet/agent.rb:53:in `run' /usr/lib/ruby/1.8/puppet/agent.rb:134:in `with_client' /usr/lib/ruby/1.8/puppet/agent.rb:51:in `run' /usr/lib/ruby/1.8/puppet/application/puppetd.rb:103:in `onetime' /usr/lib/ruby/1.8/puppet/application.rb:226:in `send' /usr/lib/ruby/1.8/puppet/application.rb:226:in `run_command' /usr/lib/ruby/1.8/puppet/application.rb:217:in `run' /usr/lib/ruby/1.8/puppet/application.rb:306:in `exit_on_fail' /usr/lib/ruby/1.8/puppet/application.rb:217:in `run' /usr/sbin/puppetd:159 err: /File[/var/lib/puppet/lib]: Failed to retrieve current state of resource: undefined method `closed?' for nil:NilClass Could not retrieve file metadata for puppet://puppet/plugins: undefined method `closed?' for nil:NilClass debug: Finishing transaction 70353484660700 with 0 changes debug: Executing '/etc/puppet/etckeeper-commit-pre' info: Loading facts in test_facter info: Loading facts in rubygems_bindir info: Loading facts in rubygems_version info: Loading facts in puppet_ssldir info: Loading facts in test_facter info: Loading facts in rubygems_bindir info: Loading facts in rubygems_version info: Loading facts in puppet_ssldir debug: catalog supports formats: b64_zlib_yaml marshal pson raw yaml; using pson /usr/lib/ruby/1.8/net/http.rb:1060:in `request' /usr/lib/ruby/1.8/net/http.rb:772:in `get' /usr/lib/ruby/1.8/puppet/indirector/rest.rb:69:in `find' /usr/lib/ruby/1.8/puppet/indirector/indirection.rb:195:in `find' /usr/lib/ruby/1.8/puppet/indirector.rb:51:in `find' /usr/lib/ruby/1.8/puppet/configurer.rb:106:in `retrieve_catalog' /usr/lib/ruby/1.8/puppet/util.rb:418:in `thinmark' /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime' /usr/lib/ruby/1.8/puppet/util.rb:417:in `thinmark' /usr/lib/ruby/1.8/puppet/configurer.rb:105:in `retrieve_catalog' /usr/lib/ruby/1.8/puppet/configurer.rb:162:in `run' /usr/lib/ruby/1.8/puppet/agent.rb:53:in `run' /usr/lib/ruby/1.8/puppet/agent/locker.rb:21:in `lock' /usr/lib/ruby/1.8/puppet/agent.rb:53:in `run' /usr/lib/ruby/1.8/sync.rb:230:in `synchronize' /usr/lib/ruby/1.8/puppet/agent.rb:53:in `run' /usr/lib/ruby/1.8/puppet/agent.rb:134:in `with_client' /usr/lib/ruby/1.8/puppet/agent.rb:51:in `run' /usr/lib/ruby/1.8/puppet/application/puppetd.rb:103:in `onetime' /usr/lib/ruby/1.8/puppet/application.rb:226:in `send' /usr/lib/ruby/1.8/puppet/application.rb:226:in `run_command' /usr/lib/ruby/1.8/puppet/application.rb:217:in `run' /usr/lib/ruby/1.8/puppet/application.rb:306:in `exit_on_fail' /usr/lib/ruby/1.8/puppet/application.rb:217:in `run' /usr/sbin/puppetd:159 err: Could not retrieve catalog from remote server: undefined method `closed?' for nil:NilClass warning: Not using cache on failed catalog err: Could not retrieve catalog; skipping run debug: Executing '/etc/puppet/etckeeper-commit-post' r...@sgv-nicosc-04:~# ---------------------------------------- Feature #4780: Allow $var=undef in define as parameter http://projects.puppetlabs.com/issues/4780 Author: Nico Schottelius Status: Needs more information Priority: Normal Assignee: Category: Target version: Affected version: Keywords: Branch: Hello! When we encapsulate a simple type like file with a define, we would like to let the simple type take care of errors and thus pass direct input to it. This does not work however: Current code: define nginx::site($ensure=present, $source=false, $content=false) { include nginx $config_file="/etc/nginx/sites-enabled/$name" file { $config_file: owner => "root", group => "root", mode => 0644, ensure => $ensure, source => $source ? { false => undef, default => $source, }, content => $content ? { false => undef, default => $content, }, notify => Service['nginx'], } } Expected code: define site($ensure=present, $source=undef, $content=undef) { include nginx $config_file="/etc/nginx/sites-enabled/$name" file { $config_file: owner => "root", group => "root", mode => 0644, ensure => $ensure, source => $source, content => $content, notify => Service['nginx'], } } If you allow specifying arguments for defined types, an optimised version would look even smaller: define site(__args_used=[file]) { include nginx $config_file="/etc/nginx/sites-enabled/$name" file { $config_file: owner => "root", group => "root", mode => 0644, notify => Service['nginx'], } } Whether the second or the third version or a complete different syntax would fit best is one question. Clear is that the first version is code redundancy and it should be possible to avoid it. -- You have received this notification because you have either subscribed to it, or are involved in it. To change your notification preferences, please click here: http://projects.puppetlabs.com/my/account -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
