--- - name: Configure WSUS server tags: configure_wsus block: - name: Ensure Content directory exists win_file: path: "{{ wsus_content_directory }}" state: directory - name: Set WSUS Content Directory tags: set_wsus_content_dir win_shell: | CD "C:\Program Files\Update Services\Tools" .\wsusutil.exe postinstall CONTENT_DIR=W:\WSUS - name: WSUS Script tags: wsus_script block: - name: Copy WSUS script win_copy: src: "{{ wsus_script }}" dest: "powershell {{ script_dir }}\\{{ wsus_script }}" force: true tags: copy_wsus_script - name: Apply WSUS script win_shell: "powershell {{ script_dir }}\\{{ wsus_script }}" tags: apply_wsus_script #- name: Ensure WSUS server is deployed (UpdateServicesDSC) - Errors here :( # tags: testing # win_dsc: # resource_name: UpdateServicesServer # Ensure: Present # ContentDir: '{{ wsus_content_directory }}' # Languages: en # #Products: "{{ wsus_products }}" # Products: "Windows Admin Center" # PsDscRunAsCredential_username: Administrator # PsDscRunAsCredential_password: "{{ ansible_password }}" # #ErrorRecord: test # Classifications: # - "{{ CriticalUpdates }}" # #- "{{ DefinitionUpdates }}" # #- "{{ SecurityUpdates }}" # #- "{{ ServicePacks }}" # #- "{{ UpdateRollups }}" # #- "{{ Updates }}" # #Synchronize: True # SynchronizeAutomatically: True # SynchronizeAutomaticallyTimeOfDay: '15:30:00' # ClientTargetingMode: "{{ wsus_client_targeting_mode }}" ##- name: Configure WSUS server ## block: ## - name: Ensure Content directory exists ## win_file: ## path: '{{ wsus_content_dir }}' ## state: directory ## - name: Ensure WSUS server is deployed (UpdateServicesDSC) - Errors here :( ## win_dsc: ## resource_name: UpdateServicesServer ## Ensure: Present ## ContentDir: '{{ wsus_content_dir }}' ## Languages: en ## Products: "{{ wsus_products }}" ## Classifications: ## - "{{ wsus_category_names['CriticalUpdates'].id }}" ## #- "{{ wsus_category_names['DefinitionUpdates'].id }}" ## #- "{{ wsus_category_names['SecurityUpdates'].id }}" ## #- "{{ wsus_category_names['ServicePacks'].id }}" ## #- "{{ wsus_category_names['UpdateRollups'].id }}" ## #- "{{ wsus_category_names['Updates'].id }}" ## # Ignore upstream as we don't have one yet... ## #UpstreamServerName: "{{ wsus_upstream_server_name | default(omit) }}" ## #UpstreamServerPort: "{{ wsus_upstream_server_port | default(omit) }}" ## #UpstreamServerSSL: "{{ wsus_upstream_server_ssl | default(omit) }}" ## Synchronize: True ## SynchronizeAutomatically: True ## SynchronizeAutomaticallyTimeOfDay: '01:30:00' ## ClientTargetingMode: "{{ wsus_client_targeting_mode }}" ## ignore_errors: true ## retries: 2 ## - name: Apply approval rules (UpdateServicesDSC) ## win_dsc: ## resource_name: UpdateServicesApprovalRule ## Name: "{{ wsus_category_names[item].name }}" ## Classifications: "{{ wsus_category_names[item].id }}" ## Enabled: True ## RunRuleNow: True ## loop: ## - CriticalUpdates ## #- DefinitionUpdates ## #- SecurityUpdates ## #- ServicePacks ## #- UpdateRollups ## #- Updates ## - name: Clean up updates (UpdateServicesDSC) ## win_dsc: ## resource_name: UpdateServicesCleanup ## Ensure: Present ## DeclineExpiredUpdates: True ## DeclineSupersededUpdates: True ## CleanupObsoleteUpdates: True ## CleanupUnneededContentFiles: True ## # Might be handy: https://github.com/slopez888/vsphere-ansible/blob/master/roles/wsus-server-configure/tasks/max_xml_per_request.yml ## - name: obtain WSUS DB name ## win_reg_stat: ## path: HKLM:\SOFTWARE\Microsoft\Update Services\Server\Setup ## name: SqlDatabaseName ## register: wsus_db_name ## when: inventory_hostname in groups['meta-Tags_wsus']