I'm moving towards paramaterized classes and am beginning to try out
smart variables, but am unable to save any. I enter even the most
basic info…
Name - chroot_base
Desc - Chroot environment base directory
Default value - /chroot
Type validator - string
Validator constraint - <blank>
Order - <default>
Match - hostgroup=web_server
Value - /chroot
When I submit, I'm returned to that puppet classes' Primary tab and
can go back to the Smart Variable and view it. At that time I've
checked the lookup_keys and lookup_values tables and found nothing.
Also the "Settings -> Smart Variables" shows nothing. If I navigate
off that page and return the smart variables are gone.
Here's the production.log output during the submit of the smart
variable:
···
-------
Processing PuppetclassesController#update (for 128.194.187.98 at
2012-01-03 10:32:11) [PUT]
Parameters: {"commit"=>"Submit", "authenticity_token"=>"FV/8/
chFOEddPnsMHlK7O3jxmASVvSfHXlp1BlGAPiY=",
"puppetclass"=>{"lookup_keys_attributes"=>{"new_lookup_keys"=>{"updated_at"=>"1325608330",
"default_value"=>"", "validator_rule"=>"",
"lookup_values_attributes"=>{"new_lookup_values"=>{"value"=>"",
"_destroy"=>"", "match"=>""}}, "description"=>"",
"validator_type"=>"", "path"=>"fqdn\r\nhostgroup\r\nos\r\ndomain",
"key"=>"", "_destroy"=>""}, "0"=>{"updated_at"=>"1325608330",
"default_value"=>"/chroot", "validator_rule"=>"",
"lookup_values_attributes"=>{"new_lookup_values"=>{"value"=>"",
"_destroy"=>"", "match"=>""}, "0"=>{"value"=>"/chroot",
"_destroy"=>"", "match"=>"hostgroup=web_server"}},
"description"=>"chroot environment base directory",
"validator_type"=>"", "path"=>"fqdn\r\nhostgroup\r\nos\r\ndomain",
"key"=>"chroot_base", "_destroy"=>""}}, "name"=>"chroot",
"environment_ids"=>["1", ""], "hostgroup_ids"=>["", "", "", "", ""]},
"id"=>"chroot"}
Rendering template within layouts/application
Rendering puppetclasses/edit
Completed in 270ms (View: 250, DB: 5) | 200 OK [https://
itscforeman.tamu.edu/puppetclasses/chroot]
Let me know what other information may be useful. This system is
CentOS 5.7, x86_64, ruby-1.8.5.
Thanks
Exact thing happened to me today when I started (tried) using smart
variables.
···
On Tuesday, January 3, 2012 6:07:26 PM UTC+1, treydock wrote:
>
> I'm moving towards paramaterized classes and am beginning to try out
> smart variables, but am unable to save any. I enter even the most
> basic info...
>
–
Mike
thats a silly bug, save the smart var with no additional matchers
first, then edit it again…
sorry,
Ohad
···
On Fri, Jan 20, 2012 at 2:13 AM, Mikael Fridh wrote:
> On Tuesday, January 3, 2012 6:07:26 PM UTC+1, treydock wrote:
>>
>> I'm moving towards paramaterized classes and am beginning to try out
>> smart variables, but am unable to save any. I enter even the most
>> basic info...
>
>
> Exact thing happened to me today when I started (tried) using smart
> variables.
>
> --
> Mike
>
> --
> You received this message because you are subscribed to the Google Groups
> "Foreman users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/foreman-users/-/t8EUJn5DU-gJ.
>
> To post to this group, send email to foreman-users@googlegroups.com.
> To unsubscribe from this group, send email to
> foreman-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/foreman-users?hl=en.
Excellent that worked.
Now that I can save smart variables, I think I may have misunderstood
their use. I thought this was how to pass parameterized classes and
their values to a node?
So a really simply example is my git module with git::web. In my
node.pp I would define this… and this works just fine.
class { 'git':
gitweb => true,
}
When I set the smart variable so that the fqdn=host , value=true, and
then I look at hte YAML output for this host I see it just has the
parameter provided "gitweb=true". But this never triggers the install
of gitweb. The module I used with the traditional parameterized is
here…
class git ( $gitweb=false ) {
package { 'git':
ensure => installed,
}
if $gitweb { include git::web }
}
Do modules have to be written to pull the variable value as if it were
defined in the "node" definition in node.pp?
Thanks
···
On Jan 20, 12:15 pm, Ohad Levy wrote:
> thats a silly bug, save the smart var with no additional matchers
> first, then edit it again...
>
> sorry,
> Ohad
>
>
>
>
>
>
>
> On Fri, Jan 20, 2012 at 2:13 AM, Mikael Fridh wrote:
> > On Tuesday, January 3, 2012 6:07:26 PM UTC+1, treydock wrote:
>
> >> I'm moving towards paramaterized classes and am beginning to try out
> >> smart variables, but am unable to save any. I enter even the most
> >> basic info...
>
> > Exact thing happened to me today when I started (tried) using smart
> > variables.
>
> > --
> > Mike
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Foreman users" group.
> > To view this discussion on the web visit
> >https://groups.google.com/d/msg/foreman-users/-/t8EUJn5DU-gJ.
>
> > To post to this group, send email to foreman-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > foreman-users+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/foreman-users?hl=en.
> Excellent that worked.
Yep! I ran into the same bug.
> Now that I can save smart variables, I think I may have misunderstood
> their use. I thought this was how to pass parameterized classes and
> their values to a node?
I just ran into the same thing. Puppet modules also don't seem to pick
up variables passed by foreman host parameters either. As far as I can
see, you have to rewrite all modules to be foreman specific; which I
do not think I want to do.
> So a really simply example is my git module with git::web. In my
> node.pp I would define this… and this works just fine.
>
> class { 'git':
> gitweb => true,
>
> }
>
> When I set the smart variable so that the fqdn=host , value=true, and
> then I look at hte YAML output for this host I see it just has the
> parameter provided "gitweb=true". But this never triggers the install
> of gitweb. The module I used with the traditional parameterized is
> here…
>
> class git ( $gitweb=false ) {
>
> package { 'git':
> ensure => installed,
> }
>
> if $gitweb { include git::web }
>
> }
>
> Do modules have to be written to pull the variable value as if it were
> defined in the "node" definition in node.pp?
I don't know much yet, as I have just started testing as well, but it
looks like modules have to be written differently than standard
puppet. I sure hope that's not the case.
Right now I am trying to set sshd_allowed_users variables per host,
and if I have to edit them all via smart variables attached to the
class, that is rather cumbersome.
···
On Jan 30, 11:21 am, treydock wrote:
One way I've worked through half of this issue, at least with defines,
is to pass a string in JSON format from Foreman to my module. I wrote
this module to turn JSON strings to a hash, https://github.com/treydock/puppet-string2hash.
In my modules I put an if statement to check for the existence of the
variable, then pass it through create_resources to my defines. This
doesn't solve the parameterized issue, but it's a small step.
The module would have (works only to pass hash to defines not classes)
class ssh {
if $sshd_allowed_users {
allowed_users = string2hash($sshd_allowed_users)
create_resources('ssh::allowed_users', $allowed_users)
}
}
Another "hack" would be to write your class like this…
class ssh::allowed_users (
users=false
) {
if $sshd_allowed_users { $users = $sshd_allowed_users }
}
It's not a full rewrite of your modules but checking for that variable
to override the parameterized variables.
···
On Feb 7, 12:19 pm, Christian McHugh wrote:
> On Jan 30, 11:21 am, treydock wrote:
>
> > Excellent that worked.
>
> Yep! I ran into the same bug.
>
> > Now that I can save smart variables, I think I may have misunderstood
> > their use. I thought this was how to pass parameterized classes and
> > their values to a node?
>
> I just ran into the same thing. Puppet modules also don't seem to pick
> up variables passed by foreman host parameters either. As far as I can
> see, you have to rewrite all modules to be foreman specific; which I
> do not think I want to do.
>
>
>
>
>
>
>
>
>
> > So a really simply example is my git module with git::web. In my
> > node.pp I would define this.. and this works just fine.
>
> > class { 'git':
> > gitweb => true,
>
> > }
>
> > When I set the smart variable so that the fqdn=host , value=true, and
> > then I look at hte YAML output for this host I see it just has the
> > parameter provided "gitweb=true". But this never triggers the install
> > of gitweb. The module I used with the traditional parameterized is
> > here...
>
> > class git ( $gitweb=false ) {
>
> > package { 'git':
> > ensure => installed,
> > }
>
> > if $gitweb { include git::web }
>
> > }
>
> > Do modules have to be written to pull the variable value as if it were
> > defined in the "node" definition in node.pp?
>
> I don't know much yet, as I have just started testing as well, but it
> looks like modules have to be written differently than standard
> puppet. I sure hope that's not the case.
>
> Right now I am trying to set sshd_allowed_users variables per host,
> and if I have to edit them all via smart variables attached to the
> class, that is rather cumbersome.