---
-
  name: "Block to Allow Loading of Variables without running task"
  when: run_tasks
  block:
    - name: Create directory
      win_file:
        path: "{{ sysmon_install_location }}"
        state: directory
      register: result
    
    - name: Get sysmon zip
      win_get_url:
        url: "{{ sysmon_download_url_base }}/{{ sysmon_download_file }}{{ file_ext }}"
        dest: "{{ sysmon_install_location }}/{{ sysmon_download_file }}{{ file_ext }}"
    
    - name: Unzip sysmon
      win_unzip:
        src: "{{ sysmon_install_location }}/{{ sysmon_download_file }}{{ file_ext }}"
        dest: "{{ sysmon_install_location }}"
    
    - name: Copy sysmon config
      win_get_url:
        url: "{{ sysmon_config_url }}"
        dest: c:\sysmon\sysmonconfig-export.xml
    
    - name: check sysmon service
      win_service:
        name: sysmon64
      register: result
      failed_when: result is not defined
      ignore_errors: true
    
    - name: Run sysmon
      win_command: "{{ sysmon_install_location }}\\sysmon64.exe -accepteula -i {{ sysmon_install_location }}\\sysmonconfig-export.xml"
      args:
        chdir: "{{ sysmon_install_location }}"
      when: result.state is not defined or result.name is not defined
    