Felhasználói eszközök

Eszközök a webhelyen


ansible:windows

Összehasonlítás

A kiválasztott és az jelenlegi változat között az alábbi különbségek fordulnak elő:

Összehasonlító nézet hivatkozása

Előző változat mindkét oldalonElőző változat
Következő változat
Előző változat
ansible:windows [2026/05/26 08:40] – [Több felhasználó létrehozása] riba.zoltanansible:windows [2026/05/29 10:00] (aktuális) – [Fájl műveletek] riba.zoltan
Sor 1: Sor 1:
 ====== Windows szerver kezelése Ansible programmal ====== ====== Windows szerver kezelése Ansible programmal ======
  
-Adminisztrátorként futtatott PowerShell parancssorban adjuk ki az alábbi utasításokat a TerminalServer szolgáltatás engedélyezéséhez:+===== Távoli elérés (opcionális) ===== 
 + 
 +Adminisztrátorként futtatott PowerShell parancssorban adjuk ki az alábbi utasításokat a TerminalServer szolgáltatás bekapcsolásához. 
 + 
 +=== Szolgáltatás engedélyezése ===
  
 <code> <code>
Sor 15: Sor 19:
 PSDrive            : HKLM PSDrive            : HKLM
 PSProvider         : Microsoft.PowerShell.Core\Registry PSProvider         : Microsoft.PowerShell.Core\Registry
- 
 </code> </code>
 +
 +=== Tűzfal szabályok módosítása ===
  
 <code> <code>
 PS C:\Users\Administrator> Enable-NetFirewallRule -DisplayGroup "Remote Desktop" PS C:\Users\Administrator> Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
 </code> </code>
 +
 +=== Szolgáltatás ellenőrzése ===
  
 <code> <code>
Sor 31: Sor 38:
 </code> </code>
  
-Adminisztrátorként futtatott PowerShell parancssorban adjuk ki az alábbi utasításokat a WinRM szolgáltatás engedélyezéséhez:+===== WinRM szolgáltatás ===== 
 + 
 +Adminisztrátorként futtatott PowerShell parancssorban adjuk ki az alábbi utasításokat a WinRM szolgáltatás bekapcsolásához.
  
-Szolgáltatás konfigurálása+=== Szolgáltatás konfigurálása ===
  
 <code> <code>
Sor 39: Sor 48:
 </code> </code>
  
-Szolgáltatás engedélyezése és ellenőrzése+=== Szolgáltatás engedélyezése és ellenőrzése ===
  
 <code> <code>
Sor 98: Sor 107:
 </code> </code>
  
-Engedélyezzük a megfelelő hitelesítési eljárást+=== Hitelesítési eljárás beállítása ===
  
 <code> <code>
 PS C:\Users\Administrator> winrm set winrm/config/service/auth '@{Basic="false";Kerberos="true";Negotiate="true"}' PS C:\Users\Administrator> winrm set winrm/config/service/auth '@{Basic="false";Kerberos="true";Negotiate="true"}'
 +
 Auth Auth
     Basic = false     Basic = false
Sor 111: Sor 121:
 </code> </code>
  
-Ellenőrizzük a tűzfal szabályrendszert+=== Tűzfal szabályrendszer ellenőrzése ===
  
 <code> <code>
Sor 159: Sor 169:
 </code> </code>
  
-Engedélyezzük a hozzáférést+=== Hozzáférés engedélyezése ===
  
 <code> <code>
Sor 165: Sor 175:
 </code> </code>
  
-Ismét ellenőrizzük a tűzfal szabályrendszert+=== Tűzfal szabályrendszer ismételt ellenőrzése ===
  
 <code> <code>
Sor 213: Sor 223:
 </code> </code>
  
-==== Ellenőrizzük a szolgáltatást az ansible oldalon ====+==== Szolgáltatás ellenőrzése (ansible) ==== 
 + 
 +=== Ellenőrző műveletek ===
  
 <code> <code>
Sor 551: Sor 563:
 win2022                    : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    win2022                    : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 </code> </code>
 +
 +Windows oldalon a profil és a felhasználó törlése adminisztrátorként futtatott PS utasítások segítségével elvégezhető:
 +
 +<code>
 +PS C:\Users\Administrator> Get-CimInstance Win32_UserProfile | Where LocalPath -eq "C:\Users\USERNAME" | Remove-CimInstance
 +
 +PS C:\Users\Administrator> Remove-LocalUser USERNAME
 +</code>
 +
 +Ugyanez megoldható szkript segítségével
 +
 +<file powershell delete-local-user.ps1>
 +$user = "USERNAME"
 +
 +Get-CimInstance Win32_UserProfile |
 +Where-Object {
 +    $_.LocalPath -eq "C:\Users\$USERNAME"
 +} |
 +ForEach-Object {
 +
 +    if (-not $_.Loaded) {
 +        Remove-CimInstance $_
 +    }
 +}
 +</file>
  
 ==== Több felhasználó létrehozása ==== ==== Több felhasználó létrehozása ====
  
 <file yaml 03-create-local-users.yaml> <file yaml 03-create-local-users.yaml>
 +- hosts: windows 
 +  vars: 
 +    local_users: 
 +      - { name: "user2", pass: "Linux2026%" } 
 +      - { name: "user3", pass: "Linux2026%" } 
 +      - { name: "user4", pass: "Linux2026%" } 
 +  tasks: 
 +    - ansible.windows.win_user: 
 +        name: "{{ item.name }}" 
 +        password: "{{ item.pass }}" 
 +        state: present 
 +      loop: "{{ local_users }}"
 </file> </file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 03-create-local-users.yaml 
 +
 +PLAY [windows] *****************************************************************
 +
 +TASK [Gathering Facts] *********************************************************
 +ok: [win2022]
 +
 +TASK [ansible.windows.win_user] ************************************************
 +changed: [win2022] => (item={'name': 'user2', 'pass': 'Linux2026%'})
 +changed: [win2022] => (item={'name': 'user3', 'pass': 'Linux2026%'})
 +changed: [win2022] => (item={'name': 'user4', 'pass': 'Linux2026%'})
 +
 +PLAY RECAP *********************************************************************
 +win2022                    : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
  
 A felhasználók lekérdezhetők PowerShell segítségével. A felhasználók lekérdezhetők PowerShell segítségével.
Sor 568: Sor 633:
 </code> </code>
  
 +==== Több felhasználó törlése ====
  
-Windows oldalon a profil és a felhasználó törlése adminisztrátorként futtatott PS utasítások segítségével elvégezhető:+<file yaml 03-delete-local-users.yaml> 
 +- hosts: windows 
 +  vars: 
 +    local_users: 
 +      - user2 
 +      - user3 
 +      - user4 
 + 
 +  tasks: 
 +    - name: Delete user profiles first 
 +      ansible.windows.win_user_profile: 
 +        username: "{{ item }}" 
 +        state: absent 
 +      loop: "{{ local_users }}" 
 + 
 +    - name: Delete local Windows users 
 +      ansible.windows.win_user: 
 +        name: "{{ item }}" 
 +        state: absent 
 +      loop: "{{ local_users }}" 
 +</file>
  
 <code> <code>
-PS C:\Users\Administrator> Get-CimInstance Win32_UserProfile | Where LocalPath -eq "C:\Users\USERNAME" | Remove-CimInstance+[ansible@ansible ~]$ ansible-playbook 03-delete-local-users.yaml 
  
-PS C:\Users\Administrator> Remove-LocalUser USERNAME+PLAY [windows] ***************************************************************** 
 + 
 +TASK [Gathering Facts] ********************************************************* 
 +ok: [win2022] 
 + 
 +TASK [Delete user profiles first] ********************************************** 
 +ok: [win2022] => (item=user2) 
 +ok: [win2022] => (item=user3) 
 +ok: [win2022] => (item=user4) 
 + 
 +TASK [Delete local Windows users] ********************************************** 
 +changed: [win2022] => (item=user2) 
 +changed: [win2022] => (item=user3) 
 +changed: [win2022] => (item=user4) 
 + 
 +PLAY RECAP ********************************************************************* 
 +win2022                    : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 </code> </code>
  
-Ugyanez megoldható szkript segítségével+===== Active Directory szolgáltatások =====
  
-<file powershell delete-local-user.ps1> +Ebben a példában az Active Directory szerver ''kutyacica.lan'' tartománya a ''adc.kutyacica.lan'' gépen érhető el.
-$user = "USERNAME"+
  
-Get-CimInstance Win32_UserProfile | +==== Előkészítő műveletek ====
-Where-Object { +
-    $_.LocalPath -eq "C:\Users\$USERNAME" +
-} | +
-ForEach-Object {+
  
-    if (-not $_.Loaded) { +Ansible gépen telepíteni kell a ''microsoft.ad'' gyűjteményt. 
-        Remove-CimInstance $_ + 
-    }+<code> 
 +[ansible@ansible ~]$ ansible-galaxy collection install microsoft.ad 
 +Starting galaxy collection install process 
 +Process install dependency map 
 +Starting collection install process 
 +Downloading https://galaxy.ansible.com/api/v3/plugin/ansible/content/published/collections/artifacts/microsoft-ad-1.11.0.tar.gz to /home/ansible/.ansible/tmp/ansible-local-67186v5wyun37/tmpplulm2oa/microsoft-ad-1.11.0-p_fjaa6z 
 +Installing 'microsoft.ad:1.11.0' to '/home/ansible/.ansible/collections/ansible_collections/microsoft/ad' 
 +microsoft.ad:1.11.0 was installed successfully 
 + 
 +[ansible@ansible ~]$ ansible-galaxy collection list 
 + 
 +# /home/ansible/.ansible/collections/ansible_collections 
 +Collection        Version 
 +----------------- ------- 
 +ansible.windows   3.5.0   
 +community.windows 3.2.0   
 +microsoft.ad      1.11.0  
 +</code> 
 + 
 +==== Szervezeti egység létrehozása ==== 
 + 
 +<file yaml 04-create-ad-ou.yaml> 
 +- name: Create AD organizational units 
 +  hosts: windows 
 +  gather_facts: false 
 + 
 +  tasks: 
 +    - name: Create Users OU 
 +      microsoft.ad.ou: 
 +        name: TanfolyamUsers 
 +        path: DC=kutyacica,DC=lan 
 +        state: present 
 + 
 +    - name: Create Groups OU 
 +      microsoft.ad.ou: 
 +        name: TanfolyamGroups 
 +        path: DC=kutyacica,DC=lan 
 +        state: present 
 +</file> 
 + 
 +<code> 
 +[ansible@ansible ~]$ ansible-playbook 04-create-ad-ou.yaml  
 + 
 +PLAY [Create AD organizational units] ****************************************** 
 + 
 +TASK [Create Users OU] ********************************************************* 
 +changed: [adc] 
 + 
 +TASK [Create Groups OU] ******************************************************** 
 +changed: [adc] 
 + 
 +PLAY RECAP ********************************************************************* 
 +adc                        : ok=2    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    
 +</code> 
 + 
 +==== Csoport létrehozása ==== 
 + 
 +<file yaml 04-create-ad-group.yaml> 
 +- name: Create AD group 
 +  hosts: windows 
 +  gather_facts: false 
 + 
 +  tasks: 
 +    - name: Create global security group 
 +      microsoft.ad.group: 
 +        name: LinuxAdmins 
 +        path: OU=TanfolyamGroups,DC=kutyacica,DC=lan 
 +        scope: global 
 +        category: security 
 +        description: Linux rendszergazdák 
 +        state: present 
 +</file> 
 + 
 +<code> 
 +[ansible@ansible ~]$ ansible-playbook 04-create-ad-group.yaml  
 + 
 +PLAY [Create AD group] ********************************************************* 
 + 
 +TASK [Create global security group] ******************************************** 
 +changed: [adc] 
 + 
 +PLAY RECAP ********************************************************************* 
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    
 +</code> 
 + 
 +==== Felhasználó létrehozása ==== 
 + 
 +<file yaml 04-create-ad-user.yaml> 
 +- name: Create AD user 
 +  hosts: windows 
 +  gather_facts: false 
 + 
 +  tasks: 
 +    - name: Create user jkovacs 
 +      microsoft.ad.user: 
 +        name: jkovacs 
 +        firstname: János 
 +        surname: Kovács 
 +        display_name: "Kovács János" 
 +        upn: jkovacs@kutyacica.lan 
 +        sam_account_name: jkovacs 
 +        path: OU=TanfolyamUsers,DC=kutyacica,DC=lan 
 +        password: "KezdoJelszo123!" 
 +        enabled: true 
 +        state: present 
 +</file> 
 + 
 +<code> 
 +[ansible@ansible ~]$ ansible-playbook 04-create-ad-user.yaml  
 + 
 +PLAY [Create AD user] ********************************************************** 
 + 
 +TASK [Create user jkovacs] ***************************************************** 
 +changed: [adc] 
 + 
 +PLAY RECAP ********************************************************************* 
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    
 +</code> 
 + 
 +==== Felhasználó módosítása ==== 
 + 
 +<file yaml 04-modify-ad-user.yaml> 
 +- name: Modify AD user attributes 
 +  hosts: windows 
 +  gather_facts: false 
 +  tasks: 
 +    - name: Modify user attributes 
 +      microsoft.ad.user: 
 +        identity: jkovacs 
 +        firstname: János 
 +        surname: Kovács 
 +        display_name: "Kovács János" 
 +        description: "Linux oktató" 
 +        company: "Kutyacica Kft." 
 +        city: "Budapest" 
 +        state_province: "Budapest" 
 +        street: "Fő utca 1" 
 +        postal_code: "1111" 
 +        country: "HU" 
 +        email: "jkovacs@kutyacica.lan" 
 +        attributes: 
 +          set: 
 +            department: "IT" 
 +            title: "Senior Linux Administrator" 
 +            telephoneNumber: "+3612345678" 
 +        enabled: true 
 +        state: present 
 +</file> 
 + 
 +<code> 
 +[ansible@ansible ~]$ ansible-playbook 04-modify-ad-user.yaml  
 + 
 +PLAY [Modify AD user attributes] *********************************************** 
 + 
 +TASK [Modify user attributes] ************************************************** 
 +changed: [adc] 
 + 
 +PLAY RECAP ********************************************************************* 
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    
 +</code> 
 + 
 +Megjegyzés: Az attribútumok közül közvetlenül csak az alábbi lista elemei módosíthatók: 
 + 
 +domain_username, postal_code, delegates, city, update_password, enabled, password, domain_credentials, spn, path, street, password_expired, identity, groups, upn, country, protect_from_deletion, state, state_province, sam_account_name, email, company, attributes, domain_server, surname, description, password_never_expires, account_locked, firstname, display_name, name, user_cannot_change_password, domain_password, principals_allowed_to_delegate, spns, lastname 
 + 
 +Minden más esetben az attribútum az 
 + 
 +<code> 
 +        attributes: 
 +          set: 
 +            attributeName: érték 
 +</code> 
 + 
 +módszerrel módosítható. 
 + 
 +==== Felhasználó jelszavának cseréje ==== 
 + 
 +<file yaml 04-change-ad-user-password.yaml>  
 +- name: Change AD user password 
 +  hosts: windows 
 +  gather_facts: false 
 +  tasks: 
 +    - name: Set new password 
 +      microsoft.ad.user: 
 +        identity: jkovacs 
 +        password: "UjJelszo123!" 
 +        update_password: always 
 +        state: present 
 +</file> 
 + 
 +<code> 
 +[ansible@ansible ~]$ ansible-playbook 04-change-ad-user-password.yaml  
 + 
 +PLAY [Change AD user password] ************************************************* 
 + 
 +TASK [Set new password] ******************************************************** 
 +changed: [adc] 
 + 
 +PLAY RECAP ********************************************************************* 
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    
 +</code> 
 + 
 +==== Felhasználó tiltása ==== 
 + 
 +<file yaml 04-disable-ad-user.yaml> 
 +- name: Disable AD user 
 +  hosts: windows 
 +  gather_facts: false 
 +  tasks: 
 +    - name: Disable user 
 +      microsoft.ad.user: 
 +        identity: jkovacs 
 +        enabled: false 
 +        state: present 
 +</file> 
 + 
 +<code> 
 +[ansible@ansible ~]$ ansible-playbook 04-disable-ad-user.yaml  
 + 
 +PLAY [Disable AD user] ********************************************************* 
 + 
 +TASK [Disable user] ************************************************************ 
 +changed: [adc] 
 + 
 +PLAY RECAP ********************************************************************* 
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    
 +</code> 
 + 
 +==== Felhasználó engedélyezése ==== 
 + 
 +<file yaml 04-enable-ad-user.yaml> 
 +- name: Enable AD user 
 +  hosts: windows 
 +  gather_facts: false 
 +  tasks: 
 +    - name: Enable user 
 +      microsoft.ad.user: 
 +        identity: jkovacs 
 +        enabled: true 
 +        state: present 
 +</file> 
 + 
 +<code> 
 +[ansible@ansible ~]$ ansible-playbook 04-enable-ad-user.yaml  
 + 
 +PLAY [Enable AD user] ********************************************************** 
 + 
 +TASK [Enable user] ************************************************************ 
 +changed: [adc] 
 + 
 +PLAY RECAP ********************************************************************* 
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    
 +</code> 
 + 
 +==== Felhasználó törlése ==== 
 + 
 +<file yaml 04-delete-ad-user.yaml> 
 +- name: Delete AD user 
 +  hosts: windows 
 +  gather_facts: false 
 +  tasks: 
 +    - name: Delete user 
 +      microsoft.ad.user: 
 +        identity: jkovacs 
 +        state: absent 
 +</file> 
 + 
 +<code> 
 +[ansible@ansible ~]$ ansible-playbook 04-delete-ad-user.yaml  
 + 
 +PLAY [Delete AD user] ********************************************************** 
 + 
 +TASK [Delete user] ************************************************************* 
 +changed: [adc] 
 + 
 +PLAY RECAP ********************************************************************* 
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    
 +</code> 
 + 
 +==== Csoport törlése ==== 
 + 
 +<file yaml 04-delete-ad-group.yaml> 
 +- name: Delete AD group 
 +  hosts: windows 
 +  gather_facts: false 
 +  tasks: 
 +    - name: Delete global security group 
 +      microsoft.ad.group: 
 +        name: LinuxAdmins 
 +        state: absent 
 +</file> 
 + 
 +<code> 
 +[ansible@ansible ~]$ ansible-playbook 04-delete-ad-group.yaml  
 + 
 +PLAY [Delete AD group] ********************************************************* 
 + 
 +TASK [Delete global security group] ******************************************** 
 +ok: [adc] 
 + 
 +PLAY RECAP ********************************************************************* 
 +adc                        : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    
 +</code> 
 + 
 +==== Szervezeti egység törlése ==== 
 + 
 +<file yaml 04-delete-ad-ou.yaml> 
 +- name: Delete AD organizational units 
 +  hosts: windows 
 +  gather_facts: false 
 +  tasks: 
 +    - name: Delete Users OU 
 +      microsoft.ad.ou: 
 +        name: TanfolyamUsers 
 +        path: DC=kutyacica,DC=lan 
 +        state: absent 
 + 
 +    - name: Delete Groups OU 
 +      microsoft.ad.ou: 
 +        name: TanfolyamGroups 
 +        path: DC=kutyacica,DC=lan 
 +        state: absent 
 +</file> 
 + 
 +<code> 
 +[ansible@ansible ~]$ ansible-playbook 04-delete-ad-ou.yaml  
 + 
 +PLAY [Delete AD organizational units] ****************************************** 
 + 
 +TASK [Delete Users OU] ********************************************************* 
 +changed: [adc] 
 + 
 +TASK [Delete Groups OU] ******************************************************** 
 +changed: [adc] 
 + 
 +PLAY RECAP ********************************************************************* 
 +adc                        : ok=2    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    
 +</code> 
 + 
 +==== Teljes példa ==== 
 + 
 +<file yaml 04-ad.yaml> 
 +04-ad.yaml  
 +- name: Manage AD objects 
 +  hosts: windows 
 +  gather_facts: false 
 + 
 +  vars: 
 +    ad_state: present 
 + 
 +    domain_dn: "DC=kutyacica,DC=lan" 
 + 
 +    ad_ous: 
 +      - name: TanfolyamUsers 
 +        path: "{{ domain_dn }}" 
 +      - name: TanfolyamGroups 
 +        path: "{{ domain_dn }}" 
 + 
 +    ad_groups: 
 +      - name: LinuxAdmins 
 +        path: "OU=TanfolyamGroups,{{ domain_dn }}" 
 +        scope: global 
 +        category: security 
 + 
 +    ad_users: 
 +      - username: jkovacs 
 +        firstname: János 
 +        surname: Kovács 
 +      - username: nagy.peter 
 +        firstname: Péter 
 +        surname: Nagy 
 + 
 +  tasks: 
 +    - name: Create OUs 
 +      microsoft.ad.ou: 
 +        name: "{{ item.name }}" 
 +        path: "{{ item.path }}" 
 +        protect_from_deletion: false 
 +        state: present 
 +      loop: "{{ ad_ous }}" 
 +      when: ad_state == "present" 
 + 
 +    - name: Create groups 
 +      microsoft.ad.group: 
 +        name: "{{ item.name }}" 
 +        path: "{{ item.path }}" 
 +        scope: "{{ item.scope }}" 
 +        category: "{{ item.category }}" 
 +        state: present 
 +      loop: "{{ ad_groups }}" 
 +      when: ad_state == "present" 
 + 
 +    - name: Create users 
 +      microsoft.ad.user: 
 +        name: "{{ item.username }}" 
 +        firstname: "{{ item.firstname }}" 
 +        surname: "{{ item.surname }}" 
 +        display_name: "{{ item.surname }} {{ item.firstname }}" 
 +        upn: "{{ item.username }}@kutyacica.lan" 
 +        sam_account_name: "{{ item.username }}" 
 +        path: "OU=TanfolyamUsers,{{ domain_dn }}" 
 +        password: "KezdoJelszo123!" 
 +        enabled: true 
 +        state: present 
 +      loop: "{{ ad_users }}" 
 +      when: ad_state == "present" 
 + 
 +    - name: Add users to group 
 +      microsoft.ad.group: 
 +        name: LinuxAdmins 
 +        path: "OU=TanfolyamGroups,{{ domain_dn }}" 
 +        members: 
 +          add: "{{ ad_users | map(attribute='username') | list }}" 
 +        state: present 
 +      when: ad_state == "present" 
 + 
 +    - name: Delete users 
 +      microsoft.ad.user: 
 +        identity: "{{ item.username }}" 
 +        state: absent 
 +      loop: "{{ ad_users }}" 
 +      when: ad_state == "absent" 
 + 
 +    - name: Delete groups 
 +      microsoft.ad.group: 
 +        identity: "{{ item.name }}" 
 +        state: absent 
 +      loop: "{{ ad_groups }}" 
 +      when: ad_state == "absent" 
 + 
 +    - name: Delete OUs 
 +      microsoft.ad.ou: 
 +        name: "{{ item.name }}" 
 +        path: "{{ item.path }}" 
 +        state: absent 
 +      loop: "{{ ad_ous | reverse | list }}" 
 +      when: ad_state == "absent" 
 +</file> 
 + 
 +=== Létrehozás === 
 + 
 +<code> 
 +[ansible@ansible ~]$ ansible-playbook 04-ad.yaml -e ad_state=present 
 + 
 +PLAY [Manage AD objects] ******************************************************* 
 + 
 +TASK [Create OUs] ************************************************************** 
 +changed: [adc] => (item={'name': 'TanfolyamUsers', 'path': 'DC=kutyacica,DC=lan'}) 
 +changed: [adc] => (item={'name': 'TanfolyamGroups', 'path': 'DC=kutyacica,DC=lan'}) 
 + 
 +TASK [Create groups] *********************************************************** 
 +changed: [adc] => (item={'name': 'LinuxAdmins', 'path': 'OU=TanfolyamGroups,DC=kutyacica,DC=lan', 'scope': 'global', 'category': 'security'}) 
 + 
 +TASK [Create users] ************************************************************ 
 +changed: [adc] => (item={'username': 'jkovacs', 'firstname': 'János', 'surname': 'Kovács'}) 
 +changed: [adc] => (item={'username': 'nagy.peter', 'firstname': 'Péter', 'surname': 'Nagy'}) 
 + 
 +TASK [Add users to group] ****************************************************** 
 +changed: [adc] 
 + 
 +TASK [Delete users] ************************************************************ 
 +skipping: [adc] => (item={'username': 'jkovacs', 'firstname': 'János', 'surname': 'Kovács'})  
 +skipping: [adc] => (item={'username': 'nagy.peter', 'firstname': 'Péter', 'surname': 'Nagy'})  
 +skipping: [adc] 
 + 
 +TASK [Delete groups] *********************************************************** 
 +skipping: [adc] => (item={'name': 'LinuxAdmins', 'path': 'OU=TanfolyamGroups,DC=kutyacica,DC=lan', 'scope': 'global', 'category': 'security'})  
 +skipping: [adc] 
 + 
 +TASK [Delete OUs] ************************************************************** 
 +skipping: [adc] => (item={'name': 'TanfolyamGroups', 'path': 'DC=kutyacica,DC=lan'})  
 +skipping: [adc] => (item={'name': 'TanfolyamUsers', 'path': 'DC=kutyacica,DC=lan'})  
 +skipping: [adc] 
 + 
 +PLAY RECAP ********************************************************************* 
 +adc                        : ok=4    changed=4    unreachable=0    failed=0    skipped=3    rescued=0    ignored=0    
 +</code> 
 + 
 +=== Törlés === 
 + 
 +<code> 
 +[ansible@ansible ~]$ ansible-playbook 04-ad.yaml -e ad_state=absent 
 + 
 +PLAY [Manage AD objects] ******************************************************* 
 + 
 +TASK [Create OUs] ************************************************************** 
 +skipping: [adc] => (item={'name': 'TanfolyamUsers', 'path': 'DC=kutyacica,DC=lan'})  
 +skipping: [adc] => (item={'name': 'TanfolyamGroups', 'path': 'DC=kutyacica,DC=lan'})  
 +skipping: [adc] 
 + 
 +TASK [Create groups] *********************************************************** 
 +skipping: [adc] => (item={'name': 'LinuxAdmins', 'path': 'OU=TanfolyamGroups,DC=kutyacica,DC=lan', 'scope': 'global', 'category': 'security'})  
 +skipping: [adc] 
 + 
 +TASK [Create users] ************************************************************ 
 +skipping: [adc] => (item={'username': 'jkovacs', 'firstname': 'János', 'surname': 'Kovács'})  
 +skipping: [adc] => (item={'username': 'nagy.peter', 'firstname': 'Péter', 'surname': 'Nagy'})  
 +skipping: [adc] 
 + 
 +TASK [Add users to group] ****************************************************** 
 +skipping: [adc] 
 + 
 +TASK [Delete users] ************************************************************ 
 +changed: [adc] => (item={'username': 'jkovacs', 'firstname': 'János', 'surname': 'Kovács'}) 
 +changed: [adc] => (item={'username': 'nagy.peter', 'firstname': 'Péter', 'surname': 'Nagy'}) 
 + 
 +TASK [Delete groups] *********************************************************** 
 +changed: [adc] => (item={'name': 'LinuxAdmins', 'path': 'OU=TanfolyamGroups,DC=kutyacica,DC=lan', 'scope': 'global', 'category': 'security'}) 
 + 
 +TASK [Delete OUs] ************************************************************** 
 +changed: [adc] => (item={'name': 'TanfolyamGroups', 'path': 'DC=kutyacica,DC=lan'}) 
 +changed: [adc] => (item={'name': 'TanfolyamUsers', 'path': 'DC=kutyacica,DC=lan'}) 
 + 
 +PLAY RECAP ********************************************************************* 
 +adc                        : ok=3    changed=3    unreachable=0    failed=0    skipped=4    rescued=0    ignored=0    
 +</code> 
 + 
 +===== Könyvtárak és fájlok ===== 
 + 
 +==== Könyvtár létrehozás ==== 
 + 
 +<file yaml 05-create-directory.yaml> 
 +- name: Directory management demo 
 +  hosts: windows 
 +  gather_facts: false 
 + 
 +  tasks: 
 +    - name: Create application root directory 
 +      ansible.windows.win_file: 
 +        path: C:\apps 
 +        state: directory 
 + 
 +    - name: Create application subdirectories 
 +      ansible.windows.win_file: 
 +        path: "C:\\apps\\{{ item }}" 
 +        state: directory 
 +      loop: 
 +        - conf 
 +        - logs 
 +        - data 
 +        - backup 
 +        - temp 
 +</file> 
 + 
 +<code> 
 +[ansible@ansible ~]$ ansible-playbook 05-create-directory.yaml  
 + 
 +PLAY [Directory management demo] *********************************************** 
 + 
 +TASK [Create application root directory] *************************************** 
 +changed: [adc] 
 + 
 +TASK [Create application subdirectories] *************************************** 
 +changed: [adc] => (item=conf) 
 +changed: [adc] => (item=logs) 
 +changed: [adc] => (item=data) 
 +changed: [adc] => (item=backup) 
 +changed: [adc] => (item=temp) 
 + 
 +PLAY RECAP ********************************************************************* 
 +adc                        : ok=2    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0    
 +</code> 
 + 
 +==== Könyvtár ellenőrzése ==== 
 + 
 +<file yaml 05-check-directory.yaml> 
 +- name: Verify directory existence 
 +  hosts: windows 
 +  gather_facts: false 
 + 
 +  tasks: 
 +    - name: Check application directory 
 +      ansible.windows.win_stat: 
 +        path: C:\apps 
 +      register: apps_dir 
 + 
 +    - name: Display directory status 
 +      ansible.builtin.debug: 
 +        var: apps_dir.stat.exists 
 +</file> 
 + 
 +<code> 
 +[ansible@ansible ~]$ ansible-playbook 05-check-directory.yaml  
 + 
 +PLAY [Verify directory existence] ********************************************** 
 + 
 +TASK [Check application directory] ********************************************* 
 +ok: [adc] 
 + 
 +TASK [Display directory status] ************************************************ 
 +ok: [adc] => { 
 +    "apps_dir.stat.exists": true
 } }
 +
 +PLAY RECAP *********************************************************************
 +adc                        : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +==== Könyvtár törlés ====
 +
 +A könyvtár törlése eltávolítja a könyvtár tartalmát (alkönyvtárak, fájlok).
 +
 +<file yaml 05-delete-directory.yaml>
 +- name: Remove temporary directory
 +  hosts: windows
 +  gather_facts: false
 +
 +  tasks:
 +    - name: Delete temp directory
 +      ansible.windows.win_file:
 +        path: C:\apps\temp
 +        state: absent
 </file> </file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 05-delete-directory.yaml 
 +
 +PLAY [Remove temporary directory] **********************************************
 +
 +TASK [Delete temp directory] ***************************************************
 +changed: [adc]
 +
 +PLAY RECAP *********************************************************************
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +=== Több könyvtár törlése ===
 +
 +<file yaml 05-delete-multiple-directories.yaml>
 +- name: Remove multiple directories
 +  hosts: windows
 +  gather_facts: false
 +
 +  tasks:
 +    - name: Delete selected directories
 +      ansible.windows.win_file:
 +        path: "C:\\apps\\{{ item }}"
 +        state: absent
 +      loop:
 +        - backup
 +        - temp
 +</file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 05-delete-multiple-directories.yaml
 +
 +PLAY [Remove multiple directories] *********************************************
 +
 +TASK [Delete selected directories] *********************************************
 +changed: [adc] => (item=backup)
 +changed: [adc] => (item=temp)
 +
 +PLAY RECAP *********************************************************************
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +==== Könyvtár tartalom megjelenítése ====
 +
 +<file yaml 05-list-directory-content-recursive.yaml>
 +- name: List directory contents
 +  hosts: windows
 +  gather_facts: false
 +
 +  tasks:
 +    - name: List files and directories
 +      ansible.windows.win_shell: |
 +        Get-ChildItem C:\apps
 +      register: dir_listing
 +
 +    - name: Display directory contents
 +      ansible.builtin.debug:
 +        var: dir_listing.stdout_lines
 +
 +</file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 05-list-directory-content-recursive.yaml
 +
 +PLAY [List directory contents] *************************************************
 +
 +TASK [List files and directories] **********************************************
 +changed: [adc]
 +
 +TASK [Display directory contents] **********************************************
 +ok: [adc] => {
 +    "dir_listing.stdout_lines": [
 +        "",
 +        "",
 +        "    Directory: C:\\apps",
 +        "",
 +        "",
 +        "Mode                 LastWriteTime         Length Name                                                                 ",
 +        "----                 -------------         ------ ----                                                                 ",
 +        "d-----     2026. 05. 28.     19:19                conf                                                                 ",
 +        "d-----     2026. 05. 28.     19:19                data                                                                 ",
 +        "d-----     2026. 05. 28.     19:19                logs                                                                 ",
 +        "",
 +        ""
 +    ]
 +}
 +
 +PLAY RECAP *********************************************************************
 +adc                        : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +==== Fájl létrehozás ====
 +
 +<file yaml 05-create-empty-file.yaml>
 +- name: Create empty file
 +  hosts: windows
 +  gather_facts: false
 +
 +  tasks:
 +    - name: Create log file
 +      ansible.windows.win_file:
 +        path: C:\apps\logs\app.log
 +        state: touch
 +</file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 05-create-empty-file.yaml 
 +
 +PLAY [Create empty file] *******************************************************
 +
 +TASK [Create log file] *********************************************************
 +changed: [adc]
 +
 +PLAY RECAP *********************************************************************
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +<file yaml 05-create-file-with-content.yaml>
 +- name: Create configuration file
 +  hosts: windows
 +  gather_facts: false
 +
 +  tasks:
 +    - name: Create application configuration file
 +      ansible.windows.win_copy:
 +        dest: C:\apps\conf\app.conf
 +        content: |
 +          app_name=DemoApp
 +          environment=training
 +          log_level=info
 +          data_dir=C:\apps\data
 +</file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 05-create-file-with-content.yaml
 +
 +PLAY [Create configuration file] ***********************************************
 +
 +TASK [Create application configuration file] ***********************************
 +changed: [adc]
 +
 +PLAY RECAP *********************************************************************
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +==== Fájl másolás ====
 +
 +<file yaml 05-file-copy.yaml>
 +- name: Copy file to Windows host
 +  hosts: windows
 +  gather_facts: false
 +
 +  tasks:
 +    - name: Copy README file
 +      ansible.windows.win_copy:
 +        src: files/readme.txt
 +        dest: C:\apps\readme.txt
 +</file>
 +
 +<code>
 +[ansible@ansible ~]$ mkdir files
 +
 +[ansible@ansible ~]$ echo "Fájl tartalom" > files/readme.txt
 +
 +[ansible@ansible ~]$ ansible-playbook 05-file-copy.yaml 
 +
 +PLAY [Copy file to Windows host] ***********************************************
 +
 +TASK [Copy README file] ********************************************************
 +changed: [adc]
 +
 +PLAY RECAP *********************************************************************
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +==== Fájl ellenőrzés ====
 +
 +<file yaml 05-check-file-existence.yaml>
 +- name: Verify file existence
 +  hosts: windows
 +  gather_facts: false
 +
 +  tasks:
 +    - name: Check configuration file
 +      ansible.windows.win_stat:
 +        path: C:\apps\conf\app.conf
 +      register: conf_file
 +
 +    - name: Display file status
 +      ansible.builtin.debug:
 +        var: conf_file.stat.exists
 +</file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 05-check-file-existence.yaml
 +
 +PLAY [Verify file existence] ***************************************************
 +
 +TASK [Check configuration file] ************************************************
 +ok: [adc]
 +
 +TASK [Display file status] *****************************************************
 +ok: [adc] => {
 +    "conf_file.stat.exists": true
 +}
 +
 +PLAY RECAP *********************************************************************
 +adc                        : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +==== Fájl tartalom módosítás ====
 +
 +=== Sor csere ===
 +
 +<file yaml 05-modify-file.yaml>
 +- name: Update configuration setting
 +  hosts: windows
 +  gather_facts: false
 +
 +  tasks:
 +    - name: Set log level to debug
 +      community.windows.win_lineinfile:
 +        path: C:\apps\conf\app.conf
 +        regexp: '^log_level='
 +        line: 'log_level=debug'
 +</file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 05-modify-file.yaml 
 +
 +PLAY [Update configuration setting] ********************************************
 +
 +TASK [Set log level to debug] **************************************************
 +changed: [adc]
 +
 +PLAY RECAP *********************************************************************
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +=== Új sor ===
 +
 +<file yaml 05-add-line-to-file.yaml>
 +- name: Add configuration entry
 +  hosts: windows
 +  gather_facts: false
 +
 +  tasks:
 +    - name: Add max_clients setting
 +      community.windows.win_lineinfile:
 +        path: C:\apps\conf\app.conf
 +        line: 'max_clients=100'
 +        create: true
 +</file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 05-add-line-to-file.yaml
 +
 +PLAY [Add configuration entry] *************************************************
 +
 +TASK [Add max_clients setting] *************************************************
 +changed: [adc]
 +
 +PLAY RECAP *********************************************************************
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +=== Sor törlés ===
 +
 +<file yaml 05-delete-line-from-file.yaml>
 +- name: Remove configuration entry
 +  hosts: windows
 +  gather_facts: false
 +
 +  tasks:
 +    - name: Remove environment setting
 +      community.windows.win_lineinfile:
 +        path: C:\apps\conf\app.conf
 +        regexp: '^environment='
 +        state: absent
 +</file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 05-delete-line-from-file.yaml
 +
 +PLAY [Remove configuration entry] **********************************************
 +
 +TASK [Remove environment setting] **********************************************
 +changed: [adc]
 +
 +PLAY RECAP *********************************************************************
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +=== Több sor módosítása ===
 +
 +<file yaml 05-modify-multiple-lines-in-file.yaml>
 +- name: Configure multiple settings
 +  hosts: windows
 +  gather_facts: false
 +
 +  tasks:
 +    - name: Configure application settings
 +      community.windows.win_lineinfile:
 +        path: C:\apps\conf\app.conf
 +        regexp: "^{{ item.key }}="
 +        line: "{{ item.key }}={{ item.value }}"
 +        create: true
 +      loop:
 +        - { key: "app_name", value: "DemoApp" }
 +        - { key: "log_level", value: "warning" }
 +        - { key: "max_clients", value: "200" }
 +</file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 05-modify-multiple-lines-in-file.yaml
 +
 +PLAY [Configure multiple settings] *********************************************
 +
 +TASK [Configure application settings] ******************************************
 +ok: [adc] => (item={'key': 'app_name', 'value': 'DemoApp'})
 +changed: [adc] => (item={'key': 'log_level', 'value': 'warning'})
 +changed: [adc] => (item={'key': 'max_clients', 'value': '200'})
 +
 +PLAY RECAP *********************************************************************
 +adc                        : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +==== Fájl tartalom megjelenítése ====
 +
 +<file yaml 05-read-file-content.yaml>
 +- name: Read configuration file
 +  hosts: windows
 +  gather_facts: false
 +
 +  tasks:
 +    - name: Read configuration file content
 +      ansible.windows.win_shell: Get-Content C:\apps\conf\app.conf
 +      register: conf_content
 +
 +    - name: Display configuration content
 +      ansible.builtin.debug:
 +        var: conf_content.stdout_lines
 +</file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 05-read-file-content.yaml
 +
 +PLAY [Read configuration file] *************************************************
 +
 +TASK [Read configuration file content] *****************************************
 +changed: [adc]
 +
 +TASK [Display configuration content] *******************************************
 +ok: [adc] => {
 +    "conf_content.stdout_lines": [
 +        "app_name=DemoApp",
 +        "log_level=warning",
 +        "data_dir=C:\\apps\\data",
 +        "max_clients=200"
 +    ]
 +}
 +
 +PLAY RECAP *********************************************************************
 +adc                        : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +===== Ansible vault =====
 +
 +==== Fájl műveletek ====
 +
 +=== Létrehozás ===
 +
 +<code>
 +[ansible@ansible ~]$ cat > secret.yaml <<'EOF'
 +db_user: appuser
 +db_password: SuperSecret123!
 +EOF
 +</code>
 +
 +=== Titkosítás ===
 +
 +<code>
 +[ansible@ansible ~]$ ansible-vault encrypt secret.yaml
 +New Vault password: 
 +Confirm New Vault password: 
 +Encryption successful
 +
 +[ansible@ansible ~]$ cat secret.yaml 
 +$ANSIBLE_VAULT;1.1;AES256
 +66306635613562363439353734343137346161353763636162383363616234303962616363336366
 +6633396663663462353864393231313461353532373531340a306333616563306133343332373335
 +61356334383632656432333538366262636261646233363661386638366533616537373034356263
 +3961353663633331320a383261663839376463396534313237323266306564623637613637373462
 +39646263383532356362353833393635613732653334646134613262313439313739353331333831
 +6332343031333734373935336338333638656661386636613730
 +</code>
 +
 +=== Szerkesztés ===
 +
 +<code>
 +[ansible@ansible ~]$ ansible-vault edit secret.yaml 
 +Vault password: 
 +...
 +</code>
 +
 +=== Visszafejtés ===
 +
 +<code>
 +[ansible@ansible ~]$ ansible-vault decrypt secret.yaml 
 +Vault password: 
 +Decryption successful
 +
 +[ansible@ansible ~]$ cat secret.yaml 
 +db_user: appuser
 +db_password: SuperSecret123!
 +</code>
 +
 +=== Jelszó csere ===
 +
 +<code>
 +[ansible@ansible ~]$ ansible-vault rekey secret.yaml 
 +Vault password: 
 +New Vault password: 
 +Confirm New Vault password: 
 +Rekey successful
 +</code>
 +
 +==== Interaktív használat ====
 +
 +<file yaml 06-vault-test.yaml>
 +- hosts: localhost
 +  vars_files:
 +    - secret.yaml
 +
 +  tasks:
 +    - debug:
 +        msg: "DB password: {{ db_password }}"
 +</file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 06-vault-test.yaml
 +ERROR! Attempting to decrypt but no vault secrets found
 +
 +[ansible@ansible ~]$ ansible-playbook 06-vault-test.yaml --ask-vault-pass
 +Vault password: 
 +
 +PLAY [localhost] ***************************************************************
 +
 +TASK [Gathering Facts] *********************************************************
 +ok: [localhost]
 +
 +TASK [debug] *******************************************************************
 +ok: [localhost] => {
 +    "msg": "DB password: SuperSecret123!"
 +}
 +
 +PLAY RECAP *********************************************************************
 +localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +==== Jelszófájl használat ====
 +
 +<code>
 +[ansible@ansible ~]$ cat > vault.pass <<'EOF'
 +12345
 +EOF
 +
 +[ansible@ansible ~]$ chmod 0600 vault.pass 
 +
 +[ansible@ansible ~]$ ansible-playbook 06-vault-test.yaml --vault-password-file vault.pass
 +
 +PLAY [localhost] ***************************************************************
 +
 +TASK [Gathering Facts] *********************************************************
 +ok: [localhost]
 +
 +TASK [debug] *******************************************************************
 +ok: [localhost] => {
 +    "msg": "DB password: SuperSecret123!"
 +}
 +
 +PLAY RECAP *********************************************************************
 +localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +==== Változó titkosítása ====
 +
 +<code>
 +[ansible@ansible ~]$ ansible-vault encrypt_string 'SuperSecret123!' --name 'db_password'
 +New Vault password: 
 +Confirm New Vault password: 
 +Encryption successful
 +db_password: !vault |
 +          $ANSIBLE_VAULT;1.1;AES256
 +          64663064386637346261633135653162356330353564373332613430336266313930323061646465
 +          6263373239316131626264623966343962303964343131360a623838393637643131623965663765
 +          39346333613866376437633137643838306330353632616366353966353062326366383232633264
 +          3933303831666237340a383038636464313235353166313661363139316161636464323539653138
 +          3530
 +</code>
 +
 +<file yaml 06-internal-vault-test.yaml>
 +- hosts: localhost
 +  vars:
 +    db_user: appuser
 +    db_password: !vault |
 +        $ANSIBLE_VAULT;1.1;AES256
 +        64663064386637346261633135653162356330353564373332613430336266313930323061646465
 +        6263373239316131626264623966343962303964343131360a623838393637643131623965663765
 +        39346333613866376437633137643838306330353632616366353966353062326366383232633264
 +        3933303831666237340a383038636464313235353166313661363139316161636464323539653138
 +        3530
 +
 +  tasks:
 +    - debug:
 +        msg: "DB password: {{ db_password }}"
 +</file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 06-internal-vault-test.yaml 
 +
 +PLAY [localhost] *****************************************************************************************************************************************************************************
 +
 +TASK [Gathering Facts] ***********************************************************************************************************************************************************************
 +ok: [localhost]
 +
 +TASK [debug] *********************************************************************************************************************************************************************************
 +fatal: [localhost]: FAILED! => {"msg": "Attempting to decrypt but no vault secrets found"}
 +
 +PLAY RECAP ***********************************************************************************************************************************************************************************
 +localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
 +
 +[ansible@ansible ~]$ ansible-playbook 06-internal-vault-test.yaml --vault-password-file vault.pass 
 +
 +PLAY [localhost] *****************************************************************************************************************************************************************************
 +
 +TASK [Gathering Facts] ***********************************************************************************************************************************************************************
 +ok: [localhost]
 +
 +TASK [debug] *********************************************************************************************************************************************************************************
 +ok: [localhost] => {
 +    "msg": "DB password: SuperSecret123!"
 +}
 +
 +PLAY RECAP ***********************************************************************************************************************************************************************************
 +localhost                  : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +==== Több vault használata ====
 +
 +<code>
 +[ansible@ansible ~]$ ansible-vault encrypt_string --vault-id dev@prompt 'dev123' --name dev_db_password >> vaults.yaml 
 +New vault password (dev): 
 +Confirm new vault password (dev): 
 +
 +[ansible@ansible ~]$ ansible-vault encrypt_string --vault-id prod@prompt 'prod123' --name prod_db_password >> vaults.yaml 
 +New vault password (prod): 
 +Confirm new vault password (prod): 
 +
 +[ansible@ansible ~]$ cat vaults.yaml 
 +dev_db_password: !vault |
 +          $ANSIBLE_VAULT;1.2;AES256;dev
 +          34653336386234303265623664386237393761626465626230373133643762613266636434613965
 +          3439333961393832346231353037663662336565306430310a613264636639643865376561316139
 +          65663862386134396237383936356630666664346530376235333834633033643135396236613262
 +          3566653338383735640a323937623663303539346463346338366266353866366234336631613538
 +          6565
 +prod_db_password: !vault |
 +          $ANSIBLE_VAULT;1.2;AES256;prod
 +          63623637666532326637316432396432393431333664323262363937386238303134303264353436
 +          3866336533396262626438616630373863366261366533350a663765316337343863356665363763
 +          36663835643730303734643032643466323732386561633162323332373861656235346462643130
 +          6465303633356331370a363564653465653666656366353166663039333430656163373939326538
 +          6531
 +</code>
 +
 +<file yaml 06-vault-id.yaml>
 +- hosts: localhost
 +
 +  vars:
 +    db_user: appuser
 +
 +  vars_files:
 +    - vaults.yaml
 +
 +  tasks:
 +    - debug:
 +        msg: "DEV DB password: {{ dev_db_password }}"
 +
 +    - debug:
 +        msg: "PROD DB password: {{ prod_db_password }}"
 +</file>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 06-vault-id.yaml --vault-id dev@prompt --vault-id prod@prompt
 +Vault password (dev): 
 +Vault password (prod): 
 +
 +PLAY [localhost] *****************************************************************************************************************************************************************************
 +
 +TASK [Gathering Facts] ***********************************************************************************************************************************************************************
 +ok: [localhost]
 +
 +TASK [debug] *********************************************************************************************************************************************************************************
 +ok: [localhost] => {
 +    "msg": "DEV DB password: dev123"
 +}
 +
 +TASK [debug] *********************************************************************************************************************************************************************************
 +ok: [localhost] => {
 +    "msg": "PROD DB password: prod123"
 +}
 +
 +PLAY RECAP ***********************************************************************************************************************************************************************************
 +localhost                  : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +===== Windows frissítés, ütemezett feladatok =====
 +
 +==== Windows frissítés (kritikus és biztonsági javítások) ====
 +
 +<file yaml 99-windows-update.yaml>
 +- hosts: windows
 +  tasks:
 +    - name: Install critical/security updates
 +      ansible.windows.win_updates:
 +        category_names:
 +          - CriticalUpdates
 +          - SecurityUpdates
 +        reboot: true
 +      register: upd
 +
 +    - debug:
 +        var: upd
 +</file>
 +
 +<bootnote critical>A frissítés hosszú ideig is eltarthat valamint a gép újraindulhat!</bootnote>
 +
 +<code>
 +[ansible@ansible ~]$ ansible-playbook 99-windows-update.yaml 
 +
 +PLAY [windows] *****************************************************************
 +
 +TASK [Gathering Facts] *********************************************************
 +ok: [win2022]
 +
 +TASK [Install critical/security updates] ***************************************
 +An exception occurred during task execution. To see the full traceback, use -vvv. The error was: Exception: Timed out waiting for last boot time check (timeout=1200)
 +fatal: [win2022]: FAILED! => {"changed": true, "elapsed": 1208, "failed_update_count": 0, "filtered_updates": {"af2d807f-c5a6-435b-bbba-36023ea98955": {"categories": ["Definition Updates", "Microsoft Defender Antivirus"], "downloaded": false, "filtered_reasons": ["category_names"], "id": "af2d807f-c5a6-435b-bbba-36023ea98955", "installed": false, "kb": ["2267602"], "title": "Security Intelligence Update for Microsoft Defender Antivirus - KB2267602 (Version 1.451.111.0) - Current Channel (Broad)"}, "db5bac0b-a277-4d18-9bfd-6c9b08e3251c": {"categories": ["EU Browser Choice Update-For Europe Only", "Update Rollups", "Windows Server 2016", "Windows Server 2019", "Windows Server, version 1903 and later"], "downloaded": false, "filtered_reasons": ["category_names"], "id": "db5bac0b-a277-4d18-9bfd-6c9b08e3251c", "installed": false, "kb": ["890830"], "title": "Windows Malicious Software Removal Tool x64 - v5.141 (KB890830)"}, "f79e3de9-b030-4984-a5ac-fcaa5dab7e8d": {"categories": ["Microsoft Server operating system-21H2", "Updates"], "downloaded": false, "filtered_reasons": ["category_names"], "id": "f79e3de9-b030-4984-a5ac-fcaa5dab7e8d", "installed": false, "kb": ["5010475"], "title": "2022-02 Cumulative Update Preview for .NET Framework 3.5 and 4.8 for Microsoft server operating system version 21H2 for x64 (KB5010475)"}}, "found_update_count": 2, "installed_update_count": 2, "msg": "Failed to reboot host: Timed out waiting for last boot time check (timeout=1200)", "reboot_required": true, "rebooted": true, "unreachable": false, "updates": {"0ae6f8d8-5a5a-4551-a0cc-ca97524fc415": {"categories": ["Microsoft Server operating system-21H2", "Security Updates"], "downloaded": false, "id": "0ae6f8d8-5a5a-4551-a0cc-ca97524fc415", "installed": true, "kb": ["5088862"], "title": "2026-05 Cumulative Update for .NET Framework 3.5, 4.8 and 4.8.1 for Microsoft server operating system version 21H2 for x64 (KB5088862)"}, "d684f5a6-3ade-4716-9aa1-787d79a36afe": {"categories": ["Security Updates"], "downloaded": false, "id": "d684f5a6-3ade-4716-9aa1-787d79a36afe", "installed": true, "kb": ["5087545"], "title": "2026-05 Cumulative Update for Microsoft server operating system version 21H2 for x64-based Systems (KB5087545)"}}}
 +
 +PLAY RECAP *********************************************************************
 +win2022                    : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
 +</code>
 +
 +A frissítés nyomon követhető PowerShell segítségével.
 +
 +<code>
 +PS C:\Windows\system32> Get-Service wuauserv,BITS,CryptSvc,TrustedInstaller
 +
 +Status   Name               DisplayName
 +------   ----               -----------
 +Stopped  BITS               Background Intelligent Transfer Ser...
 +Running  CryptSvc           Cryptographic Services
 +Running  TrustedInstaller   Windows Modules Installer
 +Running  wuauserv           Windows Update
 +
 +
 +PS C:\Windows\system32> Get-Service UsoSvc
 +
 +Status   Name               DisplayName
 +------   ----               -----------
 +Running  UsoSvc             Update Orchestrator Service
 +
 +
 +PS C:\Windows\system32> Get-Content C:\Windows\Logs\CBS\CBS.log -Tail 20 -wait
 +2026-05-26 01:55:11, Info                  DPX    hr: 0x8000000a at onecore\base\compress\dpx\src\dpxjob.cpp(2433)
 +2026-05-26 01:55:11, Info                  DPX    Started DPX phase: Apply Deltas Provided In File
 +2026-05-26 01:55:13, Info                  DPX    hr: 0x80070012 at onecore\base\compress\dpx\src\ipdcab.cpp(1338)
 +2026-05-26 01:55:13, Info                  DPX    hr: 0x80070012 at onecore\base\compress\dpx\src\bufcab.cpp(330)
 +2026-05-26 01:55:13, Info                  DPX    CCabStorage::GetErrorCode(): m_hrFirstError = 0x80070012
 +2026-05-26 01:55:13, Info                  DPX    hr: 0x80070012 at onecore\base\compress\dpx\src\storage.cpp(466)
 +2026-05-26 01:55:13, Info                  DPX    hr: 0x80070012 at onecore\base\compress\dpx\src\storage.cpp(58)
 +2026-05-26 01:55:13, Info                  DPX    hr: 0x80070012 at onecore\base\compress\dpx\src\storage.cpp(565)
 +2026-05-26 01:55:13, Info                  DPX    hr: 0x80070012 at onecore\base\compress\dpx\src\bufcab.cpp(21)
 +2026-05-26 01:55:13, Info                  DPX    hr: 0x80070012 at onecore\base\compress\dpx\src\bufcab.cpp(108)
 +2026-05-26 01:55:13, Info                  DPX    Ended DPX phase: Apply Deltas Provided In File
 +2026-05-26 01:55:13, Info                  DPX    CJob::Resume completed with status: 0x0
 +2026-05-26 01:55:13, Info                  DPX    Ended DPX phase: Resume and Download Job
 +2026-05-26 01:55:13, Info                  CBS    Extracting all files from cabinet \\?\C:\Windows\CbsTemp\31255788_4177394721\Windows10.0-KB5087545-x64.cab\Cab_1_for_KB5087545.cab
 +2026-05-26 01:55:13, Info                  DPX    Started DPX phase: Resume and Download Job
 +2026-05-26 01:55:13, Info                  DPX    hr: 0x8000000a at onecore\base\compress\dpx\src\dpxjob.cpp(2433)
 +2026-05-26 01:55:13, Info                  DPX    Started DPX phase: Apply Deltas Provided In File
 +2026-05-26 01:55:13, Info                  DPX    Ended DPX phase: Apply Deltas Provided In File
 +2026-05-26 01:55:13, Info                  DPX    hr: 0x8000000a at onecore\base\compress\dpx\src\dpxjob.cpp(2433)
 +2026-05-26 01:55:13, Info                  DPX    Started DPX phase: Apply Deltas Provided In File
 +2026-05-26 02:06:38, Info                  DPX    Ended DPX phase: Apply Deltas Provided In File
 +2026-05-26 02:06:38, Info                  DPX    CJob::Resume completed with status: 0x0
 +2026-05-26 02:06:38, Info                  DPX    Ended DPX phase: Resume and Download Job
 +2026-05-26 02:06:38, Info                  CBS    Extracting all files from cabinet \\?\C:\Windows\CbsTemp\31255788_4177394721\Windows10.0-KB5087545-x64.cab\Cab_2_for_KB5087545.cab
 +2026-05-26 02:06:38, Info                  DPX    Started DPX phase: Resume and Download Job
 +2026-05-26 02:06:38, Info                  DPX    hr: 0x8000000a at onecore\base\compress\dpx\src\dpxjob.cpp(2433)
 +2026-05-26 02:06:38, Info                  DPX    Started DPX phase: Apply Deltas Provided In File
 +2026-05-26 02:06:38, Info                  DPX    Ended DPX phase: Apply Deltas Provided In File
 +2026-05-26 02:06:38, Info                  DPX    hr: 0x8000000a at onecore\base\compress\dpx\src\dpxjob.cpp(2433)
 +2026-05-26 02:06:38, Info                  DPX    Started DPX phase: Apply Deltas Provided In File
 +</code>
  
ansible/windows.1779784800.txt.gz · legutóbbi módosítás: – Szerkesztő: riba.zoltan