Issue #21678 has been updated by Charlie Sharpsteen. Status changed from Unreviewed to Rejected Assignee set to Charlie Sharpsteen
The [hash method of Ruby objects](http://ruby-doc.org/core-2.0/Object.html#method-i-hash) does not return a digest, such as an MD5, that is generated from the data encapsulated by the object. Rather, it returns a number that is used internally by the Ruby interpreter to test quickly test equality of objects generated during the lifetime of the program. Importantly: > The hash value for an object may not be identical across invocations or > implementations of ruby. If you need a stable identifier across ruby > invocations and implementations you will need to generate one with a custom > method. For example, the Ruby 1.8.x interpreter uses the memory address objects are stored in to compute the hash value. Values derived in this way will never be consistent between Ruby invocations as the memory addresses used by the interpreter will vary from run to run. If you want a consistent hash value, you will need to use a digest function that calculates values based on content. A CRC digest may fit nicely in this situation as you are looking for a decimal number. ---------------------------------------- Bug #21678: inline_template hash always different on ${title} string https://projects.puppetlabs.com/issues/21678#change-94284 * Author: Daniel Taschik * Status: Rejected * Priority: Normal * Assignee: Charlie Sharpsteen * Category: cron * Target version: * Affected Puppet version: 3.2.2 * Keywords: cron * Branch: ---------------------------------------- I am trying to create a cron entry using the cron function. The minutes shall be calculated out of the title. Every time I run the manifest it creates a different time. Somehow the hash is always different although the title is still the same. <pre><code class="ruby"> define dbbackup() { $app_env = $title file { "/etc/profile.d/set_databasebackup_setting_${app_env}.sh": content => template('dbbackup/databasebackup_setting.sh'), ensure => present, } file {"/opt/backups/scripts/backup_${app_env}.sh": mode => '0755', content => template('dbbackup/backup.sh.erb'), require => File['/opt/backups/scripts'], } cron {"run_database_backup_${app_env}": command => "/opt/backups/scripts/backup_${app_env}.sh #${title}", minute => inline_template("<%= @title.hash.abs % 60 %>"), ensure => present, } </pre> I call the define like the following: <pre><code class="ruby"> dbbackup{'master':} dbbackup{'staging':} </pre> The created cron looks like this, except the time is always changing: <pre> # Puppet Name: run_database_backup_master 3 * * * * /opt/backups/scripts/backup_master.sh #master # Puppet Name: run_database_backup_staging 36 * * * * /opt/backups/scripts/backup_staging.sh #staging </pre> -- 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 unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/puppet-bugs. For more options, visit https://groups.google.com/groups/opt_out.
