joshuapy / ansible2_myapi Goto Github PK
View Code? Open in Web Editor NEW对Ansible2.2+ API进行封装,以达到API使用方式像Ansible1.9 API一样简单。
对Ansible2.2+ API进行封装,以达到API使用方式像Ansible1.9 API一样简单。
2.1定义:
def get_hosts(self, pattern="all", ignore_limits_and_restrictions=False):
2.2定义:
def get_hosts(self, pattern="all", ignore_limits=False, ignore_restrictions=False):
所以现在的api是2.2+版本下的。
我按照格式3传入了如下格式:
{
'1.1.1.1': {
'vars': {
'ansible_password': 'mypassword', 'ansible_port': '22', 'ansible_user': 'root'
}
}
}
执行的时候提示Inventory is empty.
,这个是什么情况呢
我刚看了下,默认仅支持22端口对吧,请问,支持其他端口么?
Traceback (most recent call last):
File "/home/xxx/Network/scms/ansible-test.py", line 14, in
result = runner.run()
File "/home/xxx/Network/scms/ansible2_myAPI/runner.py", line 158, in run
raise Exception(e)
Exception: 'str' object has no attribute 'get'
提示这个错误呢?什么原因呢
from ansible2_myAPI.runner import Runner
runner = Runner(
module_name="shell",
module_args="uptime",
remote_user="test",
pattern="all",
hosts="172.19.0.70, ",
passwords='123'
)
result = runner.run()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.