-
Notifications
You must be signed in to change notification settings - Fork 23.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make ec2_instance able to create new instance or fail if instance matching filter already found #53610
Comments
Files identified in the description: If these files are inaccurate, please update the |
@Elias481, just so you are aware we have a dedicated Working Group for aws. |
@Elias481, thanks for submitting this, I don't think this should be included in the module itself, the module ( and ansible in general ) is to ensure you have the resource/s in the desired state; That said, if this is a feature you need, you can already achieve it by using - name: Fail if instance already exist
ec2_instance_facts:
[...]
filters:
<your_filters>
register: instance_exists
failed_when: instance_exists.instances | length > 0 |
Yes for sure it's possible to check the in yet another additional ansible block. It is always the case and the approach is symply to say users (acting as admins) that all changes that they do to the system without commiting it to ansible will be overwritten. For me it's a legitimate definition of having a desired state "instance running" that I just want to ensure the instance is available before continuing the play with the parts that follow which need the instance to be running and having the definition of the details only applied if instance does not exists. So I do not really want to fail, but just an option that tells the module to not change anything if the instance is already there and populate the results with the found instance. Of cause an instance_facts step before can be used. But it's not only quite much overhead of ansible script lines (which is anyway very much to implement sane workflows) but also avoids a call to gather-instance-facts for new instances (as the ec2_instance module is querying the same again). |
Looking at other cloud modules (vultr, cloustack, cloudscale) there is a logic to not changing a running instance if the change would require a reboot unless https://docs.ansible.com/ansible/latest/modules/vultr_server_module.html#parameters |
@resmo sensible comment, I like consistency, so I'm happy to add the |
@Shaps for "backwards compatibility" it make sense to set it to "true". |
Thank you very much for your interest in Ansible. Ansible has migrated much of the content into separate repositories to allow for more rapid, independent development. We are closing this issue/PR because this content has been moved to one or more collection repositories.
For further information, please see: |
SUMMARY
It would be fine if the filter in ec2_instance could be used to create new instance if no instance found matching filter criteria and fail otherwise without touching an already running instance.
ISSUE TYPE
COMPONENT NAME
ec2_instance
ADDITIONAL INFORMATION
The text was updated successfully, but these errors were encountered: