易出错的剧本运行不正常



下面是我易理解的战术手册

---
- name: Schema Backup Script
hosts: hosts1:hosts2:hosts3
gather_facts: False
tasks:
- name: Copy the script to Managed node
copy:
src: backup.sh
dest: ~/
mode: 0777
become: true
become_user: user1
- name: Execute the Export command
shell: sh ~/backup.sh
become: true
become_user: user1
- name: Delete the script copied on Managed node
file:
path: ~/backup.sh
state: absent
become: true
become_user: user1
...

当我运行这个剧本任务2时,问题是执行Export命令,但任务1没有执行。

1(当您想在远程节点上执行本地脚本时,可以使用脚本模块

2( 您不能在Ansible模块参数中使用~,因为它是外壳功能

最新更新