ad-hoc执行出错
来源:7-5 ad-hoc任务执行_
慕姐6915038
2019-05-29
python3.7 ,ansible:2.4.2
ansible_api_k1.py这个文件我只修改的print(),因为python3 是需要()打印的,其他未修改,执行报如下错误
/root/PycharmProjects/txfcops/venv/bin/python /root/PycharmProjects/txfcops/ops/ansible_api_k1.py
#下面这一行是我打印的play_source信息
{‘name’: ‘Ansible Play ad-hoc test’, ‘hosts’: ‘192.168.1.200’, ‘gather_facts’: ‘no’, ‘tasks’: [{‘action’: {‘module’: ‘shell’, ‘args’: ‘touch /tmp/ad_hoc_test1’}}]}
Traceback (most recent call last):
File “/root/PycharmProjects/txfcops/ops/ansible_api_k1.py”, line 74, in
play = Play().load(play_source, variable_manager=variable_manager, loader=loader)
File “/usr/local/python3/lib/python3.7/site-packages/ansible/playbook/play.py”, line 117, in load
return p.load_data(data, variable_manager=variable_manager, loader=loader)
File “/usr/local/python3/lib/python3.7/site-packages/ansible/playbook/base.py”, line 254, in load_data
self._attributes[name] = method(name, ds[name])
File “/usr/local/python3/lib/python3.7/site-packages/ansible/playbook/play.py”, line 147, in _load_tasks
return load_list_of_blocks(ds=ds, play=self, variable_manager=self._variable_manager, loader=self._loader)
File “/usr/local/python3/lib/python3.7/site-packages/ansible/playbook/helpers.py”, line 59, in load_list_of_blocks
loader=loader,
File “/usr/local/python3/lib/python3.7/site-packages/ansible/playbook/block.py”, line 86, in load
return b.load_data(data, variable_manager=variable_manager, loader=loader)
File “/usr/local/python3/lib/python3.7/site-packages/ansible/playbook/base.py”, line 254, in load_data
self._attributes[name] = method(name, ds[name])
File “/usr/local/python3/lib/python3.7/site-packages/ansible/playbook/block.py”, line 122, in _load_block
use_handlers=self._use_handlers,
File “/usr/local/python3/lib/python3.7/site-packages/ansible/playbook/helpers.py”, line 332, in load_list_of_tasks
t = Task.load(task_ds, block=block, role=role, task_include=task_include, variable_manager=variable_manager, loader=loader)
File “/usr/local/python3/lib/python3.7/site-packages/ansible/playbook/task.py”, line 139, in load
return t.load_data(data, variable_manager=variable_manager, loader=loader)
File “/usr/local/python3/lib/python3.7/site-packages/ansible/playbook/base.py”, line 244, in load_data
ds = self.preprocess_data(ds)
File “/usr/local/python3/lib/python3.7/site-packages/ansible/playbook/task.py”, line 179, in preprocess_data
(action, args, delegate_to) = args_parser.parse()
File “/usr/local/python3/lib/python3.7/site-packages/ansible/parsing/mod_args.py”, line 289, in parse
if item in module_loader or item in action_loader or item in [‘meta’, ‘include’, ‘include_tasks’, ‘include_role’, ‘import_tasks’, ‘import_role’]:
File “/usr/local/python3/lib/python3.7/site-packages/ansible/plugins/loader.py”, line 323, in has_plugin
return self.find_plugin(name) is not None
File “/usr/local/python3/lib/python3.7/site-packages/ansible/plugins/loader.py”, line 265, in find_plugin
for path in (p for p in self._get_paths() if p not in self._searched_paths and os.path.isdir§):
File “/usr/local/python3/lib/python3.7/site-packages/ansible/plugins/loader.py”, line 176, in _get_paths
ret.extend(self._get_package_paths(subdirs=subdirs))
File “/usr/local/python3/lib/python3.7/site-packages/ansible/plugins/loader.py”, line 141, in _get_package_paths
m = import(self.package)
File “/usr/local/python3/lib/python3.7/site-packages/ansible/plugins/action/init.py”, line 96
if self._task.async and not self._supports_async:
^
SyntaxError: invalid syntax
Process finished with exit code 1
1回答
-
慕姐6915038
提问者
2019-05-29
问题已经解决,python版本降到3.6.8通过
00
相似问题