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

Directly runnig module doesn't work with fetch_url() function within module #53872

Closed
okgolove opened this issue Mar 15, 2019 · 4 comments · Fixed by #53875
Closed

Directly runnig module doesn't work with fetch_url() function within module #53872

okgolove opened this issue Mar 15, 2019 · 4 comments · Fixed by #53875
Assignees
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback. verified This issue has been verified/reproduced by maintainer

Comments

@okgolove
Copy link
Contributor

SUMMARY

I'm trying to run my module locally using next instructions https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html#exercising-module-code-locally

And I get an error.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Any module containing fetch_url() function from ansible.module_utils.urls
In my case it is my module I'm developing https://github.com/okgolove/ansible/blob/sentry_fixes/lib/ansible/modules/web_infrastructure/sentry_project.py

ANSIBLE VERSION
ansible 2.8.0.dev0
  config file = None
  configured module search path = [u'/Users/user/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/user/git/ansible/lib/ansible
  executable location = /Users/user/git/ansible/bin/ansible
  python version = 2.7.15 (default, Oct  2 2018, 11:47:18) [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.2)]
CONFIGURATION

args.json

{
    "ANSIBLE_MODULE_ARGS": {
        "api_token": "abcxdz",
        "organization": "develop",
        "project_name": "backendtest",
        "project_slug": "backendtest",
        "state": "present",
        "team": "develop",
        "url": "https://sentry.io"
    }
}
OS / ENVIRONMENT

MacOS 10.14.3, Python 2.7.15

STEPS TO REPRODUCE

pipenv shell && source hacking/env-setup && python lib/ansible/modules/web_infrastructure/sentry_project.py args.json

EXPECTED RESULTS

Module runs properly.

ACTUAL RESULTS

And I get an error:

  File "lib/ansible/modules/web_infrastructure/sentry_project.py", line 159, in <module>
    main()
  File "lib/ansible/modules/web_infrastructure/sentry_project.py", line 118, in main
    if is_project_exists(project_name, organization, team, api_token):
  File "lib/ansible/modules/web_infrastructure/sentry_project.py", line 110, in is_project_exists
    method="GET")
  File "/Users/user/git/ansible/lib/ansible/module_utils/urls.py", line 1327, in fetch_url
    tempfile.tempdir = module.tmpdir
  File "/Users/user/git/ansible/lib/ansible/module_utils/basic.py", line 851, in tmpdir
    basedir = os.path.expanduser(os.path.expandvars(self._remote_tmp))
AttributeError: 'AnsibleModule' object has no attribute '_remote_tmp'
@ansibot
Copy link
Contributor

ansibot commented Mar 15, 2019

Files identified in the description:
None

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback. labels Mar 15, 2019
@samdoran
Copy link
Contributor

samdoran commented Mar 15, 2019

This has not worked since Ansible 2.5.0. I bisected to this commit ca8e4c8.

@samdoran samdoran added the verified This issue has been verified/reproduced by maintainer label Mar 15, 2019
@samdoran samdoran self-assigned this Mar 15, 2019
@samdoran samdoran changed the title Direction run module doesn't work with fetch_url() function within module Directly runnig module doesn't work with fetch_url() function within module Mar 16, 2019
@okgolove
Copy link
Contributor Author

@samdoran my tests for my module with fetch_url() also are not able to pass because of the same error:

https://app.shippable.com/github/ansible/ansible/runs/116365/6/console
123

@sivel sivel added has_pr This issue has an associated PR. and removed needs_triage Needs a first human triage before being processed. labels Apr 2, 2019
@lithammer
Copy link

To work around the issue you can pass _ansible_tmpdir in your args.json:

{
  "ANSIBLE_MODULE_ARGS": {
    "foo": "bar",
    "_ansible_tmpdir": "/tmp"
  }
}

@ansible ansible locked and limited conversation to collaborators Jul 25, 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 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback. verified This issue has been verified/reproduced by maintainer
Projects
None yet
6 participants