ansible-collections / community.windows

Windows community collection for Ansible
https://galaxy.ansible.com/community/windows
GNU General Public License v3.0
198 stars 153 forks source link

win_region: copy_settings is not doing it's job #493

Open andresgiuffre opened 1 year ago

andresgiuffre commented 1 year ago
SUMMARY

win_region is applying all settings i've defined (es-ES), including copy_settings, but changes are only applied to the current session. After restarting, all sessions opened with different users are keeping the original english settings, except for the one that was opened during playbook execution. That one is working fine in Spanish.

ISSUE TYPE
COMPONENT NAME

win_region

ANSIBLE VERSION
ansible 2.9.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/xxxx1/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/xxxx1/xxxx2/xxxx3/venvansible2.9_win/lib64/python3.6/site-packages/ansible
  executable location = /home/xxxx1/xxxx2/xxxx3/venvansible2.9_win/bin/ansible
  python version = 3.6.8 (default, Aug 13 2020, 07:46:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
COLLECTION VERSION
Not present in my current version (2.9.0)
CONFIGURATION
DEFAULT_CALLBACK_WHITELIST(/etc/ansible/ansible.cfg) = ['profile_tasks']
DEFAULT_LOG_PATH(/etc/ansible/ansible.cfg) = /var/log/ansible.log
OS / ENVIRONMENT

Windows Server 2019

STEPS TO REPRODUCE
---
- block:
  - name: Install Spanish Language Pack
    win_command: >-
        "C:\Windows\System32\lpksetup.exe" /i es-ES /s /r /p \\<server>\<cab_location>\
    ignore_errors: true
    become: yes
    become_method: runas    

- name: Set Spanish as Default Language
  win_region:
        format: es-ES
        location: 217
        unicode_language: es-ES
        copy_settings: true
  register: result 

 - name: Reboot if required
   win_reboot:
   when: result.restart_required   

- name: Define Keyboard Layout
  win_shell: |
        $actualList = Get-WinUserLanguageList
        $actualList.Add('es-ES')
        Set-WinUserLanguageList -LanguageList es-ES, en-US -Force
EXPECTED RESULTS

I'm expecting that every user logging on that machine, being a new one or not, gets all the Spanish regional settings configuration as default.

ACTUAL RESULTS

Only the current account is being affected. I'm seing that if I go to Language Settings - Administrative Language Settings - Copy Settings, there are 2 checkboxes saying "Copy your current settings to:" - "Welcome Screen and System Account" and "New user accounts". It's my understanding that the "copy_settings" provided in the win_region module should check those 2 boxes, but that's not happening.

no errors
maheimstaden commented 1 year ago

Hello,

Have issues with the newer version of Ansible - when using "copy_settings: true" it does fail, getting error.

ANSIBLE VERSION

7.5.0

OS / ENVIRONMENT

Windows 10

STEPS TO REPRODUCE

- name: Change region to German
  community.windows.win_region:
    location: 94
    format: de-DE
    unicode_language: de-DE
    copy_settings: yes
  register: region_change
  become: true
  become_method: runas
  become_user: "{{ansible_user}}"

ACTUAL RESULTS

An exception occurred during task execution. To see the full traceback, use -vvv. The error was:    at Microsoft.PowerShell.Commands.NewObjectCommand.CallConstructor(Type type, ConstructorInfo[] constructors, Object[] args)
 fatal: [default]: FAILED! => {"changed": false, "msg": "Unhandled exception while executing module: Exception calling \".ctor\" with \"2\" argument(s): \"Failed to load registry hive at C:\\Users\\Default\\NTUSER.DAT (A required privilege is not held by the client, Win32ErrorCode 1314)\""}

CONFIGURATION

pip packages:


2023-05-18T09:06:27.2054701Z Requirement already satisfied: pywinrm>=0.4.3 in /usr/local/lib/python3.9/dist-packages (0.4.3)
2023-05-18T09:06:27.2063285Z Requirement already satisfied: ansible==7.5.0 in /usr/local/lib/python3.9/dist-packages (7.5.0)
2023-05-18T09:06:27.2073475Z Requirement already satisfied: ansible-lint==6.16.0 in /usr/local/lib/python3.9/dist-packages (6.16.0)
2023-05-18T09:06:27.2096071Z Requirement already satisfied: ansible-core~=2.14.5 in /usr/local/lib/python3.9/dist-packages (from ansible==7.5.0) (2.14.5)
2023-05-18T09:06:27.2561095Z Requirement already satisfied: black>=22.8.0 in /usr/local/lib/python3.9/dist-packages (from ansible-lint==6.16.0) (23.3.0)
2023-05-18T09:06:27.2568994Z Requirement already satisfied: filelock>=3.3.0 in /usr/local/lib/python3.9/dist-packages (from ansible-lint==6.16.0) (3.12.0)
2023-05-18T09:06:27.2577020Z Requirement already satisfied: jsonschema>=4.10.0 in /usr/local/lib/python3.9/dist-packages (from ansible-lint==6.16.0) (4.17.3)
2023-05-18T09:06:27.2587056Z Requirement already satisfied: packaging>=21.3 in /usr/local/lib/python3.9/dist-packages (from ansible-lint==6.16.0) (23.1)
2023-05-18T09:06:27.2594886Z Requirement already satisfied: pyyaml>=5.4.1 in /usr/local/lib/python3.9/dist-packages (from ansible-lint==6.16.0) (5.4.1)
2023-05-18T09:06:27.2602951Z Requirement already satisfied: rich>=12.0.0 in /usr/local/lib/python3.9/dist-packages (from ansible-lint==6.16.0) (13.3.5)
2023-05-18T09:06:27.2611378Z Requirement already satisfied: ruamel.yaml<0.18,>=0.17.24 in /usr/local/lib/python3.9/dist-packages (from ansible-lint==6.16.0) (0.17.26)
2023-05-18T09:06:27.2620819Z Requirement already satisfied: subprocess-tee>=0.4.1 in /usr/local/lib/python3.9/dist-packages (from ansible-lint==6.16.0) (0.4.1)
2023-05-18T09:06:27.2628378Z Requirement already satisfied: yamllint>=1.30.0 in /usr/local/lib/python3.9/dist-packages (from ansible-lint==6.16.0) (1.31.0)
2023-05-18T09:06:27.2636143Z Requirement already satisfied: wcmatch>=8.1.2 in /usr/local/lib/python3.9/dist-packages (from ansible-lint==6.16.0) (8.4.1)
2023-05-18T09:06:27.2715436Z Requirement already satisfied: xmltodict in /usr/local/lib/python3.9/dist-packages (from pywinrm>=0.4.3) (0.13.0)
2023-05-18T09:06:27.2730142Z Requirement already satisfied: requests>=2.9.1 in /usr/local/lib/python3.9/dist-packages (from pywinrm>=0.4.3) (2.30.0)
2023-05-18T09:06:27.2738304Z Requirement already satisfied: requests-ntlm>=1.1.0 in /usr/local/lib/python3.9/dist-packages (from pywinrm>=0.4.3) (1.2.0)
2023-05-18T09:06:27.2745635Z Requirement already satisfied: six in /usr/local/lib/python3.9/dist-packages (from pywinrm>=0.4.3) (1.16.0)
2023-05-18T09:06:27.2796645Z Requirement already satisfied: jinja2>=3.0.0 in /usr/local/lib/python3.9/dist-packages (from ansible-core~=2.14.5->ansible==7.5.0) (3.1.2)
2023-05-18T09:06:27.2803141Z Requirement already satisfied: cryptography in /usr/local/lib/python3.9/dist-packages (from ansible-core~=2.14.5->ansible==7.5.0) (40.0.2)
2023-05-18T09:06:27.2812547Z Requirement already satisfied: resolvelib<0.9.0,>=0.5.3 in /usr/local/lib/python3.9/dist-packages (from ansible-core~=2.14.5->ansible==7.5.0) (0.8.1)
2023-05-18T09:06:27.2971680Z Requirement already satisfied: click>=8.0.0 in /usr/local/lib/python3.9/dist-packages (from black>=22.8.0->ansible-lint==6.16.0) (8.1.3)
2023-05-18T09:06:27.2979770Z Requirement already satisfied: mypy-extensions>=0.4.3 in /usr/local/lib/python3.9/dist-packages (from black>=22.8.0->ansible-lint==6.16.0) (1.0.0)
2023-05-18T09:06:27.2989119Z Requirement already satisfied: pathspec>=0.9.0 in /usr/local/lib/python3.9/dist-packages (from black>=22.8.0->ansible-lint==6.16.0) (0.11.1)
2023-05-18T09:06:27.2997117Z Requirement already satisfied: platformdirs>=2 in /usr/local/lib/python3.9/dist-packages (from black>=22.8.0->ansible-lint==6.16.0) (3.5.1)
2023-05-18T09:06:27.3012294Z Requirement already satisfied: tomli>=1.1.0 in /usr/local/lib/python3.9/dist-packages (from black>=22.8.0->ansible-lint==6.16.0) (2.0.1)
2023-05-18T09:06:27.3026081Z Requirement already satisfied: typing-extensions>=3.10.0.0 in /usr/local/lib/python3.9/dist-packages (from black>=22.8.0->ansible-lint==6.16.0) (4.5.0)
2023-05-18T09:06:27.3324093Z Requirement already satisfied: attrs>=17.4.0 in /usr/local/lib/python3.9/dist-packages (from jsonschema>=4.10.0->ansible-lint==6.16.0) (23.1.0)
2023-05-18T09:06:27.3333032Z Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in /usr/local/lib/python3.9/dist-packages (from jsonschema>=4.10.0->ansible-lint==6.16.0) (0.19.3)
2023-05-18T09:06:27.3441728Z Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.9/dist-packages (from requests>=2.9.1->pywinrm>=0.4.3) (3.1.0)
2023-05-18T09:06:27.3450745Z Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.9/dist-packages (from requests>=2.9.1->pywinrm>=0.4.3) (3.4)
2023-05-18T09:06:27.3459535Z Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.9/dist-packages (from requests>=2.9.1->pywinrm>=0.4.3) (1.26.15)
2023-05-18T09:06:27.3467681Z Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.9/dist-packages (from requests>=2.9.1->pywinrm>=0.4.3) (2023.5.7)
2023-05-18T09:06:27.3515846Z Requirement already satisfied: pyspnego>=0.1.6 in /usr/local/lib/python3.9/dist-packages (from requests-ntlm>=1.1.0->pywinrm>=0.4.3) (0.9.0)
2023-05-18T09:06:27.3588301Z Requirement already satisfied: markdown-it-py<3.0.0,>=2.2.0 in /usr/local/lib/python3.9/dist-packages (from rich>=12.0.0->ansible-lint==6.16.0) (2.2.0)
2023-05-18T09:06:27.3598514Z Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.9/dist-packages (from rich>=12.0.0->ansible-lint==6.16.0) (2.15.1)
2023-05-18T09:06:27.3678737Z Requirement already satisfied: ruamel.yaml.clib>=0.2.7 in /usr/local/lib/python3.9/dist-packages (from ruamel.yaml<0.18,>=0.17.24->ansible-lint==6.16.0) (0.2.7)
2023-05-18T09:06:27.3789876Z Requirement already satisfied: bracex>=2.1.1 in /usr/local/lib/python3.9/dist-packages (from wcmatch>=8.1.2->ansible-lint==6.16.0) (2.3.post1)
2023-05-18T09:06:27.4411546Z Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.9/dist-packages (from cryptography->ansible-core~=2.14.5->ansible==7.5.0) (1.15.1)
2023-05-18T09:06:27.4501283Z Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.9/dist-packages (from jinja2>=3.0.0->ansible-core~=2.14.5->ansible==7.5.0) (2.1.2)
2023-05-18T09:06:27.4736174Z Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.9/dist-packages (from markdown-it-py<3.0.0,>=2.2.0->rich>=12.0.0->ansible-lint==6.16.0) (0.1.2)
2023-05-18T09:06:27.5545378Z Requirement already satisfied: pycparser in /usr/local/lib/python3.9/dist-packages (from cffi>=1.12->cryptography->ansible-core~=2.14.5->ansible==7.5.0) (2.21)
2023-05-18T09:06:32.7037670Z Starting galaxy collection install process
2023-05-18T09:06:32.7038764Z Process install dependency map
2023-05-18T09:06:32.7039390Z Starting collection install process
2023-05-18T09:06:32.7040700Z Downloading https://galaxy.ansible.com/download/community-windows-1.13.0.tar.gz to /home/agent/.ansible/tmp/ansible-local-625vdu35acd/tmp4q18_859/community-windows-1.13.0-463pk4p7
2023-05-18T09:06:32.7043746Z Installing 'community.windows:1.13.0' to '/home/agent/.ansible/collections/ansible_collections/community/windows'
2023-05-18T09:06:32.7048365Z community.windows:1.13.0 was installed successfully
2023-05-18T09:06:32.7049462Z Downloading https://galaxy.ansible.com/download/ansible-windows-1.14.0.tar.gz to /home/agent/.ansible/tmp/ansible-local-625vdu35acd/tmp4q18_859/ansible-windows-1.14.0-7g85vzvs
2023-05-18T09:06:32.7059356Z Installing 'ansible.windows:1.14.0' to '/home/agent/.ansible/collections/ansible_collections/ansible/windows'
2023-05-18T09:06:32.7069987Z ansible.windows:1.14.0 was installed successfully

EXPECTED RESULTS

Regional settings are setup as specified for each new user.

It is working with the following combination: ansible 2.10.7 and ansible.windows:1.11.1 - no issues.

maheimstaden commented 1 year ago

anyone?