英文:
OnePassword task kicking back invalid item type during playbook
问题
I see you have provided a detailed error log related to an Ansible playbook. If you have any specific questions or need assistance with a particular aspect of this issue, please let me know, and I'll do my best to help you resolve it.
英文:
Having an issue with a test playbook I am working on to pull various secrets from our company 1Password vault.
I can pull secrets via the 1Pass CLI so its not a permissions / network / application issue. Just something with my sample play.
---
- name: 1Password testing
hosts: $testHost
connection: local
gather_facts: false
pre_tasks:
- name: Fixing 1Pass module bug...
file:
state: touch
path: "{{ '~/.op/config' | expanduser }}"
mode: 0700
run_once: true
- name: Import 1Password secrets...
include_vars: /etc/ansible/1password.yml
- name: Retrieve API keys...
community.general.onepassword_info:
auto_login:
master_password: '{{ account_password }}'
search_terms:
- name: "{{ inventory_hostname }}"
field: "credential"
vault: "my_vault"
cli_path: "~/.op/config"
delegate_to: localhost
register: api_key
When running, I am getting a error on the task that follows:
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
I understand what its trying to say. I have some kind of mis-matched data type, but I don't understand which field. The log does not appear to be descriptive enough, even with -vvvvv flagged.
Full output:
The full traceback is:
Traceback (most recent call last):
File "/root/.ansible/tmp/ansible-tmp-1684603988.409842-4767-16415303489901/AnsiballZ_onepassword_info.py", line 102, in <module>
_ansiballz_main()
File "/root/.ansible/tmp/ansible-tmp-1684603988.409842-4767-16415303489901/AnsiballZ_onepassword_info.py", line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/root/.ansible/tmp/ansible-tmp-1684603988.409842-4767-16415303489901/AnsiballZ_onepassword_info.py", line 40, in invoke_module
runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.onepassword_info', init_globals=None, run_name='__main__', alter_sys=True)
File "/usr/lib/python3.10/runpy.py", line 224, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/tmp/ansible_community.general.onepassword_info_payload_qzgnswsl/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py", line 390, in <module>
File "/tmp/ansible_community.general.onepassword_info_payload_qzgnswsl/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py", line 384, in main
File "/tmp/ansible_community.general.onepassword_info_payload_qzgnswsl/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py", line 351, in run
File "/tmp/ansible_community.general.onepassword_info_payload_qzgnswsl/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py", line 342, in assert_logged_in
File "/tmp/ansible_community.general.onepassword_info_payload_qzgnswsl/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py", line 308, in get_token
File "/usr/lib/python3.10/genericpath.py", line 30, in isfile
st = os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
$targetHost | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1684603988.409842-4767-16415303489901/AnsiballZ_onepassword_info.py\", line 102, in <module>\n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1684603988.409842-4767-16415303489901/AnsiballZ_onepassword_info.py\", line 94, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1684603988.409842-4767-16415303489901/AnsiballZ_onepassword_info.py\", line 40, in invoke_module\n runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.onepassword_info', init_globals=None, run_name='__main__', alter_sys=True)\n File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_community.general.onepassword_info_payload_qzgnswsl/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 390, in <module>\n File \"/tmp/ansible_community.general.onepassword_info_payload_qzgnswsl/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 384, in main\n File \"/tmp/ansible_community.general.onepassword_info_payload_qzgnswsl/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 351, in run\n File \"/tmp/ansible_community.general.onepassword_info_payload_qzgnswsl/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 342, in assert_logged_in\n File \"/tmp/ansible_community.general.onepassword_info_payload_qzgnswsl/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 308, in get_token\n File \"/usr/lib/python3.10/genericpath.py\", line 30, in isfile\n st = os.stat(path)\nTypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
This is for Ansible core 2.14.5 and community.general of 1.3.6 or 6.6.0 depending on the installation path according to the collection list.
New edit - 2023-05-22, response to mdaniel, try #2.
Output from "mode: 0600":
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: PermissionError: [Errno 13] Permission denied: '/root/.op/config'
$targetHost | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1684811698.3200085-22036-163190884623241/AnsiballZ_onepassword_info.py\", line 107, in <module>\n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1684811698.3200085-22036-163190884623241/AnsiballZ_onepassword_info.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1684811698.3200085-22036-163190884623241/AnsiballZ_onepassword_info.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.onepassword_info', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.onepassword_info', _modlib_path=modlib_path),\n File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_community.general.onepassword_info_payload_9bdub1uc/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 390, in <module>\n File \"/tmp/ansible_community.general.onepassword_info_payload_9bdub1uc/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 384, in main\n File \"/tmp/ansible_community.general.onepassword_info_payload_9bdub1uc/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 351, in run\n File \"/tmp/ansible_community.general.onepassword_info_payload_9bdub1uc/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 346, in assert_logged_in\n File \"/tmp/ansible_community.general.onepassword_info_payload_9bdub1uc/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 338, in assert_logged_in\n File \"/tmp/ansible_community.general.onepassword_info_payload_9bdub1uc/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 202, in _run\n File \"/usr/lib/python3.10/subprocess.py\", line 969, in __init__\n self._execute_child(args, executable, preexec_fn, close_fds,\n File \"/usr/lib/python3.10/subprocess.py\", line 1845, in _execute_child\n raise child_exception_type(errno_num, err_msg, err_filename)\nPermissionError: [Errno 13] Permission denied: '/root/.op/config'\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
Output from "mode: 0700"
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: OSError: [Errno 8] Exec format error: '/root/.op/config'
ATLAB-PF-FW | FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1684811717.592182-22110-137137656610529/AnsiballZ_onepassword_info.py\", line 107, in <module>\n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1684811717.592182-22110-137137656610529/AnsiballZ_onepassword_info.py\", line 99, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1684811717.592182-22110-137137656610529/AnsiballZ_onepassword_info.py\", line 47, in invoke_module\n runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.onepassword_info', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.onepassword_info', _modlib_path=modlib_path),\n File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\n return _run_module_code(code, init_globals, run_name, mod_spec)\n File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\n _run_code(code, mod_globals, init_globals,\n File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\n exec(code, run_globals)\n File \"/tmp/ansible_community.general.onepassword_info_payload_simtqqd8/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 390, in <module>\n File \"/tmp/ansible_community.general.onepassword_info_payload_simtqqd8/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 384, in main\n File \"/tmp/ansible_community.general.onepassword_info_payload_simtqqd8/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 351, in run\n File \"/tmp/ansible_community.general.onepassword_info_payload_simtqqd8/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 346, in assert_logged_in\n File \"/tmp/ansible_community.general.onepassword_info_payload_simtqqd8/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 338, in assert_logged_in\n File \"/tmp/ansible_community.general.onepassword_info_payload_simtqqd8/ansible_community.general.onepassword_info_payload.zip/ansible_collections/community/general/plugins/modules/onepassword_info.py\", line 202, in _run\n File \"/usr/lib/python3.10/subprocess.py\", line 969, in __init__\n self._execute_child(args, executable, preexec_fn, close_fds,\n File \"/usr/lib/python3.10/subprocess.py\", line 1845, in _execute_child\n raise child_exception_type(errno_num, err_msg, err_filename)\nOSError: [Errno 8] Exec format error: '/root/.op/config'\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
答案1
得分: 1
这是你要翻译的部分:
-
这是他们
module_utils.onepassword.OnePasswordConfig
合同中的一个错误,他们让@property
脱离了方法底部,这意味着它返回None
,但 调用者没有检查 -
最好的情况是他们修复这个问题,但我猜你的解决方法是确保其中的一个 这三个文件 存在
- file:
state: touch
path: "{{ '~/.op/config' | expanduser }}"
mode: 0600
- debug:
msg: 现在尝试你的 onepassword_info 任务
英文:
It's a bug in the contract between their module_utils.onepassword.OnePasswordConfig
where they let the @property
fall off the bottom of the method meaning it returns None
, but the caller doesn't check for that
The best case would be them fixing that, but I'd guess the work-around for you is to ensure one of these 3 files exists
- file:
state: touch
path: "{{ '~/.op/config' | expanduser }}"
mode: 0600
- debug:
msg: now try your onepassword_info task
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论