Debian Codegraph @

ansible_collections/community/windows/plugins/modules/win_psrepository_copy.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2020, Brian Scholer <@briantist>
5 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 DOCUMENTATION = r'''
8 ---
9 module: win_psrepository_copy
10 short_description: Copies registered PSRepositories to other user profiles
11 version_added: '1.3.0'
12 description:
13 - Copies specified registered PSRepositories to other user profiles on the system.
14 - Can include the C(Default) profile so that new users start with the selected repositories.
15 - Can include special service accounts like the local SYSTEM user, LocalService, NetworkService.
16 options:
17 source:
18 description:
19 - The full path to the source repositories XML file.
20 - Defaults to the repositories registered to the current user.
21 type: path
22 default: '%LOCALAPPDATA%\Microsoft\Windows\PowerShell\PowerShellGet\PSRepositories.xml'
23 name:
24 description:
25 - The names of repositories to copy.
26 - Names are interpreted as wildcards.
27 type: list
28 elements: str
29 default: ['*']
30 exclude:
31 description:
32 - The names of repositories to exclude.
33 - Names are interpreted as wildcards.
34 - If a name matches both an include (I(name)) and I(exclude), it will be excluded.
35 type: list
36 elements: str
37 profiles:
38 description:
39 - The names of user profiles to populate with repositories.
40 - Names are interpreted as wildcards.
41 - The C(Default) profile can also be matched.
42 - The C(Public) and C(All Users) profiles cannot be targeted, as PSRepositories are not loaded from them.
43 type: list
44 elements: str
45 default: ['*']
46 exclude_profiles:
47 description:
48 - The names of user profiles to exclude.
49 - If a profile matches both an include (I(profiles)) and I(exclude_profiles), it will be excluded.
50 - By default, the service account profiles are excluded.
51 - To explcitly exclude nothing, set I(exclude_profiles=[]).
52 type: list
53 elements: str
54 default:
55 - systemprofile
56 - LocalService
57 - NetworkService
58 force:
59 description:
60 - If C(True), this deletes repositories that are not present in the source.
61 type: bool
62 default: False
63 version_added: 2.4.0
64 notes:
65 - Does not require the C(PowerShellGet) module or any other external dependencies.
66 - 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.
67 - If setting service account profiles, you may need C(become=yes). See examples.
68 - "When PowerShellGet first sets up a repositories file, it always adds C(PSGallery), however if this module creates a new repos file and your selected
69 repositories don't include C(PSGallery), it won't be in your destination."
70 - "The values searched in I(profiles) (and I(exclude_profiles)) are profile names, not necessarily user names. This can happen when the profile path is
71 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
72 domain name or local computer name appended, like C(JoeUser.Contoso) vs. C(JoeUser).
73 If you intend to filter user profiles, ensure your filters catch the right names."
74 - "In the case of the service accounts, the specific profiles are C(systemprofile) (for the C(SYSTEM) user), and C(LocalService) or C(NetworkService)
75 for those accounts respectively."
76 - "Repositories with credentials (requiring authentication) or proxy information will copy, but the credentials and proxy details will not as that
77 information is not stored with repository."
78 seealso:
79 - module: community.windows.win_psrepository
80 - module: community.windows.win_psrepository_info
81 author:
82 - Brian Scholer (@briantist)
83 '''
84
85 EXAMPLES = r'''
86 - name: Copy the current user's PSRepositories to all non-service account profiles and Default profile
87 community.windows.win_psrepository_copy:
88
89 - name: Copy the current user's PSRepositories to all profiles and Default profile
90 community.windows.win_psrepository_copy:
91 exclude_profiles: []
92
93 - name: Copy the current user's PSRepositories to all profiles beginning with A, B, or C
94 community.windows.win_psrepository_copy:
95 profiles:
96 - 'A*'
97 - 'B*'
98 - 'C*'
99
100 - name: Copy the current user's PSRepositories to all profiles beginning B except Brian and Brianna
101 community.windows.win_psrepository_copy:
102 profiles: 'B*'
103 exclude_profiles:
104 - Brian
105 - Brianna
106
107 - name: Copy a specific set of repositories to profiles beginning with 'svc' with exceptions
108 community.windows.win_psrepository_copy:
109 name:
110 - CompanyRepo1
111 - CompanyRepo2
112 - PSGallery
113 profiles: 'svc*'
114 exclude_profiles: 'svc-restricted'
115
116 - name: Copy repos matching a pattern with exceptions
117 community.windows.win_psrepository_copy:
118 name: 'CompanyRepo*'
119 exclude: 'CompanyRepo*-Beta'
120
121 - name: Copy repositories from a custom XML file on the target host
122 community.windows.win_psrepository_copy:
123 source: 'C:\data\CustomRepostories.xml'
124
125 ### A sample workflow of seeding a system with a custom repository
126
127 # A playbook that does initial host setup or builds system images
128
129 - name: Register custom respository
130 community.windows.win_psrepository:
131 name: PrivateRepo
132 source_location: https://example.com/nuget/feed/etc
133 installation_policy: trusted
134
135 - name: Ensure all current and new users have this repository registered
136 community.windows.win_psrepository_copy:
137 name: PrivateRepo
138
139 # In another playbook, run by other users (who may have been created later)
140
141 - name: Install a module
142 community.windows.win_psmodule:
143 name: CompanyModule
144 repository: PrivateRepo
145 state: present
146 '''
147
148 RETURN = r'''
149 '''