community.windows
community.windows copied to clipboard
improper string handling (evaluation) in community.windows.win_timezone
SUMMARY
Improper string handling (evaluation) in community.windows.win_timezone.
A string that includes white spaces is split apart and the extracted first field (field separator is white space) only is used.
ISSUE TYPE
- Bug Report
COMPONENT NAME
- community.windows.win_timezone
ANSIBLE VERSION
$ ansible --version
ansible [core 2.16.1]
config file = /mnt/ansible/ansible.cfg
configured module search path = ['/home/****/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.11/site-packages/ansible
ansible collection location = /home/****/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.11.5 (main, Nov 15 2023, 18:13:17) [GCC 8.5.0 20210514 (Red Hat 8.5.0-20.0.1)] (/usr/bin/python3.11)
jinja version = 3.1.2
libyaml = True
COLLECTION VERSION
$ ansible-galaxy collection list
# /home/***/.ansible/collections/ansible_collections
Collection Version
-------------------- -------
community.windows 2.1.0
CONFIGURATION
$ ansible-config dump --only-changed
CONFIG_FILE() = /mnt/ansible/ansible.cfg
DEFAULT_ROLES_PATH(/mnt/ansible/ansible.cfg) = ['/mnt/ansible/roles']
INVENTORY_IGNORE_EXTS(/mnt/ansible/ansible.cfg) = ["{{(REJECT_EXTS + ('.orig'", '.cfg', "'.retry'))}}"]
OS / ENVIRONMENT
- Arch: amd64
- Type: Linux
- OS: OracleLinux8
STEPS TO REPRODUCE
- add Windows host to inventory (e.g. Windows Server 2022)
- set ansible_shell_type=powershell for the host
- create a task in playbook that uses win_timezone with extra variable
- name: configure timezone community.windows.win_timezone: timezone: '{{ timezone }}'
- run playbook
ansible-playbook -i ./inventory ./playbook.yml -e timezone='Pacific Standard Time' -vvv
EXPECTED RESULTS
changed: [1.1.1.1] => {
"changed": true,
"previous_timezone": "UTC",
"timezone": "Pacific Standard Time"
}
ACTUAL RESULTS
fatal: [1.1.1.1]: FAILED! => {
"changed": false,
"msg": "The specified timezone: Pacific isn't supported on the machine.",
"previous_timezone": "UTC",
"timezone": "Pacific"
}
WORKAROUND
Using single quotation marks within double quotation marks solves the problem.
ansible-playbook -i ./inventory ./playbook.yml -e timezone="'Pacific Standard Time'" -vvv