I am creating an ansible script to install splunk Universal Forwarder. If management port 8089 is not free, splunk service start doesnot work. It asks for user input:
{
"stdout_lines": [
"",
"This appears to be your first time running this version of Splunk.",
"",
"Splunk software must create an administrator account during startup. Otherwise, you cannot log in.",
"Create credentials for the administrator account.",
"Characters do not appear on the screen when you type in credentials.",
"",
"Please enter an administrator username: admin",
"Password must contain at least:",
" * 8 total printable ASCII character(s).",
"Please enter a new password: ", "Please confirm new password: ",
"",
"Splunk> Needle. Haystack. Found.",
"",
"Checking prerequisites...",
"\tChecking mgmt port [8089]: not available",
"ERROR: mgmt port [8089] - port is already bound. Splunk needs to use this port.",
"Would you like to change ports? [y/n]: "
]
}
I am using the pexpect module this way for username and password :
- name: Start splunk forwarder service
expect:
command: /opt/splunkforwarder/bin/splunk start --accept-license --answer-yes
responses:
(.*)Please enter an administrator username(.*): "{{ Username }}"
(.*)Please enter a new password(.*): "{{ Password }}"
(.*)Please confirm new password(.*): "{{ Password }}"
I want to add under pexpect responses - Would you like to change ports? [y/n] :.
This should be executed only when below prompts for user.
execution stops with "ERROR: mgmt port [8089] - port is already bound. Splunk needs to use this port."
Please let me know how I can achieve this?