Python中文
首页
教程
问答
标签
搜索
登录
注册
动作插件和Ansible模块之间的关系是什么?
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<h2>问题</h2> <p>目前,我正在尝试开发一个动作插件来调用其他模块来简化和自动化一个任务。(请参阅我的<a href="https://stackoverflow.com/questions/46893066/calling-an-ansible-module-from-another-ansible-module">previous question</a>了解更多详细信息)目前,我甚至无法运行插件。我知道我需要一个同名的模块才能正常运行,但是当我有一个同名的空白文件时,它仍然失败。我缺少模块和插件之间的关系?在</p> <h2>其他信息</h2> <p>以防万一,我把我的错误误诊了这里是一些安装信息和插件的示例代码。在</p> <h3>安装</h3> <p>模块存在于<code>~/.ansible/plugins/modules</code><br/> 插件存在于<code>~/.ansible/plugins/action_plugin</code></p> <h3>示例代码</h3> <pre><code>from ansible.plugins.action import ActionBase class ActionModule(ActionBase): def run(self, tmp=None, task_vars=None): result = super(ActionModule, self).run(tmp, task_vars) result_modules = {} common_args = {} common_args['ucs_ip'] = self._task.args.get('ucs_ip') common_args['ucs_username'] = self._task.args.get('ucs_username') common_args['ucs_password'] = self._task.args.get('ucs_password') #Make LS Server module_args = common_args.copy() module_args['name'] = self._task.args.get('name') module_args['other_args'] = self._task.args.get('other_args') result_modules['lsServer'] = self._execute_module(module_name='ls_server_module', module_args=module_args, task_vars=task_vars, tmp=tmp) root_name = self._task.args.get('org_dn') + '/ls-' + self._task.args.get('name') #Make Vnic Ether for vnic in self._task.args.get('LAN', {}).get('VNIC'): module_args = common_args.copy() module_args['name'] = vnic.get('name') module_args['other_args'] = vnic.get('other_args') module_args['parent'] = root_name res['vnic_'+vnic.get('name')] = self._execute_module(module_name='vnic_ether_module', module_args=module_args, task_vars=task_vars, tmp=tmp) vnic_name = root_name + "/ether-" + vnic.get('name') #Make Vlan with VnicEtherIf for vlan in vnic.get('vlans'): module_args = common_args.copy() module_args['name'] = vlan.get('name') module_args['parent'] = vnic_name </code></pre> <h3>Yaml文件</h3> ^{pr2}$
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>操作插件的正确文件夹是<code>~/.ansible/plugins/action</code></p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
plt.savefig不会覆盖现有文件
6 回答
plt.savefig不保存图像
8 回答
plt.savefig在jupyter笔记本中不起作用
5 回答
plt.savefig在从另一个fi调用时停止工作
10 回答
plt.savefig在调用plt.show之前保存空数字
3 回答
plt.save不创建png文件
3 回答
plt.scatter overlay分类数据帧列
2 回答
Plt.Scatter:如何添加title、xlabel和ylab
9 回答
plt.scatter()绘图与Matplotlib中的plt.plot()绘图类似
7 回答
plt.scatter错误'NoneType'对象在成功运行后没有属性'sqrt'
3 回答
plt.set_title()中的标题字符串有误
2 回答
plt.show()
10 回答
plt.show()不在Jupyter笔记本上渲染任何内容
8 回答
plt.show()不打印plt.plot only plt.scatter
7 回答
plt.show()不显示三维散射图像
7 回答
plt.show()不显示任何内容
1 回答
plt.show()不显示数据,而是保留它供下一个图表使用(spyder)
2 回答
plt.show()使终端挂起
7 回答
plt.show()无法使用此代码
10 回答
plt.show()没有打开新的图形风
6 回答