migrate_single_indexer.yml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ---
  2. # Perform actual migration of a server.
  3. # PREREQUITES:
  4. # 1) An initial rsync should have been performed (see rsync_colddb)
  5. # 2) Cluster should be in maintenance mode
  6. #
  7. # Specify extra vars for both "target" and "folder"
  8. #
  9. # e.g.:
  10. # ansible-playbook migrate_single_indexer.yml --extra-vars="target=10.10.10.10 folder=defaultdb"
  11. - hosts: "{{ target }}"
  12. become: true
  13. become_user: splunk
  14. serial: 1
  15. tasks:
  16. # Verify folder is defined
  17. - name: Variable check
  18. fail: msg="Variable 'folder' is not defined or is invalid. Please run with --extra-vars=\"target=x folder=dbfolder\""
  19. when: (folder is not defined)
  20. # Verify folder exists
  21. - name: Ensure folder already exists
  22. stat:
  23. path: /opt/splunk/var/lib/splunkcold/{{ folder }}/colddb
  24. register: colddbpath
  25. - name: Fail if the folder doesn't exist
  26. fail: msg="The colddb folder does not exist."
  27. when: not(colddbpath.stat.isdir is defined and colddbpath.stat.isdir)
  28. - debug:
  29. msg: "Cold Path exists. Good."
  30. when: colddbpath.stat.isdir is defined and colddbpath.stat.isdir
  31. # Verify migrated folder does not exist (DO NOT RUN TWICE!)
  32. - name: Ensure migrated folder does not exist
  33. stat:
  34. path: /opt/splunk/var/lib/splunk/{{ folder }}/colddb.migrated
  35. register: colddbmigratedpath
  36. - name: Fail if the migrated folder exist
  37. fail: msg="The migrated folder already exists. (Already run on this index?)"
  38. when: colddbmigratedpath.stat.isdir is defined and colddbmigratedpath.stat.isdir
  39. - debug:
  40. msg: "Migrated Cold Path does not exist. Good."
  41. when: not(colddbmigratedpath.stat.isdir is defined and coldmigratedpath.stat.isdir)
  42. # Stop Splunk
  43. - name: Stop Splunk
  44. command: /opt/splunk/bin/splunk stop
  45. - name: rsync cold data
  46. command: rsync -avz --delete /opt/splunk/var/lib/splunk/{{ folder }}/colddb/ /opt/splunk/var/lib/splunkcold/{{ folder }}/colddb/
  47. # Run this asynchyronously for one hour, polling every 30.
  48. # async: 604800
  49. # poll: 60
  50. register: rsync_result
  51. - name: overwrite indexes.conf
  52. copy:
  53. src: ../files/indexes.conf
  54. dest: /opt/splunk/etc/slave-apps/_cluster/local/indexes.conf
  55. owner: splunk
  56. group: splunk
  57. mode: 0600
  58. - name: Rename Colddb path
  59. command: mv /opt/splunk/var/lib/splunk/{{ folder }}/colddb /opt/splunk/var/lib/splunk/{{ folder }}/colddb.migrated
  60. - name: Btool Check for Good Measure
  61. command: /opt/splunk/bin/splunk btool check
  62. - name: start splunk
  63. command: /opt/splunk/bin/splunk start
  64. - name: sleep after
  65. command: sleep 60