Ansible 作业模板AWX
我有一个这样的剧本,我试图在ansible awx中作为作业模板运行它,但得到了一个Ansible 作业模板AWX,ansible,ansible-awx,Ansible,Ansible Awx,我有一个这样的剧本,我试图在ansible awx中作为作业模板运行它,但得到了一个回溯(最近一次调用):\n File\“/root/.ansible/tmp/ansible-tmp-1609214869.41401-6813-56941014390086/rhv snapshots.py\”,第4行,在prettytable导入prettytable\nModuleNotFoundError中:没有名为“prettytable”的模块error,它使用ansible CLI工作,但在awx中
回溯(最近一次调用):\n File\“/root/.ansible/tmp/ansible-tmp-1609214869.41401-6813-56941014390086/rhv snapshots.py\”,第4行,在prettytable导入prettytable\nModuleNotFoundError中:没有名为“prettytable”的模块
error,它使用ansible CLI工作,但在awx中没有。有什么想法吗
---
- hosts: localhost
tasks:
- name: "Creating Script..."
copy:
content: |
#!/usr/bin/python3
import xml.etree.ElementTree as ET
from prettytable import PrettyTable
print('hello world!')
dest: /tmp/test.py
mode: 777
- name: "Running Script..."
script: /tmp/test.py
register: output
- debug:
var: output.stdout_lines
您可以创建类似files/test.py的文件 然后你复制它:
copy:
src: test.py
dest: /tmp/test.py
mode: '0777'
你能检查一下你的路线是否正确吗?任务名称应直接位于tasks关键字下。请尝试下面的代码
---
- hosts: localhost
tasks:
- name: "Creating Script..."
copy:
content: |
#!/usr/bin/python3
import xml.etree.ElementTree as ET
from prettytable import PrettyTable
print('hello world!')
dest: /tmp/test.py
mode: 777
- name: "Running Script..."
script: /tmp/test.py
register: output
- debug:
var: output.stdout_lines
为什么不创建一个包含内容的文件并复制它?可以给我一个例子吗?你需要在你的awx主机上安装
prettytable
python模块。正如我提到的,它是安装在CLI中的,而不是在awxI中。我收到了以下错误:“ansible.errors.AnsibleFileNotFound:找不到或访问“/home/ec2 user/test2.py”,它与Clip一起工作仍然不工作,已与进行检查