CLI

# fallback: install required python2 over SSH on remote machine
ansible example.com -i inventory -u root -m raw -a "apt-get update && apt-get install -y python-minimal"
 
# Ad-hoc commands
ansible all -i inventory.list -l localhost -u root -m ping
ansible all -s -m shell -a "hostname -f"
ansible all -s -m apt -a 'pkg=nginx state=installed update_cache=true'
ansible all -m shell -a uptime
ansible all -m shell -a "apt-get update"
ansible www.example.com -m setup
ansible all -m setup -i inventory/example.com -u root > /tmp/example.com.inventory.$(date -I).txt
ansible www.example.com -m setup -a "filter=ansible_ssh_host_key_rsa_public"
ansible all -m setup -a "filter=ansible_processor_vcpus"
ansible all -m setup -a "filter=ansible_all_ipv4_addresses"
ansible localhost -m setup
 
# set temporary host ip
ansible-playbook example.yml -i inventories/dev -e ansible_host=192.168.1.11
 
ansible localhost -m setup -a "filter=ansible_date_time"