- We will be running Ansible ad hoc commands using the EC2 dynamic inventory and shell module to execute /bin/uname -a:
ansible -i ec2.py tag_Name_my_first_instance -m shell -a "/bin/uname -a"
- Similarly, we can use the dynamic inventory to target the following specific features:
ansible -i ec2.py <instance-id> -m shell -a "/bin/uname -a"
ansible -i ec2.py us-east-1 -m shell -a "/bin/uname -a"
ansible -i ec2.py all -m shell -a "/bin/uname -a"
- AWS dynamic inventory, generated by ec2.py, is grouped by default with various parameters, for example, tags, instance_ids, regions, and so on. We can also use this same approach for running an Ansible playbook (with hosts: us-east-1), ...