forked from voxpupuli/puppet-splunk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement new method for setting admin password
This commit introduces a new set of parameters and classes that are used instead of the previous implementation of the "manage_password" parameter to set the initial admin password through the documented user-seed.conf method. The old method still exists but now logs a message indicating that it is no longer the preferred method. This is being done to align the module with Splunk's documentation, prevent Puppet from causing a correctional change on each run, and make it possible to reset the admin password from the Splunk console when desired. The new seed method was implemented in a class separate from Class[splunk::{enterprise,forwarder}::config] to enable it to be easily used external from Puppet, specifically with a Bolt Plan in mind so people can reset the seeded admin password easily without the need to temporarily change infrastructure data sets. The old direct management method was migrated to the same method just for consistency. Fixes voxpupuli#226
- Loading branch information
Showing
13 changed files
with
2,128 additions
and
507 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# @summary | ||
# Implements the direct management of the Splunk Enterprise admin password | ||
# so it can be used outside of regular management of the whole stack to | ||
# facilitate admin password resets through Bolt Plans. | ||
# | ||
# Note: Entirely done to make this implementation consistent with the method | ||
# used to manage admin password seeding. | ||
# | ||
# @param manage_password | ||
# If set to true, Manage the contents of splunk.secret and passwd. | ||
# | ||
# @param password_config_file | ||
# Which file to put the password in i.e. in linux it would be | ||
# `/opt/splunk/etc/passwd`. | ||
# | ||
# @param password_content | ||
# The hashed password username/details for the user. | ||
# @param secret_file | ||
# Which file we should put the secret in. | ||
# | ||
# @param secret | ||
# The secret used to salt the splunk password. | ||
# | ||
# @params service | ||
# Name of the Splunk Enterprise service that needs to be restarted after files | ||
# are updated, not applicable when running in agent mode. | ||
# | ||
# @params mode | ||
# The class is designed to work in two ways, as a helper that is called by | ||
# Class[splunk::enterprise::config] or leveraged independently from with in a | ||
# Bolt Plan. The value defaults to "bolt" implicitly assuming that anytime it | ||
# is used outside of Class[splunk::enterprise::config], it is being used by | ||
# Bolt | ||
# | ||
class splunk::enterprise::password::manage( | ||
Boolean $manage_password = $splunk::params::manage_password, | ||
Stdlib::Absolutepath $password_config_file = $splunk::params::forwarder_password_config_file, | ||
String[1] $password_content = $splunk::params::password_content, | ||
Stdlib::Absolutepath $secret_file = $splunk::params::forwarder_secret_file, | ||
String[1] $secret = $splunk::params::secret, | ||
String[1] $splunk_user = $splunk::params::splunk_user, | ||
String[1] $service = $splunk::params::enterprise_service, | ||
Enum['agent', 'bolt'] $mode = 'bolt', | ||
) inherits splunk::params { | ||
|
||
file { $secret_file: | ||
ensure => file, | ||
owner => $splunk_user, | ||
group => $splunk_user, | ||
content => $secret, | ||
} | ||
|
||
file { $password_config_file: | ||
ensure => file, | ||
owner => $splunk_user, | ||
group => $splunk_user, | ||
content => $password_content, | ||
require => File[$secret_file], | ||
} | ||
|
||
if $mode == 'bolt' { | ||
service { $service: | ||
ensure => running, | ||
enable => true, | ||
hasstatus => true, | ||
hasrestart => true, | ||
subscribe => File[$password_config_file], | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# @summary | ||
# Implements the seeding and reseeding of the Splunk Enterprise admin password | ||
# so it can be used outside of regular management of the whole stack to | ||
# facilitate admin password resets through Bolt Plans | ||
# | ||
# @param seed_password | ||
# If set to true, Manage the contents of splunk.secret and user-seed.conf. | ||
# | ||
# @param reset_seed_password | ||
# If set to true, deletes `password_config_file` to trigger Splunk's password | ||
# import process on restart of the Splunk services. | ||
# | ||
# @param password_config_file | ||
# Which file to put the password in i.e. in linux it would be | ||
# `/opt/splunk/etc/passwd`. | ||
# | ||
# @param seed_config_file | ||
# Which file to place the admin password hash in so its imported by Splunk on | ||
# restart. | ||
# | ||
# @param password_hash | ||
# The hashed password for the admin user. | ||
# | ||
# @param secret_file | ||
# Which file we should put the secret in. | ||
# | ||
# @param secret | ||
# The secret used to salt the splunk password. | ||
# | ||
# @params service | ||
# Name of the Splunk Enterprise service that needs to be restarted after files | ||
# are updated, not applicable when running in agent mode. | ||
# | ||
# @params mode | ||
# The class is designed to work in two ways, as a helper that is called by | ||
# Class[splunk::enterprise::config] or leveraged independently from with in a | ||
# Bolt Plan. The value defaults to "bolt" implicitly assuming that anytime it | ||
# is used outside of Class[splunk::enterprise::config], it is being used by | ||
# Bolt | ||
# | ||
class splunk::enterprise::password::seed( | ||
Boolean $reset_seeded_password = $splunk::params::reset_seeded_password, | ||
Stdlib::Absolutepath $password_config_file = $splunk::params::enterprise_password_config_file, | ||
Stdlib::Absolutepath $seed_config_file = $splunk::params::enterprise_seed_config_file, | ||
String[1] $password_hash = $splunk::params::password_hash, | ||
Stdlib::Absolutepath $secret_file = $splunk::params::enterprise_secret_file, | ||
String[1] $secret = $splunk::params::secret, | ||
String[1] $splunk_user = $splunk::params::splunk_user, | ||
String[1] $service = $splunk::params::enterprise_service, | ||
Enum['agent', 'bolt'] $mode = 'bolt', | ||
) inherits splunk::params { | ||
|
||
file { $secret_file: | ||
ensure => file, | ||
owner => $splunk_user, | ||
group => $splunk_user, | ||
content => $secret, | ||
} | ||
|
||
if $reset_seeded_password or $facts['splunk_version'].empty { | ||
file { $password_config_file: | ||
ensure => absent, | ||
before => File[$seed_config_file], | ||
} | ||
file { $seed_config_file: | ||
ensure => file, | ||
owner => $splunk_user, | ||
group => $splunk_user, | ||
content => epp('splunk/user-seed.conf.epp', { 'hash' => $password_hash}), | ||
require => File[$secret_file], | ||
} | ||
|
||
if $mode == 'bolt' { | ||
service { $service: | ||
ensure => running, | ||
enable => true, | ||
hasstatus => true, | ||
hasrestart => true, | ||
subscribe => File[$seed_config_file], | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.