Adhoc-Commands

Parallelism & Shell Commands

  1. To set up SSH agent

$ ssh-agent bash 
$ ssh-add ~/.ssh/id_rsa 
  1. To use SSH with a password instead of keys, you can use --ask-pass (-K)

$ ansible europe -a "/sbin/reboot" -f 20 
  1. To run /usr/bin/ansible from a user account, not the root

$ ansible europe -a "/usr/bin/foo" -u username 
  1. To run commands through privilege escalation and not through user account

$ ansible europe -a "/usr/bin/foo" -u username --become [--ask-become-pass] 
  1. If you are using password less method then use --ask-become-pass (-K) to interactively get the password to be use You can become a user, other than root by using --become-user

$ ansible europe -a "/usr/bin/foo" -u username --become --become-user otheruser [--ask-become-pass]

Last updated