运行我的第一本剧本时出现错误消息。我创建了一个剧本来在多个主机上应用补丁。
---
- hosts: server01
vars:
jboss_home: /apps/middleware/jboss-eap-7.1
patch_file: patch_url
patch_dest: /apps/middleware/jboss-eap-7.1
patch_version: 7.1.3
tasks:
- name: Copy patch to target host
copy:
src: "{{ patch_file }}"
dest: "{{ patch_dest }}/{{ patch_file }}"
- name: Check applied patches
command: "jboss-cli.sh 'patch history'"
register: result
changed_when: "False"
- name: Apply patch
command: "jboss-cli.sh 'patch apply {{ patch_dest }}/{{ patch_file }}'"
when: patch_version not in result.stdout
输出
致命错误PLAY [server1] ****************************************************** ********************************************任务[收集事实] ****************************************************** ****************************************************** *******好的:[server1]任务[将补丁复制到目标主机] ****************************************************** ***************************************************发生异常在任务执行期间。看到完整 追溯,使用-vvv。错误是:
/ apps /中间件/ ansible / environments / dev / jboss / patching / patch_url 致命的:[server1]:失败! => {“已更改”:false,“ msg”:“找不到 或访问“ patch_url” \ n 在以下位置:\ n \ t / apps / middleware / ansible / environments / dev / jboss / patching / files / patch_url \ n \ t / apps / middleware / ansible / environments / dev / jboss / patching / patch_url \ n \ t / apps / middleware / ansible / environments / dev / jboss / patching / files / patch_url \ n \ t / apps / middleware / ansible / environments / dev / jboss / patching / patch_url“} 要重试,请使用:--limit @ / apps / middleware / ansible / environments / dev / jboss / patching / jboss_patching.retry
答案 0 :(得分:0)
patch_url
文件应该位于files
角色的patching
目录中。
如输出中所述,默认情况下,copy
模块将在此位置寻找它,然后在您角色的根目录中寻找它。