有时候我们需要在ansible 执行sudo 命令,并且sudo 命令中存在管道符
可以通过 sh -c 并把需要sudo权限的部分放到引号内
1 2 3 4 5 |
- name: update env before deploy shell: /usr/bin/sudo -u tai sh -c "/bin/cat abc | uniq -u | wc -;" args: chdir: "{{ target_path }}" when: senv.changed |
Latest posts by Zhiming Zhang (see all)
- 什么是ami - 二月 22, 2021
- istio Ingress Gateways - 十一月 25, 2020
- Istio VirtualService - 十一月 23, 2020