Closed emujoyce closed 6 years ago
@emujoyce, this is strange - are you using the latest cookbook, 0.3.1
? Do you have anything else that would overwrite the file netdata.conf
outside of this resource, possibly another cookbook?
We have tests that run on CentOS 6.7 and they add multiple configurations into the netdata.conf
file successfully. Recipe that specifics multiple entries: https://github.com/jmadureira/netdata-cookbook/blob/master/test/fixtures/cookbooks/netdata_test/recipes/configuration.rb#L1 and the Tests that check it: https://github.com/jmadureira/netdata-cookbook/blob/master/test/integration/general/default_spec.rb#L21
I just tried replicating your configuration with the latest cookbook and it worked fine, the file came out like this:
[web]
bind to = localhost
[test]
text goes = here
Other than the questions I asked above, maybe try removing all other cookbooks and only use the netdata_install
and netdata_config
resource to see if it works, then work on adding the rest of the cookbooks from there. If it's still happening you can send the chef-client run to this issue and we can try to parse it and find the issue.
@emujoyce, the version of the chef-client being used could also be helpful to solve this issue.
Thanks for the reply. Chef Client, version 12.13.37. I'll try minimizing any other cookbooks, though I'm not sure that is impacting this. I am certain that nothing else is writing that file. Its always the first call of netdata_config that get written (was originally global that I was seeing but I deleted global to make sure that it was the first resource call that was being written).
I did a pull on this cookbook this morning to get the latest updates. To be more specific, I am trying to make a "wrapper" cookbook that calls your resource from another cookbook. I have a cookbook called xyz_netdata that has my recipe calling your resource. I have configured the Berksfile and metadata.rb files to reference your cookbook. I consistently get the same results when I do this. Upon further review I'm wondering if this behavior is the result of running the wrapper cookbook without your matchers.rb library.
Hello @emujoyce
If possible can you provide the recipe code you are using? I'm running some tests using this cookbook (version 0.3.1) as a wrapper without any issues so far.
@jmadureira At this point it is very simple. I install netdata in a separate recipe and then run my configure.rb
netdata_config 'web' do
configurations(
'bind to' => 'localhost'
)
end
netdata_config 'test' do
configurations(
'text goes' => 'here'
)
end
This seems to always put only the [web] portion (or whatever I put first in the recipe) into the netdata.conf file and never the [test] portion. I do have some other cookbooks that are part of a base image that have to run before the netdata stuff but none of that should impact the netdata cookbooks.
The relevant part of the chef run:
Recipe: xyz_netdata::install
* yum_package[netdata] action install
- install version 1.9.1-1.el6 of package netdata
Recipe: xyz_netdata::configure
* netdata_config[web] action create (up to date)
* template[/etc/netdata/netdata.conf] action nothing (skipped due to action :nothing)
* service[netdata] action nothing (skipped due to action :nothing)
* netdata_config[test] action create (up to date)
* service[netdata] action nothing (skipped due to action :nothing)
* template[/etc/netdata/netdata.conf] action create
- update content in file /etc/netdata/netdata.conf from 50be49 to 50f61e
--- /etc/netdata/netdata.conf 2018-02-02 19:26:08.000000000 +0000
+++ /etc/netdata/.chef-netdata.conf20180220-559-y8zodh 2018-02-20 15:55:11.666698805 +0000
@@ -10,16 +10,6 @@
# The value shown in the commented settings, is the default value.
#
-[global]
- run as user = netdata
-
- # the default database size - 1 hour
- history = 3600
-
- # by default do not expose the netdata port
- bind to = localhost
-
[web]
- web files owner = root
- web files group = netdata
+ bind to = localhost
* service[netdata] action restart
- restart service service[netdata]
* service[netdata] action restart
- restart service service[netdata]
Running handlers:
Running handlers complete
@emujoyce Tried using chef-client version: 12.13.37
and I got the same results as you. Missing [test]
section.
Tried using the same version on Ubuntu and the same thing happened.
Then I added the compat_resource
cookbook on Ubuntu and CentOS and the [test]
block appeared.
@emujoyce Try adding this cookbook to your cookbook dependencies:
depends 'compat_resource', '~> 12.19.1'
Thanks for the help!
compat_resource
should already be included as a transitive dependency of netdata.
netdata (0.3.1)
apt (< 7.0.0)
yum-epel (< 3.0.0)
yum-epel (2.1.2)
compat_resource (>= 12.16.3)
Interesting @jmadureira ! I ended up adding it to the netdata cookbook metadata.rb
while testing. Removing it from there and adding it to the fixture/wrapper cookbook removed the [test]
block again.
If we want the netdata cookbook to continue supporting chef-client 12 until EOL in April then we'll need to add this as it appears the netdata cookbook needs to call it directly to make it work for anything below chef-client 12.19
@nictrix @jmadureira Thank you both for you help on this. For now, Im going to have to just generate my files with plain old templates. I'll hopefully be able to come back to this when we chef updated.
I'm using the netdata_config resource to try to generate a netdata.conf file. I use the following in a recipe called configure.rb which is being called in the .kitchen.yml: `netdata_config 'web' do configurations( 'bind to' => 'localhost' ) end
netdata_config 'test' do configurations( 'text goes' => 'here' ) end`
My netdata.conf comes out with only a web section. I can see that the recipe definitely overwrites the original netdata.conf. I haven't been able to get it to properly create more than one section though. Running on cent6.7.