Does anyone have some examples of using this create_resources function, https://github.com/puppetlabs/puppetlabs-create_resources, ? Based on the README example I can''t figure out exactly how to change from using defines to using this function. Maybe I misunderstand the purpose of create_resources...is it to replace defines, or is it to allow ENCs (for example) to use a define? Below is an example of a define I use for apache virtual hosts. From the example on the functions readme, does "class webserver::instances" use the information in $instances? So if I wanted to create files / directories from the information in $instances, would that be done in "class webserver::instances" or else where? Here''s the example... node ''webserver'' { apache::vhost { ''drupal-multisite1'': domain => ''com'', docroot => ''/var/www/example2.com/html'', options => ''None'', override => ''All'', protocol => ''http''; ''drupal-multisite2'': domain => ''com'', docroot => ''/var/www/example2.com/html'', create_docroot => false, options => ''None'', override => ''All'', protocol => ''http''; } } .... define apache::vhost ( $protocol=''http'', $cname=$name, $domain=false, $server_alias="www.$cname.$domain", $alias_list=false, $docroot=false, $create_docroot=true, $docroot_owner=false, $docroot_group=false, $docroot_mode=false, $options=false, $sendfile=true, $override=''None'', $order=''allow,deny'', $allowfrom=''all'', $denyfrom=false, $source=false ) { host{ "${name}.$domain": ensure => present, host_aliases => [ $name ], ip => $ipaddress_eth0, } if $create_docroot != false { file { "$docroot": ensure => directory, owner => $docroot_owner ? { false => undef, default => $docroot_owner, }, group => $docroot_group ? { false => undef, default => $docroot_group, }, mode => $docroot_mode ? { false => undef, default => $docroot_mode, }, require => Package[''httpd'']; } } file { "/etc/httpd/conf.d/$cname.conf": ensure => present, owner => ''root'', group => ''root'', mode => 644, content => $source ? { false => template(''apache/ virtualhost_conf.erb''), default => $source, }, require => Package[''httpd''], notify => Exec[''reload-apache''], } } Thanks - Trey -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Nan Liu
2011-Aug-17 17:59 UTC
Re: [Puppet Users] Using back-ported create_resources in 2.6.x
On Wed, Aug 17, 2011 at 10:27 AM, treydock <treydock@gmail.com> wrote:> Does anyone have some examples of using this create_resources > function, https://github.com/puppetlabs/puppetlabs-create_resources, > ? Based on the README example I can''t figure out exactly how to > change from using defines to using this function. Maybe I > misunderstand the purpose of create_resources...is it to replace > defines, or is it to allow ENCs (for example) to use a define?The purpose of create resources is not to replace define, but rather to declare resource from a hash. This is typically used to work around ENC limitation of class only so you can provide a hash to generate resources for a node.> Below is an example of a define I use for apache virtual hosts. From > the example on the functions readme, does "class webserver::instances" > use the information in $instances? So if I wanted to create files / > directories from the information in $instances, would that be done in > "class webserver::instances" or else where? > > Here''s the example... > > node ''webserver'' { > apache::vhost { > ''drupal-multisite1'': > domain => ''com'', > docroot => ''/var/www/example2.com/html'', > options => ''None'', > override => ''All'', > protocol => ''http''; > > ''drupal-multisite2'': > domain => ''com'', > docroot => ''/var/www/example2.com/html'', > create_docroot => false, > options => ''None'', > override => ''All'', > protocol => ''http''; > } > }So if you use create resource, instead of the section above would be: $vhost = { ''drupal-multisite1'' => { domain => ''com'', ... } } create_resource ("apache::vhost", $vhost) It would not change your existing define apache::vhost. Thanks, Nan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
treydock
2011-Aug-17 19:20 UTC
[Puppet Users] Re: Using back-ported create_resources in 2.6.x
Ah ok! That makes more sense now. Thanks - Trey On Aug 17, 12:59 pm, Nan Liu <n...@puppetlabs.com> wrote:> On Wed, Aug 17, 2011 at 10:27 AM, treydock <treyd...@gmail.com> wrote: > > Does anyone have some examples of using this create_resources > > function,https://github.com/puppetlabs/puppetlabs-create_resources, > > ? Based on the README example I can''t figure out exactly how to > > change from using defines to using this function. Maybe I > > misunderstand the purpose of create_resources...is it to replace > > defines, or is it to allow ENCs (for example) to use a define? > > The purpose of create resources is not to replace define, but rather > to declare resource from a hash. This is typically used to work around > ENC limitation of class only so you can provide a hash to generate > resources for a node. > > > > > > > > > > > Below is an example of a define I use for apache virtual hosts. From > > the example on the functions readme, does "class webserver::instances" > > use the information in $instances? So if I wanted to create files / > > directories from the information in $instances, would that be done in > > "class webserver::instances" or else where? > > > Here''s the example... > > > node ''webserver'' { > > apache::vhost { > > ''drupal-multisite1'': > > domain => ''com'', > > docroot => ''/var/www/example2.com/html'', > > options => ''None'', > > override => ''All'', > > protocol => ''http''; > > > ''drupal-multisite2'': > > domain => ''com'', > > docroot => ''/var/www/example2.com/html'', > > create_docroot => false, > > options => ''None'', > > override => ''All'', > > protocol => ''http''; > > } > > } > > So if you use create resource, instead of the section above would be: > > $vhost = { ''drupal-multisite1'' => { domain => ''com'', ... } } > > create_resource ("apache::vhost", $vhost) > > It would not change your existing define apache::vhost. > > Thanks, > > Nan-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
treydock
2011-Aug-17 19:57 UTC
[Puppet Users] Re: Using back-ported create_resources in 2.6.x
On Aug 17, 12:59 pm, Nan Liu <n...@puppetlabs.com> wrote:> On Wed, Aug 17, 2011 at 10:27 AM, treydock <treyd...@gmail.com> wrote: > > Does anyone have some examples of using this create_resources > > function,https://github.com/puppetlabs/puppetlabs-create_resources, > > ? Based on the README example I can''t figure out exactly how to > > change from using defines to using this function. Maybe I > > misunderstand the purpose of create_resources...is it to replace > > defines, or is it to allow ENCs (for example) to use a define? > > The purpose of create resources is not to replace define, but rather > to declare resource from a hash. This is typically used to work around > ENC limitation of class only so you can provide a hash to generate > resources for a node. > > > > > > > > > > > Below is an example of a define I use for apache virtual hosts. From > > the example on the functions readme, does "class webserver::instances" > > use the information in $instances? So if I wanted to create files / > > directories from the information in $instances, would that be done in > > "class webserver::instances" or else where? > > > Here''s the example... > > > node ''webserver'' { > > apache::vhost { > > ''drupal-multisite1'': > > domain => ''com'', > > docroot => ''/var/www/example2.com/html'', > > options => ''None'', > > override => ''All'', > > protocol => ''http''; > > > ''drupal-multisite2'': > > domain => ''com'', > > docroot => ''/var/www/example2.com/html'', > > create_docroot => false, > > options => ''None'', > > override => ''All'', > > protocol => ''http''; > > } > > } > > So if you use create resource, instead of the section above would be: > > $vhost = { ''drupal-multisite1'' => { domain => ''com'', ... } } > > create_resource ("apache::vhost", $vhost) > > It would not change your existing define apache::vhost. > > Thanks, > > NanHaving a bit of trouble now...and the error I''m getting is of no help. Here''s my parameter in node definition $redmine_instances = { ''default'' => { docroot => ''/var/www/rails/redmine'', db => ''redmine'', db_user => ''redmine'', db_pass => ''....'', }, } create_resources(''redmine::instance'', $redmine_instances) And the defines this is going to... define redmine::instance ( $instances = {} ) { file { "$instances[docroot]": ensure => directory, owner => ''apache'', } file {"$instances[docroot]/config/database.yml": content => "production: adapter: mysql database: $instances[db] host: localhost username: $instances[db_user] password: $instances[db_pass] encoding: utf8 ", } } That''s a trimmed down example, but the error I get is .... # puppetd --test --debug -v --noop debug: Puppet::Type::User::ProviderDirectoryservice: file /usr/bin/ dscl does not exist debug: Puppet::Type::User::ProviderPw: file pw 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: Puppet::Type::File::ProviderMicrosoft_windows: feature microsoft_windows is missing debug: Failed to load library ''ldap'' for feature ''ldap'' 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/state/state.yaml]: Autorequiring File[/ var/lib/puppet/state] debug: /File[/var/lib/puppet/ssl/certs/client.tld.pem]: Autorequiring File[/var/lib/puppet/ssl/certs] debug: /File[/var/lib/puppet/client_data]: Autorequiring File[/var/lib/ puppet] debug: /File[/var/lib/puppet/ssl/certs/ca.pem]: Autorequiring File[/ var/lib/puppet/ssl/certs] debug: /File[/etc/puppet/puppet.conf]: Autorequiring File[/etc/puppet] debug: /File[/var/lib/puppet/state/last_run_report.yaml]: Autorequiring File[/var/lib/puppet/state] debug: /File[/var/lib/puppet/ssl]: Autorequiring File[/var/lib/puppet] debug: /File[/var/lib/puppet/ssl/certs]: Autorequiring File[/var/lib/ puppet/ssl] debug: /File[/etc/puppet/namespaceauth.conf]: Autorequiring File[/etc/ puppet] debug: /File[/var/lib/puppet/ssl/private_keys]: Autorequiring File[/ var/lib/puppet/ssl] debug: /File[/var/lib/puppet/ssl/certificate_requests]: Autorequiring File[/var/lib/puppet/ssl] debug: /File[/var/lib/puppet/ssl/private_keys/client.tld.pem]: Autorequiring File[/var/lib/puppet/ssl/private_keys] debug: /File[/var/lib/puppet/state/last_run_summary.yaml]: Autorequiring File[/var/lib/puppet/state] debug: /File[/var/lib/puppet/ssl/crl.pem]: Autorequiring File[/var/lib/ puppet/ssl] debug: /File[/var/lib/puppet/lib]: Autorequiring File[/var/lib/puppet] debug: /File[/var/lib/puppet/classes.txt]: Autorequiring File[/var/lib/ puppet] debug: /File[/var/lib/puppet/client_yaml]: Autorequiring File[/var/lib/ puppet] debug: /File[/var/lib/puppet/ssl/private]: Autorequiring File[/var/lib/ puppet/ssl] debug: /File[/var/lib/puppet/ssl/public_keys]: Autorequiring File[/var/ lib/puppet/ssl] debug: /File[/var/lib/puppet/state]: Autorequiring File[/var/lib/ puppet] debug: /File[/var/lib/puppet/state/graphs]: Autorequiring File[/var/ lib/puppet/state] debug: /File[/var/lib/puppet/ssl/public_keys/client.tld.pem]: Autorequiring File[/var/lib/puppet/ssl/public_keys] debug: Finishing transaction 70351925169680 debug: /File[/var/lib/puppet/ssl/certs/client.tld.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/lib]: Autorequiring File[/var/lib/puppet] debug: /File[/var/lib/puppet/ssl/public_keys/client.tld.pem]: Autorequiring File[/var/lib/puppet/ssl/public_keys] debug: /File[/etc/puppet/namespaceauth.conf]: Autorequiring File[/etc/ puppet] debug: /File[/var/lib/puppet/ssl/certificate_requests]: Autorequiring File[/var/lib/puppet/ssl] debug: /File[/var/lib/puppet/ssl/certs]: Autorequiring File[/var/lib/ puppet/ssl] debug: /File[/var/lib/puppet/ssl/public_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/crl.pem]: Autorequiring File[/var/lib/ puppet/ssl] debug: /File[/var/lib/puppet/facts]: Autorequiring File[/var/lib/ puppet] debug: /File[/var/lib/puppet/ssl/private]: Autorequiring File[/var/lib/ puppet/ssl] debug: /File[/var/lib/puppet/ssl/private_keys/client.tld.pem]: Autorequiring File[/var/lib/puppet/ssl/private_keys] debug: /File[/var/lib/puppet/ssl/certs/ca.pem]: Autorequiring File[/ var/lib/puppet/ssl/certs] debug: Finishing transaction 70351925054020 debug: Using cached certificate for ca debug: Using cached certificate for client.tld notice: Ignoring --listen on onetime run debug: Finishing transaction 70351924614320 debug: Loaded state in 0.00 seconds debug: Using cached certificate for ca debug: Using cached certificate for client.tld debug: Using cached certificate_revocation_list for ca debug: catalog supports formats: b64_zlib_yaml dot marshal pson raw yaml; using yaml err: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid parameter db_user on node client.tld warning: Not using cache on failed catalog err: Could not retrieve catalog; skipping run debug: Using cached certificate for ca debug: Using cached certificate for client.tld debug: Using cached certificate_revocation_list for ca debug: report supports formats: b64_zlib_yaml marshal raw yaml; using yaml Thanks - Trey -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Seemingly Similar Threads
- Profiles, Hiera, and create_resources('class','...')
- Dependency Cycle with puppetlabs-mrepo
- Using single hiera hash for two create_resources, and mounting filesystems
- Does create_resources support virtual resources?
- Failed to parse template, wrong number of arguments (create_resources)