This message was deleted.
# bolt
s
This message was deleted.
y
Check the TargetSpec type definition in the documentation. IIRC facts stored under a target structure (if you’re using the facts plan or apply_prep to gather them)
In an apply() block you can use $facts as usual
m
I want to use the variable in een (string url to a package) in a package resource.
Now i have:
$releaseversion = Target.facts['os']['release']['major']
But that throws an error: 'facts' parameter 'target' expects a Target value, got Type[Target]
y
It should be not a type but variable of the type ($target.facts[…])
Or how your target variable is named
j
How about
Copy code
$target.facts.get('os.release.major')
👍🏻 1
m
Hmz i think my question is wrong? I need to ask how do I set te $target variable? I want to change the url thats used for a package based on the facts.['os]['release']['major'] fact
apply($centos_targets, { 'run_as' => 'root' }) {
package { 'repo':
ensure          => 'present',
install_options => [{ '--disablerepo' => '*pgdg*' }],
source          => "<https://download.postgresql.org/pub/repos/yum/reporpms/EL-${target.facts['os']['release']['major']}-x86_64/pgdg-redhat-repo-latest.noarch.rpm>",
}
}
y
1) use apply_prep() before apply() to gather facts 2) use $facts in an apply() block