community.windows.win_psrepository_copy – Copies registered PSRepositories to other user profiles¶
This plugin is part of the community.windows collection (version 1.6.0).
To install it use:
ansible-galaxy collection install community.windows.
To use it in a playbook, specify:
New in version 1.3.0: of community.windows
Copies specified registered PSRepositories to other user profiles on the system.
Can include the
Defaultprofile so that new users start with the selected repositories.
Can include special service accounts like the local SYSTEM user, LocalService, NetworkService.
Does not require the
PowerShellGetmodule or any other external dependencies.
User profiles are loaded from the registry. If a given path does not exist (like if the profile directory was deleted), it is silently skipped.
If setting service account profiles, you may need
become=yes. See examples.
When PowerShellGet first sets up a repositories file, it always adds
PSGallery, however if this module creates a new repos file and your selected repositories don’t include
PSGallery, it won’t be in your destination.
The values searched in profiles (and exclude_profiles) are profile names, not necessarily user names. This can happen when the profile path is deliberately changed or when domain user names conflict with users from the local computer or another domain. In this case the second+ user may have the domain name or local computer name appended, like
JoeUser. If you intend to filter user profiles, ensure your filters catch the right names.
In the case of the service accounts, the specific profiles are
NetworkServicefor those accounts respectively.
Repositories with credentials (requiring authentication) or proxy information will copy, but the credentials and proxy details will not as that information is not stored with repository.
- name: Copy the current user's PSRepositories to all non-service account profiles and Default profile community.windows.win_psrepository_copy: - name: Copy the current user's PSRepositories to all profiles and Default profile community.windows.win_psrepository_copy: exclude_profiles:  - name: Copy the current user's PSRepositories to all profiles beginning with A, B, or C community.windows.win_psrepository_copy: profiles: - 'A*' - 'B*' - 'C*' - name: Copy the current user's PSRepositories to all profiles beginning B except Brian and Brianna community.windows.win_psrepository_copy: profiles: 'B*' exclude_profiles: - Brian - Brianna - name: Copy a specific set of repositories to profiles beginning with 'svc' with exceptions community.windows.win_psrepository_copy: name: - CompanyRepo1 - CompanyRepo2 - PSGallery profiles: 'svc*' exclude_profiles: 'svc-restricted' - name: Copy repos matching a pattern with exceptions community.windows.win_psrepository_copy: name: 'CompanyRepo*' exclude: 'CompanyRepo*-Beta' - name: Copy repositories from a custom XML file on the target host community.windows.win_psrepository_copy: source: 'C:\data\CustomRepostories.xml' ### A sample workflow of seeding a system with a custom repository # A playbook that does initial host setup or builds system images - name: Register custom respository community.windows.win_psrepository: name: PrivateRepo source_location: https://example.com/nuget/feed/etc installation_policy: trusted - name: Ensure all current and new users have this repository registered community.windows.win_psrepository_copy: name: PrivateRepo # In another playbook, run by other users (who may have been created later) - name: Install a module community.windows.win_psmodule: name: CompanyModule repository: PrivateRepo state: present