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

Add helper function to return helpful import error msg #47409

Merged
merged 1 commit into from Oct 23, 2018

Conversation

jborean93
Copy link
Contributor

SUMMARY

Return a prettier error msg to use when failing to import a required Python library. This will include the Python that is involved and the hostname to clear up any ambiguities when failing to import a Python library.

Supersedes #41793
Supersedes #38379

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

basic.py

ANSIBLE VERSION
devel
ADDITIONAL INFORMATION

An example output with this change is now

# with no v's
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'pypsexec'
fatal: [2016 -> localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (pypsexec) on jborean-osx's Python /Users/jborean/venvs/ansible-py37/bin/python. Please read module documentation and install in the appropriate location."}

# with 3+ v's
The full traceback is:
Traceback (most recent call last):
  File "/var/folders/83/v33q_n515ps10nvlrpmd4x000000gn/T/ansible_psexec_payload_79ha7qpc/__main__.py", line 332, in <module>
    from pypsexec import client
ModuleNotFoundError: No module named 'pypsexec'

fatal: [2016 -> localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "arguments": "Write-Output abc",
            "asynchronous": false,
            "connection_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "connection_timeout": 60,
            "connection_username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "encrypt": true,
            "executable": "powershell.exe",
            "hostname": "server2016.domain.local",
            "integrity_level": "default",
            "interactive": false,
            "interactive_session": 0,
            "load_profile": true,
            "port": 445,
            "priority": "normal",
            "process_password": null,
            "process_timeout": 0,
            "process_username": null,
            "show_ui_on_logon_screen": false,
            "stdin": null,
            "working_directory": "C:\\Windows\\System32"
        }
    },
    "msg": "Failed to import the required Python library (pypsexec) on jborean-osx's Python /Users/jborean/venvs/ansible-py37/bin/python. Please read module documentation and install in the appropriate location."                                                                     
}

@ansibot
Copy link
Contributor

ansibot commented Oct 22, 2018

Hi @jborean93, thank you for submitting this pull-request!

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Oct 22, 2018

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 docs This issue/PR relates to or includes documentation. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_triage Needs a first human triage before being processed. python3 support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback. labels Oct 22, 2018
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Oct 23, 2018
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Oct 23, 2018
@gundalow
Copy link
Contributor

Love it!

@jborean93 jborean93 merged commit ddfd1db into ansible:devel Oct 23, 2018
@jborean93 jborean93 deleted the import-err branch October 23, 2018 21:21
Tomorrow9 pushed a commit to Tomorrow9/ansible that referenced this pull request Dec 4, 2018
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 core_review In order to be merged, this PR must follow the core review workflow. docs This issue/PR relates to or includes documentation. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. needs_maintainer Ansibot is unable to identify maintainers for this PR. (Check `author` in docs or BOTMETA.yml) python3 support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants