Prompt Detail:
Here's an example Ansible playbook to install Splunk on a Linux virtual machine:
- Create a file named
install_splunk.yml
:
yaml---
- name: Install Splunk
hosts: your_vm
become: true
tasks:
- name: Download Splunk package
get_url:
url: "https://download.splunk.com/products/splunk/releases/{{ splunk_version }}/linux/splunk-{{ splunk_version }}-{{ splunk_build }}-linux-2.6-amd64.deb"
dest: "/tmp/splunk-{{ splunk_version }}-{{ splunk_build }}-linux-2.6-amd64.deb"
- name: Install Splunk package
apt:
deb: "/tmp/splunk-{{ splunk_version }}-{{ splunk_build }}-linux-2.6-amd64.deb"
state: present
- name: Start Splunk
command: "/opt/splunk/bin/splunk start --accept-license --answer-yes --auto-ports --no-prompt"
- name: Set admin password
shell: "/opt/splunk/bin/splunk edit user admin -password {{ splunk_admin_password }} -auth admin:changeme"
- Create a file named
hosts
to specify the target VM:
csharp[your_vm]
your_vm_ip_address
- Run the playbook:
bashansible-playbook -i hosts install_splunk.yml --extra-vars "splunk_version=8.2.2 splunk_build=9ae0b036e1db splunk_admin_password=your_admin_password"
Make sure to replace your_vm_ip_address
with the IP address of your Linux virtual machine and your_admin_password
with the desired admin password for Splunk.
This playbook will download the specified version and build of Splunk for Linux, install it, and start the Splunk service. The --accept-license
, --answer-yes
, and --auto-ports
options in the splunk start
command automatically accept the Splunk license, answer "yes" to prompts, and configure Splunk to use automatic port assignment respectively. The --no-prompt
option prevents the need for user interaction during the installation.