Ahoy,
I’m new to this list, so apologies if I violate convention (let me know).
I’ve been working happily with Ansible for a while, but I’ve found many AWS modules behave in unexpected ways. Many are excellent, but there seems to be a consistency issue.
It’s become awkward enough that I just want to replace a few small parts, but I would like to architect them “The Right Way”, to avoid problems down the line, in the off-chance that they end up used by folks or even making it back to core somehow.
PLEASE give me some ideas / feedback on what would work best if you were designing the modules, or problems you’ve run into / solved if you already worked on them.
Current Problems
- Inconsistency w/ other ansible modules / conventions - e.g. many modules don’t offer ‘state’, ‘name’ and other common options
- Nonidempotency - some modules are nonidempotent without a clear reason why, or require you to hardcode a command/action rather than using state (e.g. rds module has command: create, command: replicate)
- Inconsistency between AWS modules (e.g. ec2 module allows creating attached volumes, but the volume options are different than provided ec2_vol module options)
- Inconsistency with AWS APIs / boto
- Inconsistency of module behavior internally for a module task, based on options set (e.g. running ec2 module with exact_count set dramatically changes how the task behaves)
- Feature gaps - fat modules focused on individual AWS products, seem to make it difficult to perform some actions involving relationships between products. It’s surprisingly difficult to do things like modify the security groups of a VPC instance, etc.
- Large, complex tasks - modules take a lot of options and do many things, leading to confusion, and return values for register variables end up chubby as well
- There isn’t really a good, unified way to target instances of products (like ec2 instances, ELB, etc) that already exist to perform actions on them or to relate them to other instances.
Ideas
Here’s my initial idea. Tell me if it’s dumb, and why.
- Start by stealing a few ideas from boto / cli to apply to new modules, such as Filter to select instances to apply tasks to
- Create a handful of small tasks that perform very specific functions, e.g.
- ec2_security_group_assignment: state=present name=ssh-enabled tag_filter: [ Name: linux-boxes ]
- Always use ‘state’ / ‘name’ and other common features in modules if possible.
- Always do idempotent actions if possible.
- Use more tasks and smaller tasks. (e.g. require
- ec2_instance_option: termination_protection=yes
instead of providing it as option in ec2 module?). - Any task that creates / destroys should have the smallest set of options possible, and more detailed configuration should require selection using instance id or filter or whatever.
- Eventually, maybe allow fat tasks to execute smaller tasks for convenience?
Caveats
- I’m not really totally happy with any options I have thought up for dealing with idempotency for AWS.
- It will take me forever to rewrite any useful number of AWS ansble modules. I have almost no time for it and would only be working on scratching the itches that bother me most. Also, I am still a bit baffled by some parts of boto since the switch to boto3
- I plan on releasing modules on github. I do not plan on trying to get them into ansible core.
Anyway, any better ideas for AWS modules?