ansible icon indicating copy to clipboard operation
ansible copied to clipboard

fix: use && execute ansible shell

Open vpc123 opened this issue 2 years ago • 0 comments

shell: "sudo mv -f /etc/yum.repos.d/.repo /etc/yum.repos.d/bak >/dev/null 2>&1 || sudo ls /etc/yum.repos.d/ >/dev/null 2>&1 || yum clean all >/dev/null 2>&1 || rm -rf /var/cache/yum/ 2>&1"

ansible shell if use || , subsequent commands will not be executed,so before commands will not executed yum clean all && rm -rf /var/cache/yum/* ;

The best way is through && join this commands and end with || sudo ls /etc/yum.repos.d/ >/dev/null 2>&1;

for example: shell: "sudo mv -f /etc/yum.repos.d/.repo /etc/yum.repos.d/bak >/dev/null 2>&1 && yum clean all >/dev/null 2>&1 && rm -rf /var/cache/yum/ 2>&1 || sudo ls /etc/yum.repos.d/ >/dev/null 2>&1"

vpc123 avatar Dec 18 '22 00:12 vpc123