Ansible Runner API package
Project description
AnsibleRunner
拷貝自jumpserver項目
install
pip install ansible==2.8.8
Runner
Ansible Command Runner
simple runner
runner = CommandRunner()
runner.execute('ls')
inventory hosts
host_data = [
{
"hostname": "demo-web1",
"ip": "192.168.33.101",
"port": 2222,
"username": "root",
"private_key": "/Users/maliao/.ssh/id_rsa",
},
{
"hostname": "demo-web2",
"ip": "192.168.33.102",
"port": 2222,
"username": "root",
"private_key": "/Users/maliao/.ssh/id_rsa",
},
{
"hostname": "demo-web3",
"ip": "192.168.33.103",
"port": 2222,
"username": "root",
"private_key": "/Users/maliao/.ssh/id_rsa",
},
{
"hostname": "demo-web4",
"ip": "192.168.33.104",
"port": 2222,
"username": "root",
"private_key": "/Users/maliao/.ssh/id_rsa",
},
]
runner = CommandRunner(inventory=host_data)
runner.execute('ls')
Ansible Playbook Runner
simple runner
runner = PlayBookRunner(hostname='maliao-web1',path='test.yml')
runner.run()
option
runner1 = PlayBookRunner(hostname='maliao-web1', path='test.yml',options={'memory_mb': 1024, 'size_gb': 30,'num_cpus': 2})
runner1.run()
inventory hosts
hosts = [
{
"hostname": 'maliao-web1',
"ip": '192.168.1.1',
"port": '22',
"username": "root",
"private_key": "/Users/maliao/.ssh/id_rsa"
},
{
"hostname": 'maliao-web1',
"ip": '192.168.1.1',
"port": '22',
"username": "root",
"private_key": "/Users/maliao/.ssh/id_rsa"
},
]
runner2 = PlayBookRunner(hostname='maliao-web1', path='test.yml', inventory=hosts)
runner2.run()
Callback
gather_result
任務開始 v2_playbook_on_play_start
任務成功 v2_runner_on_ok
無法連接 v2_runner_on_unreachable
任務失敗 v2_runner_on_failed
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ansiblerunnerapi-0.0.2.tar.gz
.
File metadata
- Download URL: ansiblerunnerapi-0.0.2.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8950aa4d2988c8d4060f8f5e4f13f80b23bc83dcccb96f3b584a83f2884ba88b |
|
MD5 | a08b6a9bf542e2c401f10642bff4eeed |
|
BLAKE2b-256 | c80d30eb97581f2f9199cec75c7839ff2aa1cc608a453379a8aff8ac90244b1a |
File details
Details for the file ansiblerunnerapi-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: ansiblerunnerapi-0.0.2-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80bed864cf19134195225445aae4a71214a1f9eda2ace4b6fd0f5e1325834ba4 |
|
MD5 | 0742c4cc91a77cee18d5eb705dfcd38e |
|
BLAKE2b-256 | b164b8db54329ab2074fb45dcb29bf94643f0a22e8b5b457070b7289c9e7e183 |