-
Notifications
You must be signed in to change notification settings - Fork 0
/
splunk-arch-lab-init.sh
executable file
·136 lines (121 loc) · 4.56 KB
/
splunk-arch-lab-init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
####
####
set -o errexit
#set -o pipefail
### With everything being equal, this bash script will automatically setup the environment
### need to do the following
### setup virtualenv
## install ansible in the virtual env
## clone ws's remote git repo which creates and automates the setup of the splunk arch lab servers insfrastructure
## i.e. the searchhead, the forwarders and the indexers
### The roles have been created along the functions of each server.
##
#### The env/vars.yml file contains sensitive credentials/info that has been encrypted before storing on this public git repo
### The env/vars.yml file is an **importantant** component for this script to work.
SPLUNKARCHLAB_BASE=splunkarchlab_base
SPLUNKARCHLAB_DIR=splunkarchlab
install_ansible_searchhead()
{
#cd ~/$SPLUNKARCHLAB_BASE
virtualenv -p python2.7 $SPLUNKARCHLAB_DIR
source $SPLUNKARCHLAB_DIR/bin/activate
pip install --upgrade pip
pwd
pip -q install ansible
ansible -m ping localhost
}
enable_virtualenv()
{
source $SPLUNKARCHLAB_DIR/bin/activate
}
case "$1" in
install_ansible)
install_ansible_searchhead
;;
setup_sh)
setup_searchhead()
{
enable_virtualenv
ansible-vault decrypt env/vars.yml --ask-vault-pass
ansible-playbook site.yml --tag searchhead_role --skip-tags add_indexers_to_sh,set_route,create_idx_app,create_inputs_fwd1_app,create_inputs_fwd2_app,configure_sh_as_heavy_fwd,run_diag -l searchheads
# ansible-playbook site.yml --tag set_route -l forwarders
# ansible-playbook site.yml --tag set_route -l indexers
}
setup_searchhead
;;
setup_fwds)
setup_fwds()
{
enable_virtualenv
ansible-playbook site.yml --tag sshid_fwds -l searchheads
ansible-playbook -v site.yml --tag forwarders_role --skip-tags set_fwd1_hostname,set_fwd2_hostname,run_diag -l forwarders
ansible-playbook -v site.yml --tag setsplunk-hostname_fwd1 -l fwd1
ansible-playbook -v site.yml --tag set_fwd1_hostname -l fwd1
ansible-playbook -v site.yml --tag setsplunk-hostname_fwd2 -l fwd2
ansible-playbook -v site.yml --tag set_fwd2_hostname -l fwd2
}
setup_fwds
;;
setup_fwds_subset)
setup_fwds_subset()
{
enable_virtualenv
ansible-playbook site.yml --tag sshid_fwds -l searchheads
ansible-playbook -v site.yml --tag createuser,downloadufwget,set_fwd1_hostname,installuf,start_uf,start_uf_boot,set_password1,setsplunk-hostname_fwd1,configure_uf_d_cli -l fwd1
ansible-playbook -v site.yml --tag createuser,downloadufwget,set_fwd2_hostname,installuf,start_uf,start_uf_boot,set_password1,setsplunk-hostname_fwd2,configure_uf_d_cli -l fwd2
}
setup_fwds_subset
;;
setup_idxs)
setup_idxs()
{
enable_virtualenv
# ansible-vault decrypt env/vars.yml
# ansible-playbook site.yml --tag createuser,sshid -l forwarders
ansible-playbook site.yml --tag sshid_idxs -l searchheads
ansible-playbook -v site.yml --tag indexers_role --skip-tags set_idx1_hostname,set_idx2_hostname,run_diag -l indexers
ansible-playbook -v site.yml --tag setsplunk-hostname_idx1 -l idx1
ansible-playbook -v site.yml --tag set_idx1_hostname -l idx1
ansible-playbook -v site.yml --tag setsplunk-hostname_idx2 -l idx2
ansible-playbook -v site.yml --tag set_idx2_hostname -l idx2
}
setup_idxs
;;
config_sh_2)
config_sh_2()
{
enable_virtualenv
ansible-playbook site.yml --tag add_indexers_to_sh,configure_sh_as_heavy_fwd -l searchheads
ansible-playbook site.yml --tag create_idx_app -l searchheads
ansible-playbook site.yml --tag create_inputs_fwd1_app -l searchheads
ansible-playbook site.yml --tag create_inputs_fwd2_app -l searchheads
}
config_sh_2
;;
create_diag)
create_diag()
{
enable_virtualenv
ansible-playbook site.yml --tag run_diag -l searchheads
ansible-playbook site.yml --tag run_diag -l forwarders
ansible-playbook site.yml --tag run_diag -l indexers
}
create_diag
;;
ping_sh)
enable_virtualenv
ansible all -m ping
;;
ping_fwds)
enable_virtualenv
ansible forwarders -m ping
;;
ping_idxs)
enable_virtualenv
ansible indexers -m ping
;;
*)
echo $"Usage: $0 {install_ansible | setup_sh | setup_fwds | setup_idxs | ping_sh | ping_fwds| ping_idxs | config_sh_2 | setup_fwds_subset | create_diag }"
exit 1
esac