Hello all,
I do face a strange problem using an auto-generated variable data. If the variable is define literally, it work fine.
Hope someone can explain me why this is not working.
On the second part (working one), I added ******* to show the differences.
Non Working Manifest :
# Note : $myprogram_version is retrieved from a facter
class myprogram {
# Define path of the latest myprogram installation file
# Maybe this ca be change to provide puppet:/// URL but not sure....
$myprogram_path = "/etc/puppetlabs/code/environments/production/modules/plex/files"
# Retrieve version on the share folder
#
# Get version from the dowloaded installation file
$myprogram_version_latest = generate ("/bin/bash", "-c", "ls $myprogram_path/myprogram_* | awk -F'[_]' '{print \$2}' | cut -d- -f1")
# Get the istallation file full URL (including name
$myprogram_source = generate ("/bin/bash", "-c", "ls $myprogram_path/myprogram_*")
# Get only the basename using stdlib
$myprogram_filename = basename($myprogram_source)
# Check if a newer version is existing
if versioncmp($myprogram_version_latest, $myprogram_version) > 0 {
# New Version is Available - Check Sessions
if Integer($myprogram_session) == 0 {
# No myprogram Session Running
# The update code goes below this note
file { "myprogram_installation_file":
path => "/tmp/$myprogram_filename",
ensure => file,
mode => '0777',
source => "puppet:///modules/plex/$myprogram_filename",
}
package { "myprogram_installation_process":
ensure => installed,
provider => dpkg,
source => "/tmp/$myprogram_filename",
subscribe => File['myprogram_installation_file'],
}
# End of the update code
} else {
notify { "Update available but session is running - ABORT": }
}
} else {
# No update, closing
#notify { "No update available : Current = $myprogram_version : New = $myprogram_latest": }
}
}
----------
Now, the working version :
# Note : $myprogram_version is retrieved from a facter
class myprogram {
# Define path of the latest myprogram installation file
# Maybe this ca be change to provide puppet:/// URL but not sure....
$myprogram_path = "/etc/puppetlabs/code/environments/production/modules/plex/files"
# Fill the installation filename directly
# ******************************************************
$install_file = 'myprogram_1.3.3_amd64.deb'
# ******************************************************
# Retrieve version on the share folder
#
# Get version from the dowloaded installation file
$myprogram_version_latest = generate ("/bin/bash", "-c", "ls $myprogram_path/myprogram_* | awk -F'[_]' '{print \$2}' | cut -d- -f1")
# Get only the basename using stdlib
$myprogram_filename = basename($myprogram_source)
# Check if a newer version is existing
if versioncmp($myprogram_version_latest, $myprogram_version) > 0 {
# New Version is Available - Check Sessions
if Integer($myprogram_session) == 0 {
# No myprogram Session Running
# The update code goes below this note
file { "myprogram_installation_file":
path => "/tmp/$myprogram_filename",
ensure => file,
mode => '0777',
# This is the change
# *****************************************************
source => "puppet:///modules/plex/$install_file",
# *****************************************************
}
package { "myprogram_installation_process":
ensure => installed,
provider => dpkg,
source => "/tmp/$myprogram_filename",
subscribe => File['myprogram_installation_file'],
}
# End of the update code
} else {
notify { "Update available but session is running - ABORT": }
}
} else {
# No update, closing
#notify { "No update available : Current = $myprogram_version : New = $myprogram_latest": }
}
}
----------
Thanks in advance for any advice !
↧