How to access puppet hash name in templates The Next CEO of Stack OverflowPuppet defined...
Graph of the history of databases
Is it convenient to ask the journal's editor for two additional days to complete a review?
What CSS properties can the br tag have?
Can I calculate next year's exemptions based on this year's refund/amount owed?
How do I fit a non linear curve?
What was Carter Burke's job for "the company" in Aliens?
Aggressive Under-Indexing and no data for missing index
Does destroying a Lich's phylactery destroy the soul within it?
Why doesn't UK go for the same deal Japan has with EU to resolve Brexit?
Help/tips for a first time writer?
Can this note be analyzed as a non-chord tone?
Is it ever safe to open a suspicious HTML file (e.g. email attachment)?
Reshaping json / reparing json inside shell script (remove trailing comma)
A question about free fall, velocity, and the height of an object.
Is French Guiana a (hard) EU border?
"Eavesdropping" vs "Listen in on"
If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?
What is the difference between "hamstring tendon" and "common hamstring tendon"?
Is it okay to majorly distort historical facts while writing a fiction story?
Help! I cannot understand this game’s notations!
Traduction de « Life is a roller coaster »
Is it correct to say moon starry nights?
Strange use of "whether ... than ..." in official text
TikZ: How to fill area with a special pattern?
How to access puppet hash name in templates
The Next CEO of Stack OverflowPuppet defined resource - selective parameterization?Variables with a dashpuppet: file, template and variablesHow to write re-usable puppet definitions?How to access variable in puppetUse of hash in defined type for puppetOverriding Parameters in Previously Declared Puppet ResourcePuppet template erb if variable is not defined keep defaultPuppet template if defined syntaxPuppet resource dependency
I've defined a hash like so in my nodes.pp:
net::addr { "eth5":
rt => {
rt1 => {
address => '192.168.10.0',
netmask => '255.255.255.0',
gateway => '192.5.28.19',
src => '192.5.28.21'
},
}
What I can't get to access is the title of the hash in my templates, so I want to print out the title of the hash i.e. "eth5", how can I do that? Also I have a variable called $int in my define class in the file for my module (/etc/puppet/modules/net/addr.pp), how can I access that using the scope.lookupvar function from this template in the same module?
Thanks
Dan
puppet
bumped to the homepage by Community♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I've defined a hash like so in my nodes.pp:
net::addr { "eth5":
rt => {
rt1 => {
address => '192.168.10.0',
netmask => '255.255.255.0',
gateway => '192.5.28.19',
src => '192.5.28.21'
},
}
What I can't get to access is the title of the hash in my templates, so I want to print out the title of the hash i.e. "eth5", how can I do that? Also I have a variable called $int in my define class in the file for my module (/etc/puppet/modules/net/addr.pp), how can I access that using the scope.lookupvar function from this template in the same module?
Thanks
Dan
puppet
bumped to the homepage by Community♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
In the case of that example, theeth5
is the title of the resource being defined, not related to the hash variable being used as a parameter to the resource - can you clarify how this this fits in with the defined type you're using?
– Shane Madden♦
Feb 21 '13 at 7:41
Hi Shane, I'm using the following in my class: define addr::net ($route={},){$int = $name file { "routes-${name}": ensure => 'present', mode => '0655', owner => 'root', group => 'root', path=> "/opt/routes/route-${name}", content => template('net/routes-temp.erb'),}. In my templates file I can't don't know how to access this $int or $name variable from my templates alternatively how would I access the title from my template? Thanks Dan
– Dan
Feb 21 '13 at 9:36
add a comment |
I've defined a hash like so in my nodes.pp:
net::addr { "eth5":
rt => {
rt1 => {
address => '192.168.10.0',
netmask => '255.255.255.0',
gateway => '192.5.28.19',
src => '192.5.28.21'
},
}
What I can't get to access is the title of the hash in my templates, so I want to print out the title of the hash i.e. "eth5", how can I do that? Also I have a variable called $int in my define class in the file for my module (/etc/puppet/modules/net/addr.pp), how can I access that using the scope.lookupvar function from this template in the same module?
Thanks
Dan
puppet
I've defined a hash like so in my nodes.pp:
net::addr { "eth5":
rt => {
rt1 => {
address => '192.168.10.0',
netmask => '255.255.255.0',
gateway => '192.5.28.19',
src => '192.5.28.21'
},
}
What I can't get to access is the title of the hash in my templates, so I want to print out the title of the hash i.e. "eth5", how can I do that? Also I have a variable called $int in my define class in the file for my module (/etc/puppet/modules/net/addr.pp), how can I access that using the scope.lookupvar function from this template in the same module?
Thanks
Dan
puppet
puppet
asked Feb 20 '13 at 16:28
DanDan
2271414
2271414
bumped to the homepage by Community♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
In the case of that example, theeth5
is the title of the resource being defined, not related to the hash variable being used as a parameter to the resource - can you clarify how this this fits in with the defined type you're using?
– Shane Madden♦
Feb 21 '13 at 7:41
Hi Shane, I'm using the following in my class: define addr::net ($route={},){$int = $name file { "routes-${name}": ensure => 'present', mode => '0655', owner => 'root', group => 'root', path=> "/opt/routes/route-${name}", content => template('net/routes-temp.erb'),}. In my templates file I can't don't know how to access this $int or $name variable from my templates alternatively how would I access the title from my template? Thanks Dan
– Dan
Feb 21 '13 at 9:36
add a comment |
In the case of that example, theeth5
is the title of the resource being defined, not related to the hash variable being used as a parameter to the resource - can you clarify how this this fits in with the defined type you're using?
– Shane Madden♦
Feb 21 '13 at 7:41
Hi Shane, I'm using the following in my class: define addr::net ($route={},){$int = $name file { "routes-${name}": ensure => 'present', mode => '0655', owner => 'root', group => 'root', path=> "/opt/routes/route-${name}", content => template('net/routes-temp.erb'),}. In my templates file I can't don't know how to access this $int or $name variable from my templates alternatively how would I access the title from my template? Thanks Dan
– Dan
Feb 21 '13 at 9:36
In the case of that example, the
eth5
is the title of the resource being defined, not related to the hash variable being used as a parameter to the resource - can you clarify how this this fits in with the defined type you're using?– Shane Madden♦
Feb 21 '13 at 7:41
In the case of that example, the
eth5
is the title of the resource being defined, not related to the hash variable being used as a parameter to the resource - can you clarify how this this fits in with the defined type you're using?– Shane Madden♦
Feb 21 '13 at 7:41
Hi Shane, I'm using the following in my class: define addr::net ($route={},){$int = $name file { "routes-${name}": ensure => 'present', mode => '0655', owner => 'root', group => 'root', path=> "/opt/routes/route-${name}", content => template('net/routes-temp.erb'),}. In my templates file I can't don't know how to access this $int or $name variable from my templates alternatively how would I access the title from my template? Thanks Dan
– Dan
Feb 21 '13 at 9:36
Hi Shane, I'm using the following in my class: define addr::net ($route={},){$int = $name file { "routes-${name}": ensure => 'present', mode => '0655', owner => 'root', group => 'root', path=> "/opt/routes/route-${name}", content => template('net/routes-temp.erb'),}. In my templates file I can't don't know how to access this $int or $name variable from my templates alternatively how would I access the title from my template? Thanks Dan
– Dan
Feb 21 '13 at 9:36
add a comment |
2 Answers
2
active
oldest
votes
The variables set in the defined type are available as local scope variables to the contents of a template.
Simply using <%= title %>
or <%= int %>
in the template should be using the variable that was set for that specific instance of the defined type.
add a comment |
In your example, you should be using the namevar, $name
.
For example, if you define a resource like this:
objecttype { "namevar": parameter=>"value" }
Then the variables will be set thusly:
$name = "namevar"
$parameter = "value"
Within templates called from the define, these can be simply referred to a $name
and $parameter
(but watch out for reserved words!).
add a comment |
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f480727%2fhow-to-access-puppet-hash-name-in-templates%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The variables set in the defined type are available as local scope variables to the contents of a template.
Simply using <%= title %>
or <%= int %>
in the template should be using the variable that was set for that specific instance of the defined type.
add a comment |
The variables set in the defined type are available as local scope variables to the contents of a template.
Simply using <%= title %>
or <%= int %>
in the template should be using the variable that was set for that specific instance of the defined type.
add a comment |
The variables set in the defined type are available as local scope variables to the contents of a template.
Simply using <%= title %>
or <%= int %>
in the template should be using the variable that was set for that specific instance of the defined type.
The variables set in the defined type are available as local scope variables to the contents of a template.
Simply using <%= title %>
or <%= int %>
in the template should be using the variable that was set for that specific instance of the defined type.
answered Feb 22 '13 at 5:10
Shane Madden♦Shane Madden
104k9146222
104k9146222
add a comment |
add a comment |
In your example, you should be using the namevar, $name
.
For example, if you define a resource like this:
objecttype { "namevar": parameter=>"value" }
Then the variables will be set thusly:
$name = "namevar"
$parameter = "value"
Within templates called from the define, these can be simply referred to a $name
and $parameter
(but watch out for reserved words!).
add a comment |
In your example, you should be using the namevar, $name
.
For example, if you define a resource like this:
objecttype { "namevar": parameter=>"value" }
Then the variables will be set thusly:
$name = "namevar"
$parameter = "value"
Within templates called from the define, these can be simply referred to a $name
and $parameter
(but watch out for reserved words!).
add a comment |
In your example, you should be using the namevar, $name
.
For example, if you define a resource like this:
objecttype { "namevar": parameter=>"value" }
Then the variables will be set thusly:
$name = "namevar"
$parameter = "value"
Within templates called from the define, these can be simply referred to a $name
and $parameter
(but watch out for reserved words!).
In your example, you should be using the namevar, $name
.
For example, if you define a resource like this:
objecttype { "namevar": parameter=>"value" }
Then the variables will be set thusly:
$name = "namevar"
$parameter = "value"
Within templates called from the define, these can be simply referred to a $name
and $parameter
(but watch out for reserved words!).
answered Aug 9 '13 at 1:59
Steve ShipwaySteve Shipway
540312
540312
add a comment |
add a comment |
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f480727%2fhow-to-access-puppet-hash-name-in-templates%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
In the case of that example, the
eth5
is the title of the resource being defined, not related to the hash variable being used as a parameter to the resource - can you clarify how this this fits in with the defined type you're using?– Shane Madden♦
Feb 21 '13 at 7:41
Hi Shane, I'm using the following in my class: define addr::net ($route={},){$int = $name file { "routes-${name}": ensure => 'present', mode => '0655', owner => 'root', group => 'root', path=> "/opt/routes/route-${name}", content => template('net/routes-temp.erb'),}. In my templates file I can't don't know how to access this $int or $name variable from my templates alternatively how would I access the title from my template? Thanks Dan
– Dan
Feb 21 '13 at 9:36