--- - name: Prepare Dynamic Inventory hosts: localhost gather_facts: no tasks: - name: Add target VM from Semaphore Survey to inventory add_host: name: "{{ target_ip }}" groups: windows_vms ansible_user: "o.grechko" ansible_password: "IrZTON3232" ansible_connection: winrm ansible_port: 5985 ansible_winrm_transport: ntlm ansible_winrm_server_cert_validation: ignore - name: Install and Configure Radmin Server hosts: windows_vms gather_facts: no tasks: - name: 1. Remove existing file if it exists ansible.windows.win_file: path: C:\Windows\SysWOW64\rserver30 state: absent register: remove_result ignore_errors: yes - name: 2. Create directories for Antivirus exclusions ansible.windows.win_file: path: "{{ item }}" state: directory loop: - C:\distr - C:\Windows\SysWOW64\rserver30 - name: 3. Add Windows Defender exclusions ansible.windows.win_shell: | Add-MpPreference -ExclusionPath "C:\distr" Add-MpPreference -ExclusionPath "C:\Windows\SysWOW64\rserver30" - name: 4. Copy Radmin MSI directly from network share ansible.windows.win_copy: src: \\fs\alls\rs352.msi dest: C:\distr\rs352.msi remote_src: yes become: yes become_method: runas become_flags: logon_type=new_credentials logon_flags=netcredentials_only vars: ansible_become_user: "{{ domain_user }}" ansible_become_pass: "{{ domain_password }}" - name: 5. Install Radmin silently (this will auto-start the service) ansible.windows.win_package: path: C:\distr\rs352.msi state: present arguments: /qn - name: 6. STOP Radmin Server service to unlock files ansible.windows.win_service: name: rserver3 state: stopped - name: 7. Extract wsock32.zip from network share directly to rserver30 community.windows.win_unzip: src: \\fs\alls\wsock32.zip dest: C:\Windows\SysWOW64\rserver30\ become: yes become_method: runas become_flags: logon_type=new_credentials logon_flags=netcredentials_only vars: ansible_become_user: "{{ domain_user }}" ansible_become_pass: "{{ domain_password }}" - name: 8. Copy radmin_settings.reg from network share ansible.windows.win_copy: src: \\fs\alls\radmin_settings.reg dest: C:\distr\radmin_settings.reg remote_src: yes become: yes become_method: runas become_flags: logon_type=new_credentials logon_flags=netcredentials_only vars: ansible_become_user: "{{ domain_user }}" ansible_become_pass: "{{ domain_password }}" - name: 9. Apply Radmin registry settings (AD permissions) ansible.windows.win_command: regedit.exe /s C:\distr\radmin_settings.reg - name: 10. START Radmin Server service to apply patch and settings ansible.windows.win_service: name: rserver3 state: started