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

win_toast module fails to deliver notification if async is used. #596

Open
egzakharovich opened this issue Dec 5, 2024 · 1 comment
Open

Comments

@egzakharovich
Copy link

egzakharovich commented Dec 5, 2024

SUMMARY

The module exists with error Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) while async and poll used.

While using synchronous execution, there's no problem. But you HAVE to wait until expire run's out.

P.S. #494 is probably the same, but the author decided not to include information required for filing an issue and stopped to answer on information requests. So I filed a new one. Let me know if this was inappropriate.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

win_toast

ANSIBLE VERSION
ansible [core 2.17.6]
  config file = /home/user/git/ansible-pg/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/git/ansible-pg/.venv/lib64/python3/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/git/ansible-pg/.venv/bin/ansible
  python version = 3.12.2 (main, Feb 29 2024, 18:26:55) [GCC 13.2.1 20240128 (ALT Sisyphus 13.2.1-alt3)] (/home/user/git/ansible-pg/.venv/bin/python3)
  jinja version = 3.1.4
  libyaml = True
COLLECTION VERSION

Having community.general in comment example is somewhat confusing.

(.venv) $ ansible-galaxy collection list community.windows

# /home/user/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.windows 2.3.0  

# /home/user/git/ansible-pg/.venv/lib/python3/site-packages/ansible_collections
Collection        Version
----------------- -------
community.windows 2.3.0  

# /home/user/git/ansible-pg/.venv/lib64/python3/site-packages/ansible_collections
Collection        Version
----------------- -------
community.windows 2.3.0
CONFIGURATION
CONFIG_FILE() = /home/user/git/ansible-pg/ansible.cfg
DEFAULT_FORKS(/home/user/git/ansible-pg/ansible.cfg) = 50
DEFAULT_HOST_LIST(/home/user/git/ansible-pg/ansible.cfg) = ['/home/user/git/ansible-pg/inventory']
DEFAULT_STDOUT_CALLBACK(/home/user/git/ansible-pg/ansible.cfg) = yaml
DEFAULT_VAULT_PASSWORD_FILE(/home/user/git/ansible-pg/ansible.cfg) = /home/user/git/ansible-pg/.secret
EDITOR(env: EDITOR) = mcedit
OS / ENVIRONMENT
architecture: 64-bit
architecture2: x86_64
distribution: Microsoft Windows 10 Pro
distribution_major_version: '10'
distribution_version: 10.0.19045.0
os_family: Windows
os_installation_type: Client
os_name: Microsoft Windows 10 Pro
os_product_type: workstation
windows_domain: WORKGROUP
windows_domain_member: false
windows_domain_role: Stand-alone workstation
STEPS TO REPRODUCE
---
- name: Install Thin Client
  hosts: SomeMachine
  serial: '100%'
  gather_facts: false

  vars:
    version: '8.3.24.1764'

  tasks:
    - name: Notify user fails
      ignore_errors: true
      community.windows.win_toast:
        expire: 30
        title: The installation of Thin client version {{ version }} is complete
        msg: Thin client installation
      async: 60
      poll: 5

    - name: Notify user works, but need to wait until expire runs out
      community.windows.win_toast:
        expire: 30
        title: The installation of Thin client version {{ version }} is complete
        msg: Thin client installation

Only second one works. I found out, that title and msg does not work as intended, because they're swapped. But this is for another issue

Result (from second task):

image

EXPECTED RESULTS

A toast notification is shown to the user, while using async execution or fire and forget scenario

ACTUAL RESULTS

Error.

$ ansible-playbook -v playbooks/toast_test.yaml
Using /home/user/git/ansible-pg/ansible.cfg as config file

PLAY [Install Thin Client] ********************************************************************************************************************************************

TASK [Notify user fails] **********************************************************************************************************************************************
ASYNC FAILED on SomeMachine: jid=j558608974231.11724
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: at <ScriptBlock>, <No file>: line 71
fatal: [SomeMachine]: FAILED! => changed=false 
  ansible_async_watchdog_pid: 13760
  ansible_job_id: j558608974231.11724
  expire_at: 05.12.2024 19:36:25
  expire_at_utc: 5 декабря 2024 г. 16:36:25
  finished: 1
  msg: 'Failed to create toast notifier: Exception calling "Show" with "1" argument(s): "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"'
  results_file: C:\Users\Администратор\.ansible_async\j558608974231.11724
  started: 1
  stderr: ''
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>
  toast_sent: false
...ignoring

TASK [Notify user works, but need to wait until expire runs out] ******************************************************************************************************
ok: [SomeMachine] => changed=false 
  expire_at: 12/5/2024 7:36:31 PM
  expire_at_utc: Thursday, December 5, 2024 4:36:31 PM
  sent_localtime: Thursday, December 5, 2024 7:36:31 PM
  time_taken: 30.4626792
  toast_sent: true

PLAY RECAP ************************************************************************************************************************************************************
SomeMachine                : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=1   

@egzakharovich
Copy link
Author

egzakharovich commented Dec 5, 2024

I found out only now that expire=0 and synchronous execution can be used as a workaround if the actual "expiration time" is not needed. It will fire the toast and return. Documentation is not clear about 0 being possible and valid option.

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