-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
KVStore Tools #177
Open
arcsector
wants to merge
21
commits into
splunk:master
Choose a base branch
from
arcsector:feat-kv-migration
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
KVStore Tools #177
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
9f689aa
init kv features
arcsector 2e10ee3
README and post_install changes
arcsector ce2c80a
Fixes for auth and disable
arcsector e30dc3a
Additional KVstore helpers and tasks
arcsector 5b71f97
added a login task and included in kvstore related tasks
dtwersky abd4739
fixed missing tick in README.md
dtwersky 2fe810b
fixed another typo in README.md
dtwersky 1fbac54
become_user to splunk for login
dtwersky 3263c35
kvstore tools fixes
arcsector 099913b
become and changed_when:false for Get current SHCluster captain
dtwersky 0abf12a
become and checked_when:false for Get current KVStore captain
dtwersky 340a3b7
Using version var & cleaning upgrade conditionals
arcsector b7272dd
Merge branch 'feat-kv-migration' of github.com:arcsector/ansible-role…
arcsector 360e7e4
created block for task. added become to whole block
dtwersky 38a5c77
fixed splunk_authenticated typo. replaced command with shell
dtwersky ffe30c4
default values for when kvstore-status doesn't return serverVersion
arcsector dcaaa7f
Change Oplog size based on support recommendations
arcsector 5061198
Check current oplog size against requested oplog size
arcsector 2fa341d
auth for statuses
arcsector 3f8d4d2
documenting oplog kv task
arcsector 483f335
bring up-to-date with master
arcsector File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
- name: Backup KVStore on desired host | ||
ansible.builtin.command: | | ||
{{ splunk_home }}/bin/splunk backup kvstore {{ archive_name | default("") }} | ||
arcsector marked this conversation as resolved.
Show resolved
Hide resolved
|
||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
register: splunk_kvstore_backup_out | ||
changed_when: splunk_kvstore_backup_out.rc == 0 | ||
failed_when: splunk_kvstore_backup_out.rc != 0 | ||
|
||
- name: Check that backup has finished | ||
ansible.builtin.command: | | ||
{{ splunk_home }}/bin/splunk splunk show kvstore-status | grep backupRestoreStatus | sed -r 's/\s+backupRestoreStatus : //g' | ||
arcsector marked this conversation as resolved.
Show resolved
Hide resolved
|
||
register: splunk_kvstore_status_out | ||
until: "{{ splunk_kvstore_status_out.stdout }} == 'Ready'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
- name: Disable KVStore if specified | ||
arcsector marked this conversation as resolved.
Show resolved
Hide resolved
|
||
include_tasks: kvstore_disable.yml | ||
when: not splunk_enable_kvstore | ||
|
||
- name: Configure initial KVStore storage engine in server.conf | ||
community.general.ini_file: | ||
path: "{{ splunk_home }}/etc/system/local/server.conf" | ||
section: kvstore | ||
option: storageEngine | ||
value: "{{ splunk_kvstore_storage }}" | ||
owner: "{{ splunk_nix_user }}" | ||
group: "{{ splunk_nix_group }}" | ||
mode: 0644 | ||
become: true | ||
when: | ||
- splunk_kvstore_storage == "wiredTiger" | ||
- splunk_enable_kvstore | ||
|
||
- name: Configure initial KVStore oplog size in server.conf | ||
community.general.ini_file: | ||
path: "{{ splunk_home }}/etc/system/local/server.conf" | ||
section: kvstore | ||
option: oplogSize | ||
value: "{{ splunk_oplog_size }}" | ||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
when: splunk_enable_kvstore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
arcsector marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- name: Disable kvstore | ||
community.general.ini_file: | ||
path: "{{ splunk_home }}/etc/system/local/server.conf" | ||
section: kvstore | ||
option: disabled | ||
value: "true" | ||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
when: not splunk_enable_kvstore | ||
notify: restart splunk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
--- | ||
- name: Set fact for kvstore Upgrade | ||
ansible.builtin.set_fact: | ||
splunk_upgrade_server: false | ||
arcsector marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Check the current kvstore storage backend | ||
ansible.builtin.command: | | ||
{{ splunk_home }}/bin/splunk show kvstore-status --verbose | grep storageEngine | sed -r 's/\s+storageEngine : //g' | ||
arcsector marked this conversation as resolved.
Show resolved
Hide resolved
arcsector marked this conversation as resolved.
Show resolved
Hide resolved
|
||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
register: splunk_kvstore_backend_out | ||
changed_when: splunk_kvstore_backend_out.rc == 0 | ||
arcsector marked this conversation as resolved.
Show resolved
Hide resolved
|
||
failed_when: splunk_kvstore_backend_out.rc != 0 | ||
|
||
- name: Check the current kvstore server version | ||
ansible.builtin.command: | | ||
{{ splunk_home }}/bin/splunk show kvstore-status --verbose | grep serverVersion | sed -r 's/\s+serverVersion : //g' | ||
arcsector marked this conversation as resolved.
Show resolved
Hide resolved
|
||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
register: splunk_current_server_version_out | ||
changed_when: splunk_current_server_version_out.rc == 0 | ||
failed_when: splunk_current_server_version_out.rc != 0 | ||
|
||
- name: Debug print kvstore backend engine | ||
ansible.builtin.debug: | ||
var: splunk_kvstore_backend_out.stdout | ||
verbosity: 2 | ||
|
||
- name: Debug print kvstore backend engine | ||
ansible.builtin.debug: | ||
var: splunk_current_server_version_out.stdout | ||
verbosity: 2 | ||
|
||
- name: Upgrade KVstore if needed | ||
block: | ||
- name: Backup KVStore | ||
include_tasks: adhoc_backup_kvstore.yml | ||
vars: | ||
- archive_name: "-archiveName preAnsibleVersionUpgradeBackup" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this maybe be customizable? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eh, not in my opinion, but it's trivial to do so. |
||
|
||
- name: Perform single-install upgrade steps | ||
block: | ||
- name: Perform < 9.0 migration steps | ||
block: | ||
- name: Define storage migration as true in server.conf | ||
community.general.ini_file: | ||
path: "{{ splunk_home }}/etc/system/local/server.conf" | ||
section: kvstore | ||
option: storageEngineMigration | ||
value: "true" | ||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
|
||
- name: Start storage engine migration on single instance | ||
ansible.builtin.command: | | ||
{{ splunk_home }}/bin/splunk migrate kvstore-storage-engine --target-engine wiredTiger --enable-compression | ||
register: splunk_migration_single_early_out | ||
changed_when: splunk_migration_single_early_out.rc == 0 | ||
failed_when: splunk_migration_single_early_out.rc != 0 | ||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
when: splunk_package_version is version(9.0, '<') | ||
|
||
- name: Perform >= 9.0 upgrade if necessary | ||
ansible.builtin.command: | | ||
{{ splunk_home }}/bin/splunk migrate migrate-kvstore | ||
register: splunk_migration_single_early_out | ||
changed_when: splunk_migration_single_early_out.rc == 0 | ||
failed_when: splunk_migration_single_early_out.rc != 0 | ||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
when: | ||
- splunk_package_version is version(9.0, '>=') | ||
- splunk_current_server_version_out.stdout is version(4.2 '<') | ||
when: splunk_shc_target_group not in group_names | ||
|
||
- name: Perform SHC KVStore upgrade | ||
block: | ||
- name: Perform SHC pre-migration Steps | ||
ansible.builtin.command: | | ||
{{ splunk_home }}/bin/splunk start-shcluster-migration kvstore -storageEngine wiredTiger -isDryRun true | ||
register: splunk_shc_pre_steps_out | ||
changed_when: splunk_shc_pre_steps_out.rc == 0 | ||
failed_when: splunk_shc_pre_steps_out.rc != 0 | ||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
|
||
- name: Start Backend migration | ||
ansible.builtin.command: | | ||
{{ splunk_home }}/bin/splunk start-shcluster-migration kvstore -storageEngine wiredTiger -clusterPerc 50 | ||
register: splunk_shc_kvstore_backend_migration_out | ||
changed_when: splunk_shc_kvstore_backend_migration_out.rc == 0 | ||
failed_when: splunk_shc_kvstore_backend_migration_out.rc != 0 | ||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
|
||
- name: Make sure migration is successful | ||
ansible.builtin.command: | | ||
{{ splunk_home }}/bin/splunk show shcluster-kvmigration-status | sed -r 's/\s+migrationStatus : //g' | ||
register: splunk_kvstore_migration_status_out | ||
changed_when: splunk_kvstore_migration_status_out.rc == 0 | ||
failed_when: splunk_kvstore_migration_status_out.rc != 0 | ||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
until: "{{ splunk_kvstore_migration_status_out.stdout }} == 'notStarted'" | ||
|
||
- name: Perform SHC pre-upgrade steps | ||
ansible.builtin.command: | | ||
{{ splunk_home }}/bin/splunk start-shcluster-upgrade kvstore -version 4.2 -isDryRun true | ||
register: splunk_kvstore_version_check_out | ||
changed_when: splunk_kvstore_version_check_out.rc == 0 | ||
failed_when: splunk_kvstore_version_check_out.rc != 0 | ||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
|
||
- name: Start Version upgrade | ||
ansible.builtin.command: | | ||
{{ splunk_home }}/bin/splunk start-shcluster-upgrade kvstore -version 4.2 | ||
register: splunk_kvstore_version_upgrade_out | ||
changed_when: splunk_kvstore_version_upgrade_out.rc == 0 | ||
failed_when: splunk_kvstore_version_upgrade_out.rc != 0 | ||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
|
||
- name: Make sure upgrade is successful | ||
ansible.builtin.command: | | ||
{{ splunk_home }}/bin/splunk show kvstore-status --verbose | sed -r 's/\s+serverVersion : //g' | ||
register: splunk_kvstore_version_status_out | ||
changed_when: splunk_kvstore_version_status_out.rc == 0 | ||
failed_when: splunk_kvstore_version_status_out.rc != 0 | ||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
until: "{{ splunk_kvstore_version_status_out.stdout is version(4.2, '>=') }}" | ||
when: splunk_shc_target_group in group_names | ||
|
||
- name: Clean up older binaries from older versions | ||
ansible.builtin.file: | ||
path: "{{ splunk_home }}/bin/{{ item }}" | ||
state: absent | ||
loop: | ||
- mongod-3.6 | ||
- mongod-4.0 | ||
- mongodump-3.6 | ||
- mongorestore-3.6 | ||
become: true | ||
become_user: "{{ splunk_nix_user }}" | ||
when: | ||
- splunk_enable_kvstore | ||
- splunk_kvstore_storage == "wiredTiger" | ||
- "'full' in group_names" | ||
- splunk_kvstore_backend_out.stdout != "wiredTiger" | ||
- splunk_current_server_version_out.stdout is version(4.2 '<') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this variable used either
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used here: 9f689aa#diff-0977dd8c4cb1bc6903196d2c0c0efd06d11183fbdb1dccf3620ffff234438804R28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, the
splunk_kvstore_version
is unused - I'll add it to the conditionals for the bottom of the upgrade procedure