goss-org / goss

Quick and Easy server testing/validation
https://goss.rocks
Apache License 2.0
5.6k stars 472 forks source link

Add feature for checking php ini values #341

Closed catdevman closed 6 years ago

catdevman commented 6 years ago

@aelsabbahy I believe that the php_config serverspec resource is useful. I would like to try and add it to Goss. My question here is would that feature be accepted into the code here? I want to add it to Goss because we don't use ruby anywhere else so I have to install the language and a bunch of extra dependencies just to get a simple feature from serverspec that goss doesn't have out of the box. I prefer Goss because it is a simple binary and a simple config file and I am done.

Here is my current work around:

command:
  php -c /etc/php/7.0/apache2/php.ini -r "echo ini_get('memory_limit');":
    exit-status: 0
    stdout:
    - "256M"
  php -r "echo ini_get('opcache.enable');":
    exit-status: 0
    stdout:
    - "1"

but I would like the configuration to look more like:

php_config:
  memory_limit:
    value: "256M" #or pattern
    file: "/etc/php/7.0/apache2/php.ini"
  opcache.enable:
    value: "1" # or "On"

I would love to hear your thoughts. Just thought it might be nice to have php_config as a first class citizen. Just so you know I am new to Go so any code that I would write would probably need to be heavily reviewed. If that is something that you think would be worth adding to Goss please let me know and I will gladly work on it, if not then we can close this.

pysysops commented 6 years ago

Hey, looking at what serverspec does under the hood: https://github.com/mizzy/serverspec/blob/master/lib/serverspec/type/php_config.rb#L6

Basically, exactly what your workaround is doing (execute a php command). Personally I think Goss is great as it doesn't hide or abstract things away in more specific resources or types. It gives you a solid set of primitives to work with and I gain the benefit of fully understanding how a particular validation is working.

You could probably achieve the above with the file resource.

Other options might be to expose the config to localhost (if you're running http / web apps) and check for the important values using the http resource.

catdevman commented 6 years ago

@pysysops Yeah that makes sense to me. Thanks for reviewing this idea I think that this can be closed so I will do that.