use ansible-runner as Python module Interface to Ansible error: RunnerConfig' object has no attribute 'command'
use ansible-runner as Python module Interface to Ansible error: RunnerConfig' object has no attribute 'command'
我使用 ansible 2.9.13 和 ansible-runner 1.4.6
下面是我的 Python 代码:
from ansible_runner import Runner, RunnerConfig
f = open('/home/george/dev/beeops/ansible_private/keyfile', 'r')
key = f.read()
rc = RunnerConfig(private_data_dir='/home/george/dev/beeops/ansible_private',
playbook='test.yml',
inventory='127.0.0.1',
ssh_key=key,)
r = Runner(config=rc)
r.run()
执行这段代码时出错,
File "/home/george/venv/bops/lib/python3.7/site-packages/ansible_runner/runner.py", line 114, in run
command = self.config.command
AttributeError: 'RunnerConfig' object has no attribute 'command'
谁能帮我看看是什么问题?
感谢所有回复的朋友!
看起来直接运行器执行不是 fully documented. When reading the code,在调用 r.run()
.
之前应该先调用 rc.prepare()
所有这一切都是在使用 helper interfaces 时为您完成的。
我使用 ansible 2.9.13 和 ansible-runner 1.4.6
下面是我的 Python 代码:
from ansible_runner import Runner, RunnerConfig
f = open('/home/george/dev/beeops/ansible_private/keyfile', 'r')
key = f.read()
rc = RunnerConfig(private_data_dir='/home/george/dev/beeops/ansible_private',
playbook='test.yml',
inventory='127.0.0.1',
ssh_key=key,)
r = Runner(config=rc)
r.run()
执行这段代码时出错,
File "/home/george/venv/bops/lib/python3.7/site-packages/ansible_runner/runner.py", line 114, in run
command = self.config.command
AttributeError: 'RunnerConfig' object has no attribute 'command'
谁能帮我看看是什么问题? 感谢所有回复的朋友!
看起来直接运行器执行不是 fully documented. When reading the code,在调用 r.run()
.
rc.prepare()
所有这一切都是在使用 helper interfaces 时为您完成的。