Ad-Hoc commands are single liner commands which allow us to do something quickly but don’t want to save for later.
To list all hosts ansible --list-hosts all
To list hosts in a group ansible --list-hosts groupname
Negation – to list all hosts except one group
ansible --list-hosts \!groupname
To run a command as a specific user ansible -m command -a "command you wish to run" groupname -u ubuntu
Great post.