hi guys,
Just started using Ansible - have been using it primarily to work with building clusters on EC2.
Now, my playbook is working perfectly with creating clusters. However I am trying to use another playbook to delete these clusters. I have other planned scripts that resizes the disks, etc.
I’m just not able to figure out how to work with managing running EC2 instances - I am adding them in a EC2 security group, tagging them (using “instance_tags” - not sure if I should use “ec2_tag” instead).
Here’s the output of the ec2.py script and the teardown script that I’m experimenting with and which is not working - https://gist.github.com/sandys/7559115
I’m running it with “ansible-playbook -i ec2.py”, so I am able to refer to “hosts:security_group_default”, but I’m just not sure how to populate “instance_ids” which is required for “state:absent”.
Now, I took a look at https://gist.github.com/bhang/6320004 (ELB example), but I think they are running the commands from the servers on EC2 - however, I probably need to keep using “hosts:localhost”.
Before we dive into your pastebins, “I’m just not able to figure out how to work with managing running EC2 instances”
What does “work with” mean?
hi Michael,
thanks for replying.
I was speaking colloquially: My whole question was around being able to use ansible to work with the AWS management API itself. I’m pretty clear (I think!! - but not too many examples available) on how to use the dynamic inventory .py file to address certain hosts and work with playbooks on them.
What I dont understand is how do you address these running hosts (categorized into security-groups, tags, etc) and perform actions like shutting them down, changing their security group, etc. Most of the examples I have seen - launch instances, register → “ec2”, shut them down by referring to them as “ec2.instance_ids”, etc.
From what I see what it is trying to do is recreate an instance with the same id, which of course fails because of idempotency, use that data to try and delete the cluster. Why is this done this way ? I’m a beginner in configuration management, so I just wanted to understand if it is a best practice to do things this way.
By extension, does everything in ansible work this way - for example, if I wanted to remove nginx, would I first idempotently install it and then remove it ?
"
By extension, does everything in ansible work this way - for example, if I wanted to remove nginx, would I first idempotently install it and then remove it ?"