Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improper string handling (evaluation) in community.windows.win_timezone #545

Open
europ opened this issue Dec 18, 2023 · 0 comments
Open

Comments

@europ
Copy link

europ commented Dec 18, 2023

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
  1. add Windows host to inventory (e.g. Windows Server 2022)
  2. set ansible_shell_type=powershell for the host
  3. create a task in playbook that uses win_timezone with extra variable
    - name: configure timezone
      community.windows.win_timezone:
        timezone: '{{ timezone }}'
  4. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant