You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When getting a "connection refused error", the module simply tells the user to refer to the stack trace when the error could just be presented in the message itself.
---
- name: Test Playbookhosts: localhostgather_facts: falsetasks:
- name: Send Emailcommunity.general.mail:
host: 10.1.1.1port: "25"ehlohost: "localhost"sender: test@example.comto: [user1@example.com, user2@example.com]cc: [cc1@example.com]bcc: [bcc1@example.com]subject: Test Emailbody: This is a test emailcharset: utf-8secure: "never"username: test_userpassword: test_passwordtimeout: "10"register: result
- name: Print Resultdebug:
var: result
Expected Results
a message that conveys "connection refused"
Actual Results
0.yamlansible-playbook [core 2.14.5] config file = None configured module search path = ['/home/john/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /data/john/projects/cf/env/lib/python3.10/site-packages/ansible ansible collection location = /home/john/.ansible/collections:/usr/share/ansible/collections executable location = /data/john/projects/cf/env/bin/ansible-playbook python version = 3.10.11 (main, Apr 20 2023, 19:02:41) [GCC 11.2.0] (/data/john/projects/cf/env/bin/python) jinja version = 3.1.2 libyaml = TrueNo config file found; using defaultshost_list declined parsing /data/john/projects/cf/files/ansible/hosts.ini as it did not pass its verify_file() methodscript declined parsing /data/john/projects/cf/files/ansible/hosts.ini as it did not pass its verify_file() methodauto declined parsing /data/john/projects/cf/files/ansible/hosts.ini as it did not pass its verify_file() methodyaml declined parsing /data/john/projects/cf/files/ansible/hosts.ini as it did not pass its verify_file() methodParsed /data/john/projects/cf/files/ansible/hosts.ini inventory source with ini pluginSkipping callback 'default', as we already have a stdout callback.Skipping callback 'minimal', as we already have a stdout callback.Skipping callback 'oneline', as we already have a stdout callback.PLAYBOOK: 0.yaml ***************************************************************1 plays in /data/john/projects/cf/data/module_yaml/20230720-184644/lv2/community.general.mail/0.yamlPLAY [Test Playbook] ***********************************************************TASK [Send Email] **************************************************************task path: /data/john/projects/cf/data/module_yaml/20230720-184644/lv2/community.general.mail/0.yaml:7<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: john<127.0.0.1> EXEC /bin/sh -c 'echo ~john && sleep 0'<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/john/.ansible/tmp `"&& mkdir "` echo /home/john/.ansible/tmp/ansible-tmp-1689910662.8156006-77083-94511940485503 `" && echo ansible-tmp-1689910662.8156006-77083-94511940485503="` echo /home/john/.ansible/tmp/ansible-tmp-1689910662.8156006-77083-94511940485503 `" ) && sleep 0'Using module file /home/john/.ansible/collections/ansible_collections/community/general/plugins/modules/mail.py<127.0.0.1> PUT /home/john/.ansible/tmp/ansible-local-77079qydco7oo/tmpes1t2x15 TO /home/john/.ansible/tmp/ansible-tmp-1689910662.8156006-77083-94511940485503/AnsiballZ_mail.py<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/john/.ansible/tmp/ansible-tmp-1689910662.8156006-77083-94511940485503/ /home/john/.ansible/tmp/ansible-tmp-1689910662.8156006-77083-94511940485503/AnsiballZ_mail.py && sleep 0'<127.0.0.1> EXEC /bin/sh -c '/data/john/projects/cf/env/bin/python /home/john/.ansible/tmp/ansible-tmp-1689910662.8156006-77083-94511940485503/AnsiballZ_mail.py && sleep 0'<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/john/.ansible/tmp/ansible-tmp-1689910662.8156006-77083-94511940485503/ > /dev/null 2>&1 && sleep 0'The full traceback is:Traceback (most recent call last): File "/home/john/.ansible/tmp/ansible-tmp-1689910662.8156006-77083-94511940485503/AnsiballZ_mail.py", line 107, in <module> _ansiballz_main() File "/home/john/.ansible/tmp/ansible-tmp-1689910662.8156006-77083-94511940485503/AnsiballZ_mail.py", line 99, in _ansiballz_main invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS) File "/home/john/.ansible/tmp/ansible-tmp-1689910662.8156006-77083-94511940485503/AnsiballZ_mail.py", line 47, in invoke_module runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.mail', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.mail', _modlib_path=modlib_path), File "/home/john/miniconda3/envs/3.10/lib/python3.10/runpy.py", line 224, in run_module return _run_module_code(code, init_globals, run_name, mod_spec) File "/home/john/miniconda3/envs/3.10/lib/python3.10/runpy.py", line 96, in _run_module_code _run_code(code, mod_globals, init_globals, File "/home/john/miniconda3/envs/3.10/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/tmp/ansible_community.general.mail_payload_nbo2jt2q/ansible_community.general.mail_payload.zip/ansible_collections/community/general/plugins/modules/mail.py", line 418, in <module> File "/tmp/ansible_community.general.mail_payload_nbo2jt2q/ansible_community.general.mail_payload.zip/ansible_collections/community/general/plugins/modules/mail.py", line 303, in main File "/home/john/miniconda3/envs/3.10/lib/python3.10/smtplib.py", line 255, in __init__ (code, msg) = self.connect(host, port) File "/home/john/miniconda3/envs/3.10/lib/python3.10/smtplib.py", line 341, in connect self.sock = self._get_socket(host, port, self.timeout) File "/home/john/miniconda3/envs/3.10/lib/python3.10/smtplib.py", line 312, in _get_socket return socket.create_connection((host, port), timeout, File "/home/john/miniconda3/envs/3.10/lib/python3.10/socket.py", line 845, in create_connection raise err File "/home/john/miniconda3/envs/3.10/lib/python3.10/socket.py", line 833, in create_connection sock.connect(sa)ConnectionRefusedError: [Errno 111] Connection refusedfatal: [localhost]: FAILED! => { "changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/home/john/.ansible/tmp/ansible-tmp-1689910662.8156006-77083-94511940485503/AnsiballZ_mail.py\", line 107, in <module>\n _ansiballz_main()\n File \"/home/john/.ansible/tmp/ansible-tmp-1689910662.8156006-77083-94511940485503/AnsiballZ_mail.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/home/john/.ansible/tmp/ansible-tmp-1689910662.8156006-77083-94511940485503/AnsiballZ_mail.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.mail', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.mail', _modlib_path=modlib_path),\n File \"/home/john/miniconda3/envs/3.10/lib/python3.10/runpy.py\", line 224, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/home/john/miniconda3/envs/3.10/lib/python3.10/runpy.py\", line 96, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/home/john/miniconda3/envs/3.10/lib/python3.10/runpy.py\", line 86, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_community.general.mail_payload_nbo2jt2q/ansible_community.general.mail_payload.zip/ansible_collections/community/general/plugins/modules/mail.py\", line 418, in <module>\n File \"/tmp/ansible_community.general.mail_payload_nbo2jt2q/ansible_community.general.mail_payload.zip/ansible_collections/community/general/plugins/modules/mail.py\", line 303, in main\n File \"/home/john/miniconda3/envs/3.10/lib/python3.10/smtplib.py\", line 255, in __init__\n (code, msg) = self.connect(host, port)\n File \"/home/john/miniconda3/envs/3.10/lib/python3.10/smtplib.py\", line 341, in connect\n self.sock = self._get_socket(host, port, self.timeout)\n File \"/home/john/miniconda3/envs/3.10/lib/python3.10/smtplib.py\", line 312, in _get_socket\n return socket.create_connection((host, port), timeout,\n File \"/home/john/miniconda3/envs/3.10/lib/python3.10/socket.py\", line 845, in create_connection\n raise err\n File \"/home/john/miniconda3/envs/3.10/lib/python3.10/socket.py\", line 833, in create_connection\n sock.connect(sa)\nConnectionRefusedError: [Errno 111] Connection refused\n",
"module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}PLAY RECAP *********************************************************************localhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
Code of Conduct
I agree to follow the Ansible Code of Conduct
The text was updated successfully, but these errors were encountered:
Summary
When getting a "connection refused error", the module simply tells the user to refer to the stack trace when the error could just be presented in the message itself.
Issue Type
Bug Report
Component Name
mail
Ansible Version
Community.general Version
Configuration
OS / Environment
Ubuntu
Steps to Reproduce
Expected Results
a message that conveys "connection refused"
Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: