Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 7.2 support and refactor module #215

Merged
merged 1 commit into from
Apr 5, 2019
Merged

Add 7.2 support and refactor module #215

merged 1 commit into from
Apr 5, 2019

Conversation

nick-markowski
Copy link
Contributor

  • Supports systemd boot-start
  • Changed module design from Class[splunk], Class[splunk::forwarder] to
    Class[splunk::enterprise] and Class[splunk::forwarder]
  • Removed legacy-style service management
  • Allow users to disable default config (splunk/forwarder_* types)
  • Removed ability to include enterprise and forwarder on the same machine
    • Forwarder is simply a subset of enterprise capability and there is no need
      to have both
    • Forwarder and enterprise potentially share common service names and other
      assets, which cause issues when including both
  • Bumped dependency on stdlib to 4.25.0 to ensure strong typing support
  • Allow users to specify splunk service user
  • Added password management to enterprise

Fixes #213
Fixes #212
Fixes #210

Pull Request (PR) description

This Pull Request (PR) fixes the following issues

@nick-markowski nick-markowski changed the title Add 7.2 support and refactor module WIP: Add 7.2 support and refactor module Mar 5, 2019
@nick-markowski
Copy link
Contributor Author

nick-markowski commented Mar 5, 2019

Still need to:

  • Update in-module and README parameter documentation once design is approved
  • Update acceptance tests to test systemd changes
  • Optionally upgrade test, and default the version to the latest release

$package_manage = true,
Optional[String] $package_name = undef,
$inputs = {},
) {

include '::splunk::params'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the leading ::. That is legacy syntax that was required for puppet 3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have...a lot of these to remove lol

include '::splunk::params'

if !defined($splunk_home) {
$_splunk_home = $::splunk::params::forwarder_homedir
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, please remove the leading ::.

# Class splunk::enterprise
#
class splunk::enterprise (
String $version = $::splunk::params::version,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for all the strings, can you update it to String[1] to prohibit empty strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure can!

$package_manage = true,
Optional[String] $package_name = undef,
$inputs = {},
) {

include '::splunk::params'

if !defined($splunk_home) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or just unless $splunk_home {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or if $splunk_home and reverse the blocks.

@alexjfisher
Copy link
Member

@nick-markowski Huge thanks for taking this on! It's something I'm going to be needing myself shortly, so I should be able to test your PR sometime over the next week or so.

String $service_file = $::splunk::params::enterprise_service_file,
Boolean $boot_start = $::splunk::params::boot_start,
Boolean $use_default_config = true,
String $input_default_host = $facts['clientcert'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clientcert? That doesn't actually have to be a hostname. Probably better to stick with $facts['fqdn'] here.

Optional[String] $package_provider = $::splunk::params::package_provider,
Boolean $manage_package_source = true,
Optional[String] $package_source = undef,
Optional[Array[String]] $install_options = $::splunk::params::enterprise_install_options,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this being Optional, can we default to an empty array instead?

Optional[String] $package_source = undef,
Optional[Array[String]] $install_options = $::splunk::params::enterprise_install_options,
String $splunk_user = $::splunk::params::splunk_user,
String $enterprise_homedir = $::splunk::params::enterprise_homedir,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stdlib::Absolutepath instead of String?

Boolean $use_default_config = true,
String $input_default_host = $facts['clientcert'],
String $input_connection_host = 'dns',
String $splunkd_listen = '127.0.0.1',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stdlib::IP::Address?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to comb through all of the strong typing, I winged it

@nick-markowski
Copy link
Contributor Author

nick-markowski commented Mar 8, 2019

@alexjfisher @bastelfreak Splunk has made an assumption that cgroups are present in the systmed unit file, if enabled (boot-start). Cgroups are obviously not present in containers, so the test suite fails:

chown: cannot access ‘/sys/fs/cgroup/cpu/system.slice/Splunkd.service’: No such file or directory

One way we can probably get around it is to hack in the 2 cgroup files the until file expects to manage. It's ugly, but i'm not sure what else to do until Splunk fixes their code.

EDIT: If you're running splunk in a container IRL you would probably not use systemd to manage the service, you would use the binaries directly to kick off the container (or download the splunk container, per their docs). We may need to update the travis tests to utilize virtual hosts instead of containers to fully test the suite.

}

if $splunk::enterprise::package_provider != undef and $splunk::enterprise::package_provider != 'yum' and $splunk::enterprise::package_provider != 'apt' and $splunk::enterprise::package_provider != 'chocolatey' {
include ::archive::staging
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use:

Suggested change
include ::archive::staging
include archive::staging

@ody
Copy link
Contributor

ody commented Mar 22, 2019

Hey @nick-markowski,

How can I help get this over the line and merged? Working on a project and officially blocked by the lack of 7.2 support.

@nick-markowski
Copy link
Contributor Author

nick-markowski commented Mar 25, 2019

Hey @ody ! I have a list of todo items I should be able to begin addressing this week:

  • Update in-module and README parameter documentation once design is approved
    • I need to slog through copying the old parameter docs to the new classes and ensure new parameters are documented
  • Update acceptance tests to test systemd/backwards compatibility changes thoroughly
    • This is a good place for input! I can only manually test so much, and the test suite needs upgrading
    • Test add-on and password if possible, I don't have a good use case for either
    • Optionally upgrade test, and default the version to the latest release (already done, but we need to update the test suite)

Before the tests can be completed, I need some resolution about how to handle issues I posted in the chain, above.

EDIT: while automated acceptance is a good end-goal, manually deploying the module in a test environment and ensuring the logic is not complete garbage would be very useful, too!

@alexjfisher
Copy link
Member

@alexjfisher @bastelfreak Splunk has made an assumption that cgroups are present in the systmed unit file, if enabled (boot-start). Cgroups are obviously not present in containers, so the test suite fails:

chown: cannot access ‘/sys/fs/cgroup/cpu/system.slice/Splunkd.service’: No such file or directory

One way we can probably get around it is to hack in the 2 cgroup files the until file expects to manage. It's ugly, but i'm not sure what else to do until Splunk fixes their code.

EDIT: If you're running splunk in a container IRL you would probably not use systemd to manage the service, you would use the binaries directly to kick off the container (or download the splunk container, per their docs). We may need to update the travis tests to utilize virtual hosts instead of containers to fully test the suite.

Umm... I really don't know. I wonder if @ekohl has any ideas?

@ekohl
Copy link
Member

ekohl commented Mar 25, 2019

One way we can probably get around it is to hack in the 2 cgroup files the until file expects to manage. It's ugly, but i'm not sure what else to do until Splunk fixes their code.

This sounds fair. The spec_acceptance_helper sounds like the correct place if they just need to exist and setting it up once is enough.

We may need to update the travis tests to utilize virtual hosts instead of containers to fully test the suite.

AFAIK we have no place to run VMs

@nick-markowski
Copy link
Contributor Author

@ekohl I'll try to get the tests running in the containers and report any other blockers, thanks!

@nick-markowski
Copy link
Contributor Author

@alexjfisher @bastelfreak looks like some dependencies within the debian nodeset are defunct, not sure how you want to handle it

@ekohl
Copy link
Member

ekohl commented Mar 26, 2019

Debian 8 is EOL. Technically it's LTS, but in Debian that has a different meaning. It's fine to drop Debian 8 as a supported OS and only support Debian 9 IMHO.

@bastelfreak
Copy link
Member

@nick-markowski are you happy with this as it is now? I don't want to review such a huge PR multiple times :D. Please remove the WIP from the title if this is ready.

@nick-markowski
Copy link
Contributor Author

@bastelfreak understandable! I left it WIP because I need to update the README and in-module param documentation. I'll get that done this week.

@nick-markowski nick-markowski changed the title WIP: Add 7.2 support and refactor module Add 7.2 support and refactor module Mar 29, 2019
Optional[String] $package_name = undef,
$inputs = {},
Optional[Stdlib::Absolutepath] $splunk_home = undef,
Boolead $package_manage = true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean

@nick-markowski
Copy link
Contributor Author

@alexjfisher @bastelfreak @ekohl Looks like the review has already started and I need to add some testing - could I get some more 👀 on this? :)

@alexjfisher
Copy link
Member

@nick-markowski I'm going to be trying this change out for real in the next few days. :)

.sync.yml Outdated
@@ -4,7 +4,7 @@
docker_sets:
- set: centos6-64
- set: centos7-64
- set: debian8-64
- set: debian9-64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to make the whole diff smaller, do you think it's possible to add debian9 in a seperate PR and drop debian 8 in a seperate PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could re-introduce those changes as a separate PR (unless someone else beats me to it) and rebase this one to clean things up, for sure

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a move to Debian 9 a requirement for Splunk 7.2? That would be the only reason to rebase. If it isn't a requirement then it should be able to be handled entirely separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only updated because the debian 8 docker images were defunct and not letting the test suite pass, I'm fine with ditching the change and ignoring the deb8 tests

}

if $facts['virtual'] == 'docker' {
ini_setting { 'OPTIMISTIC_ABOUT_FILE_LOCKING':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, nice name for an option :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, most of this is reused code I didn't find reason to modify :)

}
}

File <| tag == 'splunk_enterprise' |>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we can simplify the whole block of class dependencies 🤔

Copy link
Contributor Author

@nick-markowski nick-markowski Apr 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope so, it was painful to write these out! I guess, technically, we could order the types to consolidate them into one block; order is arbitrary anyways:

File <| tag == 'splunk_enterprise' |>
-> Splunk_authentication <| tag == 'splunk_enterprise' |>
-> Splunk_authorize <| tag == 'splunk_enterprise' |>
-> Splunk_deploymentclient <| tag == 'splunk_enterprise' |>
... etc
~> Class['splunk::enterprise::service']

Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexjfisher @binford2k can you have a look please?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed ability to include enterprise and forwarder on the same machine

Was this the only reason for tagging the resources? Maybe much of this could be simplified??

false => $splunk::enterprise::package_source
}

if $splunk::enterprise::package_provider != undef and $splunk::enterprise::package_provider != 'yum' and $splunk::enterprise::package_provider != 'apt' and $splunk::enterprise::package_provider != 'chocolatey' {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if $splunk::enterprise::package_provider != undef is equal to if $splunk::enterprise::package_provider


if $splunk::enterprise::package_provider != 'yum' and $splunk::enterprise::package_provider != 'apt' and $splunk::enterprise::package_provider != 'chocolatey' should be equal to if not $splunk::enterprise::package_provider in ['apt', 'chocolatey', 'yum'] (but I didn't test it).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try cleaning this up, I have a local centos7 build I'm using yum providers with

}

if $splunk::enterprise::package_provider != undef and $splunk::enterprise::package_provider != 'yum' and $splunk::enterprise::package_provider != 'apt' and $splunk::enterprise::package_provider != 'chocolatey' {
include archive::staging
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this include actually required? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, most of the crazy install logic I just forklifted and plopped into place...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unable to find a reason for its inclusion aside from it including the archive class but I am also not even sure the archive class is required, it just installs awscli or 7zip on Windows.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This module is listed as supporting Windows though.


# Required for splunk 7.2.4.2
if versioncmp($splunk::enterprise::version, '7.2.4.2') >= 0 {
if !defined(Package['net-tools']) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# This is a module that supports multiple platforms. For some platforms
# there is non-generic configuration that needs to be declared in addition
# to the agnostic resources declared here.
if $facts['kernel'] == 'Linux' or $facts['kernel'] == 'SunOS' {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Untetested but should work and is shorter:

Suggested change
if $facts['kernel'] == 'Linux' or $facts['kernel'] == 'SunOS' {
if $facts['kernel'] in ['Linux', 'SunOS'] {

false => $splunk::forwarder::package_source
}

if $splunk::forwarder::package_provider != undef and $splunk::forwarder::package_provider != 'yum' and $splunk::forwarder::package_provider != 'apt' and $splunk::forwarder::package_provider != 'chocolatey' {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here as mentioned above

# If the purge parameters have been set, remove all unmanaged entries from
# the respective config files.
# Class splunk::forwarder
#
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. Trailing whitespace on every other line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why puppet-lint doesn't complain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe comments are linted differently?

)
}

include 'splunk::forwarder::install'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these use contain?

eg what if I'm doing something like...

pulp_rpmbind {'internal-splunk-7': }
class { 'splunk::forwarder':
  server                => $server,
  manage_package_source => false,
  package_provider      => 'yum',
  package_ensure        => 'latest',
  require               => Pulp_rpmbind['internal-splunk-7'],
}

README.md Outdated

#### `addons`

Manage a splunk addons, see `splunk::addons`. Defaults to an empty Hash.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. Should read Manage splunk addons (without the a).


# Declare inputs and outputs specific to the forwarder profile
$_tag_resources = { tag => 'splunk_forwarder' }
if $splunk::forwarder::forwarder_input {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always be truthy as $splunk::forwarder::forwarder_input is of type Hash.

# Declare inputs and outputs specific to the forwarder profile
$_tag_resources = { tag => 'splunk_forwarder' }
if $splunk::forwarder::forwarder_input {
create_resources( 'splunkforwarder_input', $splunk::forwarder::forwarder_input, $_tag_resources)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could/should use iteration instead of create_resources.

Optional[Stdlib::Absolutepath] $splunk_home = undef,
Boolead $package_manage = true,
Optional[String[1]] $package_name = undef,
$inputs = {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you strong type this parameter too so its consistent?

}

if $splunk::enterprise::package_provider != undef and $splunk::enterprise::package_provider != 'yum' and $splunk::enterprise::package_provider != 'apt' and $splunk::enterprise::package_provider != 'chocolatey' {
include archive::staging
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unable to find a reason for its inclusion aside from it including the archive class but I am also not even sure the archive class is required, it just installs awscli or 7zip on Windows.

if $splunk::enterprise::package_provider != undef and $splunk::enterprise::package_provider != 'yum' and $splunk::enterprise::package_provider != 'apt' and $splunk::enterprise::package_provider != 'chocolatey' {
include archive::staging
$_src_package_filename = basename($_package_source)
$_package_path_parts = [$archive::path, $splunk::enterprise::staging_subdir, $_src_package_filename]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$archive::path isn't ever set by Class[archive]

@ody
Copy link
Contributor

ody commented Apr 4, 2019

Basic functionality of standing up a new instance of 7.2 and installing forwarder validated

Thanks @nick-markowski!


if $splunk::enterprise::boot_start {
# Eensure splunk services *not* managed by the system service file are
# Ensuure splunk services *not* managed by the system service file are
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So close! ;)

@alexjfisher
Copy link
Member

Basic functionality of standing up a new instance of 7.2 and installing forwarder validated

Thanks @nick-markowski!

@ody Thanks for testing! It's been looking good for me too.

~> Class['splunk::forwarder::service']

File <| tag == 'splunk_forwarder' |>
-> Splunkforwarder_input <| tag == 'splunk_forwarder' |>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the deal with only looking for resources with the specific tag?
Previously, you could declare these resources without a tag and they would notify the service.
See #50

* Default splunk version to 7.2.4.2
* Supports systemd boot-start
  * sysvinit file ensured absent on systemd machines when supported
  * net-tools ensured present on enterprise nodes splunk >= 7.2.4.2
  * Removed legacy-style service management
* Changed module design from Class[splunk], Class[splunk::forwarder] to
  Class[splunk::enterprise] and Class[splunk::forwarder]
  * Removed inclusion of the ::archive class
  * Cleaned up install logic
* Allow users to disable default config (splunk/forwarder_* types)
  * Generate splunkforwarder_input/output with iteration, instead of
    create_resources
* Removed ability to include enterprise and forwarder on the same machine
  * Forwarder and enterprise potentially share common service names and other
    assets, which cause issues when including both
  * Forwarder is simply a subset of enterprise capability and there is no need
    to have both
* Bumped dependency on stdlib to 4.25.0 to ensure strong typing support
* Allow users to specify splunk service user
* Added password management to enterprise

Fixes #213
Fixes #212
Fixes #210
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants