--- # Perform actual migration of a server. # PREREQUITES: # 1) An initial rsync should have been performed (see rsync_colddb) # 2) Cluster should be in maintenance mode # # Specify extra vars for both "target" and "folder" # # e.g.: # ansible-playbook migrate_single_indexer.yml --extra-vars="target=10.10.10.10 folder=defaultdb" - hosts: "{{ target }}" become: true become_user: splunk serial: 1 tasks: # Verify folder is defined - name: Variable check fail: msg="Variable 'folder' is not defined or is invalid. Please run with --extra-vars=\"target=x folder=dbfolder\"" when: (folder is not defined) # Verify folder exists - name: Ensure folder already exists stat: path: /opt/splunk/var/lib/splunkcold/{{ folder }}/colddb register: colddbpath - name: Fail if the folder doesn't exist fail: msg="The colddb folder does not exist." when: not(colddbpath.stat.isdir is defined and colddbpath.stat.isdir) - debug: msg: "Cold Path exists. Good." when: colddbpath.stat.isdir is defined and colddbpath.stat.isdir # Verify migrated folder does not exist (DO NOT RUN TWICE!) - name: Ensure migrated folder does not exist stat: path: /opt/splunk/var/lib/splunk/{{ folder }}/colddb.migrated register: colddbmigratedpath - name: Fail if the migrated folder exist fail: msg="The migrated folder already exists. (Already run on this index?)" when: colddbmigratedpath.stat.isdir is defined and colddbmigratedpath.stat.isdir - debug: msg: "Migrated Cold Path does not exist. Good." when: not(colddbmigratedpath.stat.isdir is defined and coldmigratedpath.stat.isdir) # Stop Splunk - name: Stop Splunk command: /opt/splunk/bin/splunk stop - name: rsync cold data command: rsync -avz --delete /opt/splunk/var/lib/splunk/{{ folder }}/colddb/ /opt/splunk/var/lib/splunkcold/{{ folder }}/colddb/ # Run this asynchyronously for one hour, polling every 30. # async: 604800 # poll: 60 register: rsync_result - name: overwrite indexes.conf copy: src: ../files/indexes.conf dest: /opt/splunk/etc/slave-apps/_cluster/local/indexes.conf owner: splunk group: splunk mode: 0600 - name: Rename Colddb path command: mv /opt/splunk/var/lib/splunk/{{ folder }}/colddb /opt/splunk/var/lib/splunk/{{ folder }}/colddb.migrated - name: Btool Check for Good Measure command: /opt/splunk/bin/splunk btool check - name: start splunk command: /opt/splunk/bin/splunk start - name: sleep after command: sleep 60