• Blog
  • Ansible community forum
  • Documentation
Ansible Logo
Ansible Community Documentation
Ansible

Ansible getting started

  • Getting started with Ansible
  • Getting started with Execution Environments

Installation, Upgrade & Configuration

  • Installation Guide
  • Ansible Porting Guides

Using Ansible

  • Building Ansible inventories
  • Using Ansible command line tools
  • Using Ansible playbooks
  • Protecting sensitive data with Ansible vault
  • Using Ansible modules and plugins
  • Using Ansible collections
  • Using Ansible on Windows, BSD, and z/OS UNIX
  • Ansible tips and tricks

Contributing to Ansible

  • Ansible Community Guide
  • Ansible Collections Contributor Guide
  • ansible-core Contributors Guide
  • Advanced Contributor Guide
  • Ansible documentation style guide

Extending Ansible

  • Developer Guide

Common Ansible Scenarios

  • Legacy Public Cloud Guides

Network Automation

  • Network Getting Started
  • Network Advanced Topics
  • Network Developer Guide

Ansible Galaxy

  • Galaxy User Guide
  • Galaxy Developer Guide

Reference & Appendices

  • Collection Index
    • Collections in the Amazon Namespace
    • Collections in the Ansible Namespace
    • Collections in the Arista Namespace
    • Collections in the Awx Namespace
    • Collections in the Azure Namespace
    • Collections in the Check_point Namespace
    • Collections in the Chocolatey Namespace
    • Collections in the Cisco Namespace
    • Collections in the Cloud Namespace
    • Collections in the Cloudscale_ch Namespace
    • Collections in the Community Namespace
    • Collections in the Containers Namespace
    • Collections in the Cyberark Namespace
    • Collections in the Dellemc Namespace
    • Collections in the F5networks Namespace
    • Collections in the Fortinet Namespace
    • Collections in the Frr Namespace
    • Collections in the Gluster Namespace
    • Collections in the Google Namespace
    • Collections in the Grafana Namespace
    • Collections in the Graphiant Namespace
    • Collections in the Hetzner Namespace
    • Collections in the Hitachivantara Namespace
    • Collections in the Hpe Namespace
    • Collections in the Ibm Namespace
    • Collections in the Ieisystem Namespace
    • Collections in the Infinidat Namespace
    • Collections in the Infoblox Namespace
    • Collections in the Inspur Namespace
    • Collections in the Junipernetworks Namespace
    • Collections in the Kaytus Namespace
    • Collections in the Kubernetes Namespace
    • Collections in the Kubevirt Namespace
    • Collections in the Lowlydba Namespace
    • Collections in the Mellanox Namespace
    • Collections in the Microsoft Namespace
      • Microsoft.Ad
        • Description
        • Communication
        • Scenario Guides
        • Plugin Index
      • Microsoft.Iis
    • Collections in the Netapp Namespace
    • Collections in the Netapp_eseries Namespace
    • Collections in the Netbox Namespace
    • Collections in the Ngine_io Namespace
    • Collections in the Openstack Namespace
    • Collections in the Openvswitch Namespace
    • Collections in the Ovirt Namespace
    • Collections in the Pcg Namespace
    • Collections in the Purestorage Namespace
    • Collections in the Ravendb Namespace
    • Collections in the Sensu Namespace
    • Collections in the Servicenow Namespace
    • Collections in the Splunk Namespace
    • Collections in the T_systems_mms Namespace
    • Collections in the Telekom_mms Namespace
    • Collections in the Theforeman Namespace
    • Collections in the Vmware Namespace
    • Collections in the Vultr Namespace
    • Collections in the Vyos Namespace
    • Collections in the Wti Namespace
  • Indexes of all modules and plugins
  • Playbook Keywords
  • Return Values
  • Ansible Configuration Settings
  • Controlling how Ansible behaves: precedence rules
  • YAML Syntax
  • Python 3 Support
  • Interpreter Discovery
  • Releases and maintenance
  • Testing Strategies
  • Sanity Tests
  • Frequently Asked Questions
  • Glossary
  • Ansible Reference: Module Utilities
  • Special Variables
  • Red Hat Ansible Automation Platform
  • Ansible Automation Hub
  • Logging Ansible output

Roadmaps

  • Ansible Roadmap
  • ansible-core Roadmaps
Ansible
  • Collection Index
  • Collections in the Microsoft Namespace
  • Microsoft.Ad
  • microsoft.ad.gpo module – Manage Group Policy Object links
  • Edit on GitHub

microsoft.ad.gpo module – Manage Group Policy Object links

Note

This module is part of the microsoft.ad collection (version 1.12.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install microsoft.ad.

To use it in a playbook, specify: microsoft.ad.gpo.

New in microsoft.ad 1.12.0

  • Synopsis

  • Parameters

  • Attributes

  • Notes

  • See Also

  • Examples

Synopsis

  • Create, modify, or remove a Group Policy Object (GPO) link on a target container such as an OU, domain, or site.

  • Uses the GroupPolicy PowerShell module cmdlets New-GPLink, Set-GPLink, Remove-GPLink, and Get-GPInheritance.

Parameters

Parameter

Comments

domain_server

string

The FQDN of the domain controller to target for all operations.

When not specified, the module uses the default domain controller discovery.

enabled

boolean

Whether the GPO link is enabled.

When not specified during creation, the link defaults to enabled.

Choices:

  • false

  • true

enforced

boolean

Whether the GPO link is enforced (No Override).

When not specified during creation, the link defaults to not enforced.

Choices:

  • false

  • true

guid

string

The GUID of the GPO to link.

Mutually exclusive with name.

One of name or guid must be provided.

name

string

The display name of the GPO to link.

Mutually exclusive with guid.

One of name or guid must be provided.

order

integer

The link order (1-based) for the GPO on the target container.

Lower numbers have higher precedence.

state

string

Whether the GPO link should be present or absent on the target.

Choices:

  • "present" ← (default)

  • "absent"

target

string / required

The distinguished name of the container (OU, domain, or site) to which the GPO should be linked.

Example: OU=Servers,DC=contoso,DC=com.

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target, if not supported the action will be skipped.

diff_mode

Support: full

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode

platform

Platform: windows

Target OS/families that can be operated against

Notes

Note

  • This module must be run on a Windows host with the GroupPolicy PowerShell module installed (available on domain controllers or via RSAT).

  • The GPO identified by name or guid must already exist. This module does not create or delete GPOs, only their links.

See Also

See also

microsoft.ad.ou

Manage Active Directory organizational units.

microsoft.ad.object_info

Gather information an Active Directory object.

Examples

- name: Link a GPO to an OU
  microsoft.ad.gpo:
    name: Security_Hardening_Policy
    target: 'OU=Servers,DC=contoso,DC=com'
    state: present

- name: Link a GPO by GUID and enforce it
  microsoft.ad.gpo:
    guid: 5990264b-7000-482d-a2f0-c43eb26aa956
    target: 'OU=Workstations,DC=contoso,DC=com'
    enforced: true
    state: present

- name: Disable a GPO link without removing it
  microsoft.ad.gpo:
    name: Optional_Policy
    target: 'OU=Staging,DC=contoso,DC=com'
    enabled: false
    state: present

- name: Set link order for a GPO
  microsoft.ad.gpo:
    name: Security_Hardening_Policy
    target: 'OU=Servers,DC=contoso,DC=com'
    order: 1
    state: present

- name: Remove a GPO link from an OU
  microsoft.ad.gpo:
    name: Old_Policy
    target: 'OU=Servers,DC=contoso,DC=com'
    state: absent

- name: Link a GPO using a specific domain controller
  microsoft.ad.gpo:
    name: Security_Hardening_Policy
    target: 'OU=Servers,DC=contoso,DC=com'
    domain_server: dc01.contoso.com
    state: present

Authors

  • Ron Gershburg (@rgershbu)

Collection links

  • Issue Tracker
  • Repository (Sources)
  • Report an issue
  • Communication
Previous Next

© Copyright Ansible project contributors. Last updated on Jul 20, 2026.