说明
这是一个Ansible Python Api的封装。
安装
$ python setup.py install
简单使用
from Asi import Api
if __name__ == "__main__":
hosts = [
{
"hostname": "localhost",
"port": 22,
"vars": {
"ansible_ssh_user": "root",
"ansible_ssh_pass": "p@ssw0rd"
}
},
{
"hostname": "192.168.152.142",
"port": 22,
"vars": {
"ansible_ssh_user": "root",
"ansible_ssh_pass": "p@ssw0rd"
}
}
]
Api().module("shell", args="ls", register='shell_out', task_name="test")\
.module("debug", args={"msg":"{{shell_out.stdout}}"})\
.run(hosts)
获取返回数据
在run方法前面调用json方法,并且run方法中callback参数需为None,如果自己实现callback, 则需要在callback增添属性results
from Asi import Api
import json
if __name__ == "__main__":
hosts = [
dict(hostname="127.0.0.1", port=22)
]
api = Api()
api = api.module("shell", args="ls", register="shell_out")
api = api.module("debug", args=dict(msg="{{shell_out}}"))
api = api.json()
print("result")
print(json.dumps(api.run(hosts), indent=4))
Metadata
Release files for Asi 1.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| Asi-1.2.2.tar.gz | 4.9 kB | Without provenance | Details |
Release files / Asi-1.2.2.tar.gz
| Download URL | Asi-1.2.2.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
da6ca8a6c33b266cd9961fb6c692c09e184958973a19f8932024d1d94975a7cf
|
|
BLAKE2b-256 checksum How to use checksums |
92a091cc4d7ee20fc2e0759a5de915330be48a7838741b8239966ecdb8aac19c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.9.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.5
|
Security for Asi 1.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.