test-module: define ansible_version attribute
Executed command: ./hacking/test-module -m lib/ansible/modules/cloud/scaleway/scaleway_security_group.py -a ... Fix this exception found while testing scaleway_security_group module: Traceback (most recent call last): File "~/debug_dir/__main__.py", line 240, in <module> main() File "~/debug_dir/__main__.py", line 236, in main core(module) File "~/debug_dir/__main__.py", line 209, in core api = Scaleway(module=module) File "~/debug_dir/ansible/module_utils/scaleway.py", line 58, in __init__ 'User-Agent': self.get_user_agent_string(module), File "~/debug_dir/ansible/module_utils/scaleway.py", line 99, in get_user_agent_string return "ansible %s Python %s" % (module.ansible_version, sys.version.split(' ')[0]) AttributeError: 'AnsibleModule' object has no attribute 'ansible_version'
This commit is contained in:
parent
7231f7da84
commit
92103bf5d0
1 changed files with 2 additions and 0 deletions
|
@ -35,6 +35,7 @@ import sys
|
||||||
import traceback
|
import traceback
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
|
from ansible.release import __version__
|
||||||
import ansible.utils.vars as utils_vars
|
import ansible.utils.vars as utils_vars
|
||||||
from ansible.parsing.dataloader import DataLoader
|
from ansible.parsing.dataloader import DataLoader
|
||||||
from ansible.parsing.utils.jsonify import jsonify
|
from ansible.parsing.utils.jsonify import jsonify
|
||||||
|
@ -124,6 +125,7 @@ def boilerplate_module(modfile, args, interpreters, check, destfile):
|
||||||
complex_args['_ansible_selinux_special_fs'] = C.DEFAULT_SELINUX_SPECIAL_FS
|
complex_args['_ansible_selinux_special_fs'] = C.DEFAULT_SELINUX_SPECIAL_FS
|
||||||
complex_args['_ansible_tmpdir'] = C.DEFAULT_LOCAL_TMP
|
complex_args['_ansible_tmpdir'] = C.DEFAULT_LOCAL_TMP
|
||||||
complex_args['_ansible_keep_remote_files'] = C.DEFAULT_KEEP_REMOTE_FILES
|
complex_args['_ansible_keep_remote_files'] = C.DEFAULT_KEEP_REMOTE_FILES
|
||||||
|
complex_args['_ansible_version'] = __version__
|
||||||
|
|
||||||
if args.startswith("@"):
|
if args.startswith("@"):
|
||||||
# Argument is a YAML file (JSON is a subset of YAML)
|
# Argument is a YAML file (JSON is a subset of YAML)
|
||||||
|
|
Loading…
Reference in a new issue