有时候我们需要在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)
- aws eks node 自动化扩展工具 Karpenter - 8月 10, 2022
- ReplicationController and ReplicaSet in Kubernetes - 12月 20, 2021
- public key fingerprint - 5月 27, 2021