Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Managing Windows Updates with Ansible in Red Hat Enterprise Linux

June 2, 2017
Jose Angel Munoz
Related topics:
DevOpsLinux
Related products:
Streams for Apache KafkaRed Hat Enterprise Linux

    Introduction

    When looking for installation instructions of Ansible under RHEL, I have always have found two ways:

    1. With epel-release (Which I don't like just because I want to keep my system clean).
    2. From source code (Which I don't like either for the same reason).

    Packages Installation

    For me, the right approach for the installation is installing from the Official Red Hat Repository and following the instructions below:

    Select the server-extras-beta repository (Here we will find the ansible packages)

    subscription-manager repos --enable=rhel-7-server-extras-beta-rpms

    Install some extra packages we will need later (in order to install some python packages and have Kerberos auth for Windows):

    yum -y install gcc python-devel krb5-devel krb5-workstation

    And go for Ansible installation:

    yum install -y ansible

    And now, the non-standard part. We will use pip in for the Kerberos Authentication support.

    easy_install pip
    pip install https://github.com/diyan/pywinrm/archive/master.zip#egg=pywinrm
    pip install kerberos
    pip install requests_Kerberos

    Ansible Configuration

    Edit the Ansible hosts file adding the Windows Servers and the Kerberos Authentication:

    /etc/ansible/hosts

    [windows]
    server.domain.com
    appserver.domain.com

    [windows:vars]
    ansible_ssh_user=user@DOMAIN.COM
    ansible_ssh_pass=SecretPassword
    ansible_ssh_port=5986
    ansible_connection=winrm
    ansible_winrm_server_cert_validation=ignore

    Edit the Kerberos Configuration file and add your domain configuration

    /etc/krb5.conf

    # Configuration snippets may be placed in this directory as well
    includedir /etc/krb5.conf.d/
    
    [logging]
    default = FILE:/var/log/krb5libs.log
    kdc = FILE:/var/log/krb5kdc.log
    admin_server = FILE:/var/log/kadmind.log
    
    [libdefaults]
    dns_lookup_realm = false
    ticket_lifetime = 24h
    renew_lifetime = 7d
    forwardable = true
    rdns = false
    default_realm = DOMAIN.COM
    default_ccache_name = KEYRING:persistent:%{uid}
    default_tgs_enctypes = arcfour-hmac-md5 des-cbc-crc des-cbc-md5
    default_tkt_enctypes = arcfour-hmac-md5 des-cbc-crc des-cbc-md5
    
    [realms]
    DOMAIN.COM = {
      kdc = server.domain.com
      admin_server = server.domain.com
    }
    
    [domain_realm]
    .domain.com = DOMAIN.COM
    domain.com = DOMAIN.COM

    Windows Configuration

    Under the Windows Servers (Mine are 2012R2), we will download and run the following script as follows:

    ConfigureRemotingForAnsible.ps1

    powershell.exe -File ConfigureRemotingForAnsible.ps1 -ForceNewSSLCert

    Server Test

    In order to test our installation, we will ping our server with the command:

    ansible server.domain.com -m win_ping

    If everything goes right, we will have the following result:

    server.domain.com | SUCCESS => {
      "changed": false,
      "ping": "pong"
    }

    Playbook for Windows Update

    We just want to know if the server has updates available. The following playbook will do the job:

    ---
    # windows-updates.yml
    
    - hosts: windows
      serial: 1
      remote_user: user@DOMAIN.COM
    
      tasks:
    
        # Check of there are missing updates
          - block:
              - name: Check for missing updates.
                win_updates: state=searched
                register: update_count
              - name: List missing updates
                debug: var=update_count

    Running the playbook

    We will be able to run the playbook for a single server with the command:

    ansible-playbook -l appserver.domain.com windows-updates.yml

    We will have two possible results:

    1. If there are updates available

      PLAY [windows] ******************************************************************************************************************************************************************************************************************************
      TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
      ok: [appserver.domain.com]
      TASK [Check for missing updates.] ***********************************************************************************************************************************************************************************************************
      changed: [appserver.domain.com]
      TASK [List missing updates] *****************************************************************************************************************************************************************************************************************
      ok: [appserver.domain.com] => {
          "changed": false,
          "update_count": {
              "changed": true,
              "failed_update_count": 0,
              "found_update_count": 3,
              "installed_update_count": 3,
              "reboot_required": true,
              "updates": {
                  "38c0bc96-f072-4bfc-9f5a-c704b1b0b30c": {
                      "id": "38c0bc96-f072-4bfc-9f5a-c704b1b0b30c",
                      "installed": true,
                      "kb": [
                          "890830"
                      ],
                      "title": "Windows Malicious Software Removal Tool for Windows 8, 8.1, 10 and Windows Server 2012, 2012 R2, 2016 x64 Edition - May 2017 (KB890830)"
                  },
                  "5ee9120d-5bfe-4093-8ad6-9e83a6b0f02b": {
                      "id": "5ee9120d-5bfe-4093-8ad6-9e83a6b0f02b",
                      "installed": true,
                      "kb": [
                          "4019114"
                      ],
                      "title": "May, 2017 Security and Quality Rollup for .NET Framework 3.5, 4.5.2, 4.6, 4.6.1, 4.6.2 on Windows 8.1 and Windows Server 2012 R2 for x64 (KB4019114)"
                  },
                  "d2281849-7314-4da5-bed1-9e8e4d74b4ed": {
                      "id": "d2281849-7314-4da5-bed1-9e8e4d74b4ed",
                      "installed": true,
                      "kb": [
                          "4019215"
                      ],
                      "title": "2017-05 Security Monthly Quality Rollup for Windows Server 2012 R2 for x64-based Systems (KB4019215)"
                  }
              }
          }
      }
      PLAY RECAP **********************************************************************************************************************************************************************************************************************************
      appserver.domain.com   : ok=3    changed=1    unreachable=0    failed=0
    2. If the System is Up to Date

      server.domain.com | SUCCESS => {
          "changed": false,
          "found_update_count": 0,
          "installed_update_count": 0,
          "reboot_required": true,
          "updates": {}
      }
    Last updated: July 25, 2023

    Recent Posts

    • Federated identity across the hybrid cloud using zero trust workload identity manager

    • Confidential virtual machine storage attack scenarios

    • Introducing virtualization platform autopilot

    • Integrate zero trust workload identity manager with Red Hat OpenShift GitOps

    • Best Practice Configuration and Tuning for Linux and Windows VMs

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.