diff --git a/.gitignore b/.gitignore index 7f9ebf4..4da00b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,102 +1,106 @@ -# ---> Ansible -*.retry - -# ---> Python -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -env/ -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.egg-info/ -.installed.cfg -*.egg - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*,cover -.hypothesis/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# SageMath parsed files -*.sage.py - -# dotenv -.env - -# virtualenv -.venv -venv/ -ENV/ - -# Spyder project settings -.spyderproject - -# Rope project settings -.ropeproject - -# Files directory -files/* -!files/.gitkeep +# ---> Ansible +*.retry + +# ---> Python +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject + +# Files directory +files/* +!files/.gitkeep + +# Inventory directory +inventory/* +!inventory/.gitkeep diff --git a/LICENSE b/LICENSE index 3f28a5f..d4c5a2e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,9 +1,9 @@ -MIT License - -Copyright (c) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index b3813a9..4cef26f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# ansible-playbook-splunk-upgrade - +# ansible-playbook-splunk-upgrade + This repository contains the playbook contents for completion of a Splunk upgrade. Distributed environments supported \ No newline at end of file diff --git a/cluster-master.yml b/cluster-master.yml index e02f8fe..67002ad 100644 --- a/cluster-master.yml +++ b/cluster-master.yml @@ -1,8 +1,7 @@ ---- -- name: Upgrade the Indexer Master - hosts: index-cluster-masters - become: true - handlers: - - import_tasks: handlers/splunk.yml - tasks: - - import_tasks: tasks/common.yml +--- +- name: Upgrade the Indexer Master + hosts: index-cluster-masters + handlers: + - import_tasks: handlers/splunk.yml + tasks: + - import_tasks: tasks/common.yml diff --git a/deployment-server.yml b/deployment-server.yml index 23ecffb..6947796 100644 --- a/deployment-server.yml +++ b/deployment-server.yml @@ -1,8 +1,7 @@ ---- -- name: Upgrade the Deployment Server - hosts: deployment-servers - become: true - handlers: - - import_tasks: handlers/splunk.yml - tasks: - - import_tasks: tasks/common.yml +--- +- name: Upgrade the Deployment Server + hosts: deployment-servers + handlers: + - import_tasks: handlers/splunk.yml + tasks: + - import_tasks: tasks/common.yml diff --git a/distributed.yml b/distributed-upgrade.yml similarity index 96% rename from distributed.yml rename to distributed-upgrade.yml index 6f2e184..c8cb7f6 100644 --- a/distributed.yml +++ b/distributed-upgrade.yml @@ -1,13 +1,13 @@ ---- -# Upgrade License Master -- import_playbook: cluster-master.yml -# Upgrade Deployment Server -- import_playbook: deployment-server.yml -# Upgrade Searchhead Deployer/s -- import_playbook: searchhead-deployer.yml -# Heavyweight Forwarder/s -- import_playbook: heavyweight-forwarders.yml -# Upgrade the Searchead Tier -- import_playbook: searchheads.yml -# Upgrade the Indexer Tier -- import_playbook: indexers.yml +--- +# Upgrade License Master +- import_playbook: cluster-master.yml +# Upgrade Deployment Server +- import_playbook: deployment-server.yml +# Upgrade Searchhead Deployer/s +- import_playbook: searchhead-deployer.yml +# Heavyweight Forwarder/s +- import_playbook: heavyweight-forwarders.yml +# Upgrade the Searchead Tier +- import_playbook: searchheads.yml +# Upgrade the Indexer Tier +- import_playbook: indexers.yml diff --git a/group_vars/all/splunk.yml b/group_vars/all/splunk.yml index 23d26b7..fe3939d 100644 --- a/group_vars/all/splunk.yml +++ b/group_vars/all/splunk.yml @@ -1,7 +1,7 @@ ---- -# Automagically included by ansible for all inventory -splunk_user: splunk -splunk_home: /opt/splunk -splunk_archive: splunk-7.2.0-8c86330ac18-Linux-x86_64.tgz -# Manifest splunk will install upon upgrade. -splunk_manifest: splunk-7.2.0-8c86330ac18-linux-2.6-x86_64-manifest +--- +# Automagically included by ansible for all inventory +splunk_user: splunk +splunk_home: /opt/splunk +splunk_archive: splunk-8.2.0-e053ef3c985f-Linux-x86_64.tgz +# Manifest splunk will install upon upgrade. +splunk_manifest: splunk-8.2.0-e053ef3c985f-linux-2.6-x86_64-manifest diff --git a/handlers/splunk.yml b/handlers/splunk.yml index da08b11..3fb2783 100644 --- a/handlers/splunk.yml +++ b/handlers/splunk.yml @@ -1,12 +1,12 @@ ---- -- name: Stop Splunk - command: /opt/splunk/bin/splunk stop - become_user: splunk - -- name: Start Splunk - command: /opt/splunk/bin/splunk start - become_user: splunk - -- name: Start Splunk (No Warning) - command: /opt/splunk/bin/splunk start --accept-license --answer-yes --no-prompt - become_user: splunk +--- +- name: Stop Splunk + command: /opt/splunk/bin/splunk stop + become_user: splunk + +- name: Start Splunk + command: /opt/splunk/bin/splunk start + become_user: splunk + +- name: Start Splunk (No Warning) + command: /opt/splunk/bin/splunk start --accept-license --answer-yes --no-prompt + become_user: splunk diff --git a/heavyweight-forwarders.yml b/heavyweight-forwarders.yml index 771e6c2..13a318f 100644 --- a/heavyweight-forwarders.yml +++ b/heavyweight-forwarders.yml @@ -1,8 +1,7 @@ ---- -- name: Upgrade the Heavyweights - hosts: heavyweight-forwarders - become: true - handlers: - - import_tasks: handlers/splunk.yml - tasks: - - import_tasks: tasks/common.yml +--- +- name: Upgrade the Heavyweights + hosts: heavyweight-forwarders + handlers: + - import_tasks: handlers/splunk.yml + tasks: + - import_tasks: tasks/common.yml diff --git a/indexers.yml b/indexers.yml index 79136cc..8b56f53 100644 --- a/indexers.yml +++ b/indexers.yml @@ -1,8 +1,8 @@ ---- -- name: Upgrade the Indexer Cluster - hosts: indexers - become: true - handlers: - - import_tasks: handlers/splunk.yml - tasks: - - import_tasks: tasks/common.yml +--- +- name: Upgrade the Indexer Cluster + hosts: indexers + become: true + handlers: + - import_tasks: handlers/splunk.yml + tasks: + - import_tasks: tasks/common.yml diff --git a/inventory/.gitkeep b/inventory/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tasks/common.yml b/tasks/common.yml index f27161c..9ec916d 100644 --- a/tasks/common.yml +++ b/tasks/common.yml @@ -1,51 +1,49 @@ ---- -- name: checking if splunk is installed - tags: install - stat: - path: "{{ splunk_home }}" - register: splunk_path - -- name: is splunk installed? - tags: install - debug: msg='splunk is already installed under /opt/splunk' - when: splunk_path.stat.exists - -- name: Check if Splunk is already upgraded? - stat: - path: /opt/splunk/{{ splunk_manifest }} - register: splunk_mani - when: splunk_path.stat.exists - -- name: Splunk upgraded - debug: - msg: Splunk Manifest is already installed! - when: splunk_mani.stat.exists - -- name: copy splunk binary - tags: - - install - copy: - src: "{{ splunk_archive }}" - dest: /tmp/splunk - owner: root - group: root - mode: 775 - when: splunk_path.stat.exists and not splunk_mani.stat.exists - - -- name: Stop Splunk - command: /opt/splunk/bin/splunk stop - become_user: splunk - when: splunk_path.stat.exists and not splunk_mani.stat.exists - -- name: install splunk binary - tags: - - install - unarchive: - src: "/tmp/splunk/{{ splunk_archive }}" - dest: /opt/ - owner: "{{ splunk_user }}" - group: "{{ splunk_user }}" - remote_src: true - notify: Start Splunk (No Warning) - when: splunk_path.stat.exists and not splunk_mani.stat.exists +--- +- name: checking if splunk is installed + tags: install + stat: + path: "{{ splunk_home }}" + register: splunk_path + +- name: is splunk installed? + tags: install + debug: msg='splunk is already installed under /opt/splunk' + when: splunk_path.stat.exists + +- name: Check if Splunk is already upgraded? + stat: + path: /opt/splunk/{{ splunk_manifest }} + register: splunk_mani + when: splunk_path.stat.exists + +- name: Splunk upgraded + debug: + msg: Splunk Manifest is already installed! + when: splunk_mani.stat.exists + +- name: copy splunk binary + tags: + - install + copy: + src: "{{ splunk_archive }}" + dest: /tmp/splunk + mode: 775 + when: splunk_path.stat.exists and not splunk_mani.stat.exists + + +- name: Stop Splunk + command: /opt/splunk/bin/splunk stop + become_user: splunk + when: splunk_path.stat.exists and not splunk_mani.stat.exists + +- name: install splunk binary + tags: + - install + unarchive: + src: "/tmp/splunk/{{ splunk_archive }}" + dest: /opt/ + owner: "{{ splunk_user }}" + group: "{{ splunk_user }}" + remote_src: true + notify: Start Splunk (No Warning) + when: splunk_path.stat.exists and not splunk_mani.stat.exists