W3cubDocs

/Ansible 2.11

community.windows.win_psrepository – Adds, removes or updates a Windows PowerShell repository.

Note

This plugin is part of the community.windows collection (version 1.2.0).

To install it use: ansible-galaxy collection install community.windows.

To use it in a playbook, specify: community.windows.win_psrepository.

Synopsis

  • This module helps to add, remove and update Windows PowerShell repository on Windows-based systems.

Requirements

The below requirements are needed on the host that executes this module.

Parameters

Parameter Choices/Defaults Comments
force
boolean
    Choices:
  • no
  • yes
If True, any differences from the desired state will result in the repository being unregistered, and then re-registered.
force has no effect when state=absent. See notes for additional context.
installation_policy
string
    Choices:
  • trusted
  • untrusted
Sets the InstallationPolicy of a repository.
Will default to trusted when creating a new repository or used with force=True.
name
string / required
Name of the repository to work with.
proxy
string
added in 1.1.0 of community.windows
Proxy to use for repository.
publish_location
string
Specifies the URI for publishing modules to this repository.
script_publish_location
string
Specifies the URI for publishing scripts to this repository.
script_source_location
string
Specifies the URI for discovering and installing scripts from this repository.
source_location
string
Specifies the URI for discovering and installing modules from this repository.
A URI can be a NuGet server feed (most common situation), HTTP, HTTPS, FTP or file location.
Required when registering a new repository or using force=True.

aliases: source
state
string
    Choices:
  • absent
  • present
If present a new repository is added or updated.
If absent a repository is removed.

Notes

Note

  • See the examples on how to update the NuGet package provider.
  • You can not use win_psrepository to re-register (add) removed PSGallery, use the command Register-PSRepository -Default instead.
  • When registering or setting source_location, PowerShellGet will transform the location according to internal rules, such as following HTTP/S redirects.
  • This can result in a CHANGED status on each run as the values will never match and will be “reset” each time.
  • To work around that, find the true destination value with community.windows.win_psrepository_info or Get-PSRepository and update the playbook to match.
  • When updating an existing repository, all options except name are optional. Only supplied options will be updated. Use force=True to exactly match.
  • script_location, publish_location, and script_publish_location are optional but once set can only be cleared with force=True.
  • Using force=True will unregister and re-register the repository if there are any changes, so that it exactly matches the options specified.

See Also

See also

community.windows.win_psrepository_info

The official documentation on the community.windows.win_psrepository_info module.

community.windows.win_psmodule

The official documentation on the community.windows.win_psmodule module.

Examples

---
- name: Ensure the required NuGet package provider version is installed
  ansible.windows.win_shell: Find-PackageProvider -Name Nuget -ForceBootstrap -IncludeDependencies -Force

- name: Register a PowerShell repository
  community.windows.win_psrepository:
    name: MyRepository
    source_location: https://myrepo.com
    state: present

- name: Remove a PowerShell repository
  community.windows.win_psrepository:
    name: MyRepository
    state: absent

- name: Add an untrusted repository
  community.windows.win_psrepository:
    name: MyRepository
    installation_policy: untrusted

- name: Add a repository with different locations
  community.windows.win_psrepository:
    name: NewRepo
    source_location: https://myrepo.example/module/feed
    script_source_location: https://myrepo.example/script/feed
    publish_location: https://myrepo.example/api/module/publish
    script_publish_location: https://myrepo.example/api/script/publish

- name: Update only two properties on the above repository
  community.windows.win_psrepository:
    name: NewRepo
    installation_policy: untrusted
    script_publish_location: https://scriptprocessor.example/publish

- name: Clear script locations from the above repository by re-registering it
  community.windows.win_psrepository:
    name: NewRepo
    installation_policy: untrusted
    source_location: https://myrepo.example/module/feed
    publish_location: https://myrepo.example/api/module/publish
    force: True

Authors

  • Wojciech Sciesinski (@it-praktyk)
  • Brian Scholer (@briantist)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.11/collections/community/windows/win_psrepository_module.html