Commit graph

97 commits

Author SHA1 Message Date
Adam Leff
a18441f86e Rubocop: disable GuardClause and ClassLength (#2382)
Neither of these cops is helping us write good code, and GuardClause
specifically is actually contributing to us writing sometimes-unclear
code. Disabling both of these cops and removing all unnecessary disable
decorators in the codebase.

Signed-off-by: Adam Leff <adam@leff.co>
2017-12-07 20:22:55 +01:00
Adam Leff
4b9acb4800 Bump Rubocop to 0.49.1 (#2323)
* Bump Rubocop to 0.49.1

This change bumps Rubocop to 0.49.1. There have been a lot of changes
since 0.39.0 and this PR is hopefully a nice compromise of turning off
certain cops and updating our codebase to take advantage of new Ruby
2.3 methods and operators.

Signed-off-by: Adam Leff <adam@leff.co>

* Set end-of-line format to line-feed only, avoid Windows-related CRLF issues

Signed-off-by: Adam Leff <adam@leff.co>
2017-11-21 08:49:41 +01:00
Wei He
71ed5ef964 service resource: properly search for SysV Init S files (#2274)
* bug fix: Service resource

Signed-off-by: Wing924 <weihe924stephen@gmail.com>

* fix test case

Signed-off-by: Wing924 <weihe924stephen@gmail.com>
2017-11-02 15:03:51 +01:00
Jerry Aldrich III
cbcca9f39e Modify Upstart enabled check to use config file (#2163)
This modifies the enabled check for the `service` resource to use the
service's config file instead of `initctl show-config`.

`initctl show-config` does not accurately show the state of a service if
that service's config file is modified while the service is running.

This fixes #1834.

Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
2017-09-21 12:21:34 -04:00
Adam Leff
a6582bea9b Remove any "All Rights Reserved" references (#1969)
* Remove any "All Rights Reserved" references

InSpec is licensed and released under the Apache 2.0 license. This
change removes all reference to legacy code files that still had
any Copyright or License lines referring to "All Rights Reserved".

Signed-off-by: Adam Leff <adam@leff.co>

* fix functional tests

Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-06-28 04:14:19 -07:00
Kristian Vlaardingerbroek
ced4ca1858 Add support for CoreOS to the service resource (#1928)
* s/package/service/ on service unit test descriptions

Signed-off-by: Kristian Vlaardingerbroek <kvlaardingerbroek@schubergphilis.com>

* Add support for CoreOS to the service resource

Signed-off-by: Kristian Vlaardingerbroek <kvlaardingerbroek@schubergphilis.com>
2017-06-15 13:19:58 -04:00
Dominik Richter
1dafe50bd9 rename SimpleConfig / parse_config / parse_config_file options
See https://github.com/chef/inspec/issues/1709
Fixes https://github.com/chef/inspec/issues/1709

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
2017-04-26 23:18:40 +02:00
Christoph Hartmann
8b1619b60e try to use sysv fallback if is not producing proper output
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
2017-03-08 21:52:52 +01:00
Carl Johnston
316c994cc5 Added oracle linux to rhel platform section.
Broken when chef/train was fixed to detect oracle linux correctly.

Signed-off-by: Carl Johnston <carldjohnston@gmail.com>
2017-03-02 22:07:16 +11:00
Douglas
5e56bd4635 Updated Windows Service check for Enabled state to allow both Auto and
Manual to be considered valid states for a service to be enabled.

Signed-off-by: Douglas <bdougl6@ms.ds.uhc.com>
2016-11-03 11:28:38 -05:00
Artem Sidorenko
aa725fe2df Linux Mint support for service resource 2016-10-08 23:34:56 +02:00
Christoph Hartmann
3346d7e1a9 support /etc/init.d directory for run level configuration 2016-09-05 11:08:21 +02:00
Martin Hegarty
e6eb6d8d36 Allow for windows service name with spaces 2016-08-31 15:01:07 +01:00
Anirudh Gupta
4041f1898e can check windows service startup mode now 2016-08-24 02:01:10 +05:30
Steven Danna
57d7275857
Update inspec for os[:family] change in Train
Signed-off-by: Steven Danna <steve@chef.io>
2016-08-04 13:32:35 +01:00
Steven Danna
28946f5fde
Use systemctl's helper command to determine enabled & active status
The output of `systemctl show SERVICENAME` can be misleading in the
case of non-native services (i.e. services configured via an init script
and integrated with systemd via a shim) or for more sophisticated unit
types.

For example, the UnitFileState of ntp is "bad":

    > systemctl show ntp | grep UnitFileState
    UnitFileState=bad

despite systemd reporting it as enabled:

   > systemctl is-enabled ntp
   ntp.service is not a native service, redirecting to
   systemd-sysv-install
   Executing /lib/systemd/systemd-sysv-install is-enabled ntp
   enabled

Further, the old parsing code would have missed unit files in the
following states that are technically enabled:

   enabled-runtime, indirect, generated, and transient

Using the `is-enabled` commands ensures that we report the same enabled
status that systemd reports, without having to update our own parsing in
the event that new unit states are added. Additionally, as shown above,
it handles the sysv compatibility helper.

Similarly, the is-active helper command ensures that we always report
the same active/not-active status as systemd would natively. For
instance, a quick reading of `src/systemctl/systemctl.c` in the systemd
source shows that systemctl reports units as active if they are in the
state `UNIT_ACTIVE` or `UNIT_RELOADING`.

Fixes #749

Signed-off-by: Steven Danna <steve@chef.io>
2016-08-03 13:31:09 +01:00
Dominik Richter
c6644ebdfe check service running by ActiveState
See http://unix.stackexchange.com/questions/159174/differences-between-inactive-vs-disabled-and-active-vs-enabled-services
2016-07-06 12:57:04 +02:00
Alex Pop
9ded3b8835 Provide service params as a mash, empty unless systemd for now 2016-05-09 14:54:09 +02:00
Alex Pop
c518b9edc2 expose systemd service properties via .info 2016-05-06 13:36:42 +02:00
Satish Puranam
07315ce5d2 Cleanup code meet lint guidelines 2016-04-14 13:39:03 -04:00
Satish Puranam
b0bc88f637 Cleanup, remove redundant checking of os family 2016-04-13 19:08:14 -04:00
Satish Puranam
81029274e2 Add support suse 11 to service resource 2016-04-13 18:24:26 -04:00
Jacob McCann
9dbf5354e5 Add 'static' value as enabled to systemd service enabled check 2016-04-13 14:44:28 -05:00
Joshua Bussdieker
7a185f02dc Amazon linux support for service resource 2016-03-29 08:32:50 -07:00
Adam Leff
577688a3a0 Placing all resources in the Inspec::Resources namespace
Many of the resources are named as a top-level class with a fairly generic class name, such as "OS". This causes an issue specifically with kitchen-google which depends on a gem which depends on the "os" gem which itself defines an OS class with a different superclass. This prevents users from using TK, Google Compute, and Inspec without this fix.

Some mocked commands had their digest changed as well due to the new indentation, specifically in the User and RegistryKey classes.

I strongly recommend viewing this diff with `git diff --ignore-space-change`
to see the *real* changes. :)
2016-03-08 13:40:16 -05:00
Dominik Richter
ee82c3a2ff bugfix: handle edge-cases in upstart service
e.g. when a service could not be found and command outputs become empty / matchers dont hit'
2016-02-22 09:52:16 +01:00
Stephan Renatus
453cd420fb fix service_ctl override logic 2016-02-17 12:55:09 +01:00
Dominik Richter
36cbafc438 add runlevel helper object to services 2016-02-14 18:23:58 +01:00
Dominik Richter
0934948a1a support runlevels for system V + service matching
Bugfix: there were services that would get matched because of the way the regex was constructed, i.e. if the user inserted `.` or `*` or anything regexy. Even if the service only had part of the name you were interested in, it would match (e.g. `sshd` would find `my_sshdaemon`).

Apart from this, runlevels are now detected for SystemV. This is exposed in `#info`
2016-02-13 02:11:51 +01:00
Stephan Renatus
f63a8ad1d5 upstart_service: add version fallback, fix regexp
before this regexp change, a service called "running" (hello integration
tests) would always be "running" ;)
2016-02-05 13:49:18 +01:00
Stephan Renatus
6fbd28c2bb runit_service: fix resource, improve integration tests
Turns out using `/usr/bin/yes` to imitate a daemon process is a TERRIBLE idea.
2016-01-29 17:03:05 +01:00
Christoph Hartmann
bd1e5e4085 service resource for solaris 10 and 11 2016-01-28 18:30:38 +01:00
Christoph Hartmann
dd59dd9a5a use os.linux and os.windows where possible 2016-01-28 18:30:38 +01:00
Stephan Renatus
9821c4c754 resource/launchd_service: correctly match non-running services 2016-01-25 16:29:08 +01:00
Stephan Renatus
ef77e01229 service resources: fix service_ctl default/override handling 2016-01-21 11:35:34 +01:00
Stephan Renatus
492c7f8146 runit_service: cleanup; fix "non-running-runit-service" test + recipe 2016-01-21 09:05:29 +01:00
Stephan Renatus
c761b8b40d service resources: further simplifications, debian/centos handling
I've recovered the debian/centos special handling of the `service`
binary, although I doubt that it's necessary.
2016-01-21 08:22:04 +01:00
Stephan Renatus
3f39b35502 add runit_service resource, fix service_ctl handling 2016-01-20 17:54:16 +01:00
Stephan Renatus
709e4ca9e0 some code simplifications 2016-01-20 16:05:20 +01:00
Stephan Renatus
0e410df69d add *_service overrides, allowing for different control binaries 2016-01-20 15:33:18 +01:00
Christoph Hartmann
b9978b5606 new rubocop fixes 2016-01-14 23:15:10 -05:00
Jeremy W. Chalfant
9e40e6d9f3 my rubocop is different 2016-01-14 23:03:26 -05:00
Jeremy W. Chalfant
0681562fcd rubocop is nuts 2016-01-14 23:03:26 -05:00
Jeremy W. Chalfant
6cd801fbb9 rubocop is nuts 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
b167854c18 my rubocop is different 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
bbed0e7164 rubocop is nuts 2016-01-14 23:03:25 -05:00
Jeremy W. Chalfant
c982daaf6e my rubocop is different 2016-01-14 23:03:24 -05:00
Jeremy W. Chalfant
221d27423e rubocop is nuts 2016-01-14 23:03:24 -05:00
Jeremy W. Chalfant
3a90ea3a74 fix lint complaint 2016-01-14 23:03:23 -05:00
Jeremy W. Chalfant
b9ce468886 add AIX service support 2016-01-14 23:03:23 -05:00