--- - name: "Retrieve PID 1 process information (Linux)" command: "ps 1" register: pid1 when: - ansible_system is match("Linux") - pid1 is not defined - name: "Restart the splunkd service - Via CLI" command: "{{ splunk_exec }} restart --answer-yes --accept-license" become: yes become_user: "{{ splunk_user }}" register: task_result until: task_result.rc == 0 retries: 3 delay: "{{ delay_num }}" when: not splunk_enable_service - name: "Restart the splunkd service - Via systemd" service: name: "{% if pid1.stdout.find('systemd') != -1 %}Splunkd{% else %}splunk{% endif %}" state: restarted when: - splunk_enable_service - ansible_system is match("Linux") become: yes become_user: "{{ privileged_user }}" - name: "Restart the splunkd service - Via windows system" win_service: name: splunkd state: restarted when: splunk_enable_service and not ansible_system is match("Linux") - name: "Wait for splunkd management port" wait_for: port: "{{ splunk_svc_port }}"