Python ansible常用模块
2018-01-04 17:16
260 查看
import ansible.runner
import ansible.playbook
import ansible.inventory
from ansible import callbacks
from ansible import utils
远程执行命令
hosts = [hosts]
host_inventory = ansible.inventory.Inventory(hosts)
pm = ansible.runner.Runner(module_name = 'command',module_args = cmds,timeout = 600,inventory = host_inventory,subset = 'all')
out = pm.run()
远程传输文件
hosts = [hosts]
host_inventory = ansible.inventory.Inventory(hosts)
pm = ansible.runner.Runner(module_name = 'copy',module_args = 'src='+file_path+' dest='+file_path+' mode=0644',timeout = 600,inventory = host_inventory,subset = 'all')
out = pm.run()
import ansible.playbook
import ansible.inventory
from ansible import callbacks
from ansible import utils
远程执行命令
hosts = [hosts]
host_inventory = ansible.inventory.Inventory(hosts)
pm = ansible.runner.Runner(module_name = 'command',module_args = cmds,timeout = 600,inventory = host_inventory,subset = 'all')
out = pm.run()
远程传输文件
hosts = [hosts]
host_inventory = ansible.inventory.Inventory(hosts)
pm = ansible.runner.Runner(module_name = 'copy',module_args = 'src='+file_path+' dest='+file_path+' mode=0644',timeout = 600,inventory = host_inventory,subset = 'all')
out = pm.run()
相关文章推荐
- Python之——Ansible常用模块及API
- Python random模块(获取随机数)常用方法和使用例子
- python 常用模块--logging,JSON/pickle,os
- python os模块 常用命令
- python常用模块大全
- ansible常用模块介绍
- python 常用的os模块
- Python 一些常用模块的安装
- Python 之路 Day5 - 常用模块学习
- Python模块常用的几种安装方式
- python【第五篇】常用模块学习
- ansible小结(七)常用模块
- Python 常用功能模块介绍
- python3 开发面试题(常用模块以及第三方库)6.5
- Python里的OS模块常用函数说明
- os---Python里的OS模块常用函数说明
- Python GUI:高级作图turtle模块的常用函数.md
- Python sys模块的常用方法
- Python入门—1模块_2_os与shutil模块常用方法
- Python常用内建模块——学习笔记