Closed hubizx closed 5 years ago
@hubizx You asked this in an issue in the repository containing specifications for the Puppet Language and eko system. Highly recommend you hop on to Slack to get in touch with other members of the community as there is always people around providing help and advice. The issue system here is for issues in the specifications themselves.
For Slack, head over here: https://slack.puppet.com/
To answer your question, I think your instructions to Augeas are wrong - you have given it a hash - and it tries to do a Ruby strip!
on a Hash. This has nothing to do with the strip()
function.
Look at this:
changes => [
"set /files/etc/ssh/sshd_config/PermitRootLogin yes",
onlyif => "match *[. = 'PermitRootLogin'] == 'no'",
],
The onlyif => "match *[. = 'PermitRootLogin'] == 'no'",
is inside the array for changes
, and since you used =>
there, it will take that as a hash - i.e. the same as if you had written:
{onlyif => "match *[. = 'PermitRootLogin'] == 'no'"}
.
I hope that helps. Closing this issue as it has nothing to do with the specifications in this repo. @hubizx please hop on to Slack if you need further help.
Thanks for answer, will write on slac for such cases. Only add there is no way to write "onlyif" sentence, everything gives "undefined method `strip!"
/opt/puppetlabs/puppet/vendor_modules/augeas_core/lib/puppet/provider/augeas/augeas.rb:82:in `block in parse_commands'
augeas.rb: 81: data.each do |line| 82 line.strip!
It looks like not visibility of strip function.
-- Regards, Hubert
No, you are doing it wrong - as I explained - you are giving a Hash - it expects a String. Augeas does not check and strip! cannot be applied to a Hash.
19 feb. 2019 kl. 09:24 skrev hubizx notifications@github.com:
Thanks for answer, will write on slac for such cases. Only add there is no way to write "onlyif" sentence, everything gives "undefined method `strip!"
/opt/puppetlabs/puppet/vendor_modules/augeas_core/lib/puppet/provider/augeas/augeas.rb:82:in `block in parse_commands'
augeas.rb: 81: data.each do |line| 82 line.strip!
It looks like not visibility of strip function.
-- Regards, Hubert
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.
Does not master in augtool the same match works correctly?, and match in onlyif is the same like others match sentense. Faced that on puppet5, and 6.
-- Regards, Hubert
Again - you are doing it wrong ;-)
You should not have onlyif
inside the changes instruction - it is a puppet resource instruction. Do like this:
changes => [
"set /files/etc/ssh/sshd_config/PermitRootLogin yes",
],
onlyif => "match *[. = 'PermitRootLogin'] == 'no'",
Documentation is here: https://puppet.com/docs/puppet/5.3/resources_augeas.html
And please continue this dialog on Slack.
Hello,
Could you please advise what could be a reason for error: undefined method `strip!' example class: $test = " t1 " $test1 = strip("$test") $test2 = $test.strip notice("test: ${test}") notice("test1: ${test1}") notice("test2: ${test2}") augeas { "sshd_config": context => "/files/ssh/sshd_config", changes => [ "set /files/etc/ssh/sshd_config/PermitRootLogin yes", onlyif => "match *[. = 'PermitRootLogin'] == 'no'", ], }
output: puppet apply: Notice: Scope(Class[Inf_ldap::S]): test: t1
Notice: Scope(Class[Inf_ldap::S]): test1: t1 Notice: Scope(Class[Inf_ldap::S]): test2: t1 Notice: Compiled catalog for orcpuit14 in environment dev in 0.14 seconds Info: Applying configuration version '1550482520' Error: /Stage[main]/Inf_ldap::S/Augeas[sshd_config]: Could not evaluate: undefined method `strip!' for {"onlyif"=>"match *[. = 'PermitRootLogin'] == 'no'"}:Hash
Function strip works, but not for augeas. That is default installation of puppet-agent-6.2.0-1.el7.x86_64 on RH7. vendormoduledir = /opt/puppetlabs/puppet/vendor_modules strip function file comes with puppet agent: /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/functions/strip.rb
-- Regards, Hubert