Deployment Architecture

How do I bypass yes response to enable maintenance-mode question on cluster master?

wlth09
Explorer

I need a quick answer to a question:

for the command:

./splunk enable maintenance-mode -auth user:password

always requires you answer "y" to the question:

"Warning: In maintenance mode, the cluster master will not attempt to replace any missing replicated or searchable bucket copies. This mode should be enabled only while performing maintenance on peers. Do you want to continue? [y/n]: "

and will not accept "y" on stdin, how do I bypass?

1 Solution

Yasaswy
Contributor

if it's not accepting STDIN you can use "expect"... should be available on most Linux distro...

Script something like (test.exp):
#!/usr/bin/expect
spawn /path_to_splunk/bin/splunk enable maintenance-mode -auth user:pass
expect {Warning*}
send "y\r"
expect eof

run the script ./test.exp

View solution in original post

0 Karma

hsaifee
Engager

I have tried following and it works fine as expected. It will solve the issue. No need to install any third party tool like expect

/ama/apt/splunk/bin/splunk enable maintenance-mode --answer-yes --no-prompt

snrlopez
Engager

This is an older question but I figured I would respond anyway just in case someone else comes along looking for the answer like I did.

To enable: $SPLUNK_HOME/bin/splunk enable maintenance-mode -auth user:pass --answer-yes

To disable: $SPLUNK_HOME/bin/splunk disable maintenance-mode -auth user:pass --answer-yes

0 Karma

Lowell
Super Champion

Have you tried?

splunk enable maintenance-mode --answer-yes

Seems to work on 6.2 and later.

wlth09
Explorer

To all, I also found a second way to answer this as I did not want to require extra software on my hosts and am currently using ssh. If you pipe the command:

/path_to_splunk/bin/splunk enable maintenance-mode -auth user:pass
y
exit

to ssh and you are good to go, you can do the same with:

/path_to_splunk/bin/splunk --accept-license start -auth user:pass
y
exit

to migrate and start splunk after an upgrade.

0 Karma

Yasaswy
Contributor

if it's not accepting STDIN you can use "expect"... should be available on most Linux distro...

Script something like (test.exp):
#!/usr/bin/expect
spawn /path_to_splunk/bin/splunk enable maintenance-mode -auth user:pass
expect {Warning*}
send "y\r"
expect eof

run the script ./test.exp

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security(ES) 7.3 is approaching the end of support. Get ready for ...

Hi friends!    At Splunk, your product success is our top priority. With Enterprise Security (ES), we're here ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...