Änderungen von Dokument Eigene Autoconf-Rolle erstellen

Zuletzt geändert von Tom Altenbrunn am 2023/03/17 08:03

Von Version 30.2
bearbeitet von Tom Altenbrunn
am 2023/03/16 10:35
Änderungskommentar: Es gibt keinen Kommentar für diese Version
Auf Version 27.1
bearbeitet von Jonas Mayer
am 2023/03/16 07:48
Änderungskommentar: Es gibt keinen Kommentar für diese Version

Zusammenfassung

Details

Seiteneigenschaften
Dokument-Autor
... ... @@ -1,1 +1,1 @@
1 -XWiki.TomAltenbrunn@sbede
1 +XWiki.jonasmayer@sbede
Inhalt
... ... @@ -2,6 +2,7 @@
2 2  
3 3  ----
4 4  
5 +
5 5  = (% style="font-size:22px" %)__**Allgemeines**__(%%) =
6 6  
7 7  
... ... @@ -95,9 +95,17 @@
95 95  ----
96 96  
97 97  
98 -= (% style="font-size:22px" %)__**Funktionsfertiges Beispiel: Rolle „WLAN Profil mit PSK anlegen“**__(%%) =
99 99  
100 100  
101 +
102 +
103 +
104 +
105 +
106 +
107 += (% style="font-size:22px" %)__**Weiteres, funktionsfertiges Beispiel: Rolle „WLAN Profil mit PSK anlegen“**__(%%) =
108 +
109 +
101 101  Zum besseren Verständnis wird nachfolgend eine feste Autoconf-Rolle zur Konfiguration eines WLAN-Profils (SSID inkl. PSK) an Clients näher beleuchtet.
102 102  
103 103  (% class="box" %)
... ... @@ -117,7 +117,7 @@
117 117   license: SBE
118 118  (% style="color:#8e44ad" %) uuid:(%%) 52318636-c4f5-11ea-baf9-0bff00c66ff4
119 119   visible: true
120 -(% style="color:#19177c" %) priority:(%%) 0
129 + (% style="color:#19177c" %)priority:(%%) 0
121 121   applyAlways: false
122 122  (% style="color:#f1c40f" %) tags:(%%)
123 123   - CUSTOM
... ... @@ -157,17 +157,16 @@
157 157  
158 158  == (% style="font-size:16px" %)**Inhalt des PowerShell-Skripts main.ps1, das die Variablen entgegennimmt**(%%) ==
159 159  
160 -Im Unterverzeichnis {{box}} win/ {{/box}} oder {{box}} lin/ {{/box}} der Autoconf-Rolle können sich wie erläutert unterschiedliche PowerShell-Skripte zur Ausführung in den verschiedenen Phasen befinden.
161 -In dieser Rolle liegt konkret das allgemeingültige Skript {{box}}main.ps1{{/box}} vor, welches die Variablen als Parameter ##$ssid## und ##$psk## intern verwendet.
169 +Im Unterverzeichnis {{box}} win/ {{/box}} oder {{box}} lin/ {{/box}} der Autoconf-Rolle können sich unterschiedliche PowerShell-Skripte zur Ausführung in den Phasen befinden. In dieser Rolle liegt das allgemeingültige Skript {{box}}main.ps1{{/box}} vor, welches die Variablen als Parameter ##$ssid## und ##$psk## intern verwendet.
162 162  
171 +(% class="box" %)
172 +(((
173 +(% style="color:#27ae60" %)# Windows Variante(%%)
174 +root@ctrl-g1:~~ # cat /usr/lib/ld-autoconf/logodidact/roles/ld_wlan_psk/win/main.ps1
175 +)))
163 163  
164 -(% style="color:#19177c" %)**Windows Variante**
165 165  
166 -{{code language="text" width="50%"}}
167 -root@ctrl-g1:~ # cat /usr/lib/ld-autoconf/logodidact/roles/ld_wlan_psk/win/main.ps1
168 -{{/code}}
169 -
170 -{{code width="50%" language="powershell"}}
178 +{{code width="50%"}}
171 171  Param
172 172  (
173 173   [parameter(Mandatory=$false)]
... ... @@ -222,151 +222,18 @@
222 222  }
223 223  {{/code}}
224 224  
233 +==== ====
225 225  
226 -(% style="color:#19177c" %)**Linux Variante (Network Manager)**
235 +==== ====
227 227  
228 -{{code language="text" width="50%"}}
229 -root@ctrl-g1:~ # cat /usr/lib/ld-autoconf/logodidact/roles/ld_wlan_psk/lin/main.ps1
230 -{{/code}}
237 +==== ====
231 231  
232 -{{code language="powershell" width="50%"}}
233 -Param
234 -(
235 - [parameter(Mandatory=$false)]
236 - [String]
237 - $ssid,
238 - [parameter(Mandatory=$false)]
239 - [String]
240 - $psk
241 -)
239 +==== ====
242 242  
243 -if ($ssid -ne '' -and $psk -ne '') {
244 - if (Get-Command "nmcli" -ErrorAction SilentlyContinue) {
245 - # Check if kernel modules are up
246 - nmcli dev wifi rescan
247 - if ($LASTEXITCODE -ne 0) {
248 - Start-Sleep -Seconds 30
249 - }
250 -
251 - # Check again
252 - nmcli dev wifi rescan
253 - if ($LASTEXITCODE -ne 0) {
254 - Write-Verbose "Skipping role. There might be no WiFi device installed."
255 - exit 0
256 - }
257 -
258 - $config = "/etc/NetworkManager/system-connections/$ssid"
241 +==== ====
259 259  
260 - if (Test-Path -Path $config) {
261 - Write-Verbose "Removing '$config'"
262 - Remove-Item -Path $config -Recurse -Force
263 - }
243 +==== ====
264 264  
265 - Write-Verbose "Connecting to '$ssid'"
266 -
267 - nmcli device wifi connect """$ssid""" password """$psk"""
268 -
269 - if ($LASTEXITCODE -eq 0) {
270 - Start-Sleep -Seconds 5
271 - nmcli con up """$ssid"""
245 +==== ====
272 272  
273 - if ($LASTEXITCODE -ne 0) {
274 - Write-Verbose "Error: Credentials wrong?"
275 -
276 - if (Test-Path -Path $config) {
277 - Write-Verbose "Removing '$config'"
278 - Remove-Item -Path $config -Recurse -Force
279 - }
280 - }
281 - }
282 -
283 - Write-Verbose "Exiting with code: $LASTEXITCODE"
284 - exit $LASTEXITCODE
285 - }
286 -
287 - Write-Verbose "No suitable implementation found"
288 - exit 1
289 -}
290 -{{/code}}
291 -
292 -----
293 -
294 -= (% style="font-size:22px" %)__**Beispiel: eigene AutoConf-Rolle zur "Deaktivierung der Suchhervorhebung in Windows"**__(%%) =
295 -
296 -= =
297 -
298 -(((
299 -Im nachfolgenden Beispiel wird eine einfache Rolle zur Deaktivierung der Suchvorhebung in Windows deklariert. 
300 -[[image:image-20230316103442-2.png||height="530" width="1142" class="img-thumbnail"]]
301 -
302 -
303 -== (% style="font-size:16px" %)**Aufbau der Logodidact.yml:**(%%) ==
304 -
305 -Neben den allgemeinen Informationen über die Autoren (authors), Unternehmen (company), einer Beschreibung (description), dem Anzeigenamen (display_name) im LD Control Center, usw, beginnt im Abschnitt {{code language="bash"}}vars{{/code}} die eigentliche Definition der Variable
306 -"**{{code language="bash"}}disableSearchHighlight{{/code}}**".
307 -
308 -{{code language="yaml" width="45%"}}
309 -#logodidact.yml
310 -
311 -ld_info:
312 - authors:
313 - - Olav Krapp
314 - - Marcel Petersen
315 - - Kerim Ekin
316 - company: SBE network solutions GmbH
317 - description: | #Beschreibung
318 - Die Suchhervorhebung in der Windows Suchleiste wird deaktiviert
319 - display_name: Windows Suchhervorhebung #Anzeigename im LD Control Center
320 - license: SBE
321 - uuid: fec4ff30-b2a6-407f-a6b3-0a621cd7eaf7 #einmalige UUID
322 - vars: #Deklaration der Variablen
323 - disableSearchHighlight: #Name der Variable
324 - display_name: Suchhervorhebung im Suchfeld deaktivieren #Anzeigename im LD Control Center
325 - optional: true #Auswahl optional
326 - type: BOOLEAN #Variablentyp Boolean = True/False
327 - value: false #Standardwert false
328 - visible: true #Sichtbarkeit der Variable im LD Control Center
329 - priority: 0 #Abarbeitungspriorität
330 - applyAlways: false #Rolle immer ausführen oder einmalig
331 - tags:
332 - - CUSTOM #Ausführungszeitpunkt während der/den Phase(n)
333 - systems:
334 - - WINDOWS #Betriebssystem
335 -{{/code}}
336 -
337 -== ==
338 -
339 -== (% style="font-size:16px" %)**Aufbau der main.ps1:**(%%) ==
340 -
341 -
342 -Danach erfolgt die Erstellung des ausführbaren Codes per Powershell. Im ersten Abschnitt Param werden die in der im vorigen Abschnitt definierten Variaben "vars" aus der logodidact.yml aufgeführt und definiert. Bei der Variable "disableSearchHighlight" handelt es sich um ein Boolean (True/False). Die Bedingung "[parameter(Mandatory=$false)]" setzt das Vorhandensein der Variable während dem Ablauf des Skriptes nicht als zwingend notwendig voraus, sodass bei einem darauffolgenden Verarbeitungsfehler o.ä. die Abarbeitung weiter erfolgt.
343 -\\{{code language="powershell"}}#main.ps1
344 -
345 -Param
346 -(
347 - [parameter(Mandatory=$false)] #Variable zwingend erforderlich?
348 - [bool] #Variablentyp
349 - $disableSearchHighlight #Name der def. Variable aus logodidact.yml
350 -)
351 -
352 -$SystemVersion=[System.Environment]::OSVersion.Version #Hole Windows Systemversion
353 -
354 -if ($SystemVersion.Major -eq 10 -and $SystemVersion.Build -ge 19044) {
355 - $val = [int]!$disableSearchHighlight
356 - Write-Verbose "Setting EnableDynamicContentInWSB to '$val'"
357 - [Microsoft.Win32.Registry]::SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search","EnableDynamicContentInWSB",$val,[Microsoft.Win32.RegistryValueKind]::DWord)
358 -} else {
359 - Write-Host "Feature ist erst ab dem Release 21H2 verfügbar."
360 -}{{/code}}
361 -
362 -
363 -== (% style="font-size:16px" %)**Einlesen der AutoConf-Rollen am Server:**(%%) ==
364 -
365 -[[image:image-20230316103224-1.png||height="128" width="1226" class="img-thumbnail"]]
366 -
367 -==
368 -(% style="font-size:16px" %)**Ansicht im LD Control Center:**(%%) ==
369 -
370 -(% class="wikigeneratedid" %)
371 - [[image:image-20230316095106-2.png||class="img-thumbnail"]]
372 -)))
247 +==== ====
image-20230316094933-1.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.TomAltenbrunn@sbede
Größe
... ... @@ -1,1 +1,0 @@
1 -43.3 KB
Inhalt
image-20230316095106-2.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.TomAltenbrunn@sbede
Größe
... ... @@ -1,1 +1,0 @@
1 -47.8 KB
Inhalt
image-20230316102252-3.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.TomAltenbrunn@sbede
Größe
... ... @@ -1,1 +1,0 @@
1 -166.3 KB
Inhalt
image-20230316102302-4.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.TomAltenbrunn@sbede
Größe
... ... @@ -1,1 +1,0 @@
1 -166.3 KB
Inhalt
image-20230316103224-1.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.TomAltenbrunn@sbede
Größe
... ... @@ -1,1 +1,0 @@
1 -166.3 KB
Inhalt
image-20230316103442-2.png
Author
... ... @@ -1,1 +1,0 @@
1 -XWiki.TomAltenbrunn@sbede
Größe
... ... @@ -1,1 +1,0 @@
1 -201.2 KB
Inhalt