Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattyait/ansible-dynamic-ec2inventory
Ansible example to use dynamic inventory to deal with ec2 instances
https://github.com/mattyait/ansible-dynamic-ec2inventory
ansible ansible-dynamic-inventory
Last synced: 24 days ago
JSON representation
Ansible example to use dynamic inventory to deal with ec2 instances
- Host: GitHub
- URL: https://github.com/mattyait/ansible-dynamic-ec2inventory
- Owner: mattyait
- License: mit
- Created: 2019-10-10T23:45:44.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-10-10T23:48:15.000Z (about 5 years ago)
- Last Synced: 2024-10-29T21:16:13.479Z (2 months ago)
- Topics: ansible, ansible-dynamic-inventory
- Language: Python
- Size: 18.6 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## ansible-dynamic-ec2inventory
- Set the credentials as environment variable to pass to the dyanmic inventory (ec2.py) scripts
export AWS_ACCESS_KEY_ID='AK123'
export AWS_SECRET_ACCESS_KEY='abc123'- test the script and connection with valid aws credentials, it will returns the list of ec2 instances grouped in json with tag name which can be used as host in ansible playbook
python inventories/ec2.py --list
**NOTE:** If need to get the private IP's of ec2 instances then enable `vpc_destination_variable`
in `ec2.in` filevpc_destination_variable = private_ip_address
- Execute the ansible playbook to run the task on ec2-instance
ansible-playbook -i inventories/ec2.py playbooks/sample.yml