Comments (15)
When new_resource.create_account
is set to false, these should return the same thing, right?
new_resource.create_account || Logstash.get_attribute_or_default(node, @name, 'create_account')
new_resource.create_account.nil? || Logstash.get_attribute_or_default(node, @name, 'create_account')
Is the issue that someone has set create_account
on the node object? I'd say that's a logic error in the cookbook doing it.
from chef-logstash.
no the two return different things.
the first one calls
Logstash.get_attribute_or_default(node, @name, 'create_account')
which reads the value of the node['logstash']['instance_default']['create_account']
which is set to true in attributes/default.rb
rendering setting this property to false impossible.
The second line, does not call Logstash.get_attribute_or_default(node, @name, 'create_account')
and the value of new_resource.create_account
remains false
from chef-logstash.
Wouldn't it be easier to simply override the node attribute, if you're going to use one and default to true?
from chef-logstash.
(or get rid of the node attribute)
from chef-logstash.
Ok but what's the point of letting the user set a resource property if it's getting overriden anyway and is always true?
To me this is clearly a bug.
from chef-logstash.
I've just spent an hour trying to figure out why
logstash_instance 'name' do
...
create_account false
end
is trying to create the account.
from chef-logstash.
Having a resource property and looking at the node object allows us to support both styles of usage (resources vs. recipes). But if someone tries to mix them, there's actually lots of ways in which this will break (separate resource collections & run contexts, chefspec, chef-shell, etc).
I've just spent an hour trying to figure out why
From what I understand, your situation is actually:
default['logstash']['name']['create_account'] = true
logstash_instance 'name' do
...
create_account false
end
Is that more accurate? I feel like that's inconsistent. I'd almost rather raise an error there.
from chef-logstash.
no. I do not set
default['logstash']['name']['create_account'] = true
I'm only calling the resource.
from chef-logstash.
@bodgix can you show me a minimal example? I suspect something is setting node['logstash']['name']
. otherwise both the property and the utility method should return false.
from chef-logstash.
Ah, I see what's happening. We should probably adjust the utility method to never return true if node['logstash'][@name]
isn't set.
from chef-logstash.
IMHO the utility method should only be called IFF the property isn't set.
from chef-logstash.
IMHO the utility method should only be called IFF the property isn't set.
My concern is that it's a backwards-incompatible change. We should just drop support for the node object entirely if we do that 👍 (and make this a library cookbook, like it should be.)
from chef-logstash.
well but the utility method isn't called for String properties when they're set.
The problem is the use of ||
operator. It's works as expected for String/Array because strings or arrays can only be falsey when they're nil.
Boolean are special and this is why I propose to drop the use of
property || default_property
For booleans.
from chef-logstash.
the root of the problem is that an unset boolean and a boolean set to false are both falsey. and I believe that the utility function should only be called for unset properties. and it still will be with my change.
from chef-logstash.
Thank you for pointing me to the workaround.
Since my patch may break backward compatibility, I decided to try it.
I set ['logstash']['instance'][instance_name]['create_account'] to false in my recipe so now I have:
node.override['logstash']['instance'][instance_name]['create_account'] = false
logstash_instance instance_name do
base_directory base_dir
install_type 'tarball'
version '1.5.6'
source_url "file://#{File.join(base_dir, 'logstash-1.5.6.tar.gz')}"
checksum '812a809597c7ce00c869e5bb4f87870101fe6a43a2c2a6586f5cc4d1a4986092'
create_account false
user 'some_user'
group 'some_group'
end
but the provider is still trying to create the user.
I believe there is another problem and it's in the utility method this time:
chef-logstash/libraries/logstash_util.rb
Line 33 in d4c2749
I believe that the intention of the utility method is to return the instance_attr
if it's set or the default_attr
otherwise. The problem is that when the instance_attr
is set to false, this expression becomes
false || default_attr
which evaluates to default_attr
.
I finally managed to disable account creation by overriding
node.default['logstash']['instance_default']['create_account'] = false
in my recipe.
from chef-logstash.
Related Issues (20)
- Unable to install logstash 2.3.2 getting plugin install errors HOT 1
- Problem in Amazon OpsWorks with Ubuntu 16.04 HOT 1
- Support JAVA_STACK variable
- Logstash 2.3.4, 2.3.3 service fails HOT 9
- LWRP "version" property is being ignored HOT 1
- Recipe fails with No resource or method named `logstash_instance' error
- Deprecated? HOT 2
- Version 0.13.0 fails on Chef 12 due to version declaration HOT 3
- failing on linux_user
- plugin guard not working HOT 3
- config not working HOT 1
- Switch to strings for hash keys instead of symbols
- tarball plugin install error minitar HOT 1
- Restart Server only on config change
- logrotate config has invalid path of just "*.log"
- specify init choice for service? HOT 4
- "agent" is not a valid parameter to Logstash anymore HOT 2
- chef/mixin/language incompatible with Chef 14 HOT 3
- logstash_instance fails when installing from source
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chef-logstash.