Closed timdiggins closed 12 months ago
Hi @timdiggins
In terms of idempotency, enable_vpc/enable_vpc2
is tricky for the following reasons:
Therefore, our suggestion is to define a VPC as follows:
- name: Ensure a VPC is present
vultr.cloud.vpc:
description: default
subnet: 10.99.1.0
subnet_mask: 24
region: ams
- name: Create an instance using OS
vultr.cloud.instance:
label: web1
hostname: my-hostname
os: Debian 12 x64 (bookworm)
firewall_group: my firewall group
plan: vc2-1c-2gb
ssh_keys:
- my ssh key
vpcs:
- default
region: ams
Would this be an option?
P.s. As an inspiration, you might want to look at https://github.com/ngine-io/ansible-vultr-demo
@resmo - thanks that's very helpful!
I can see your points, and this does the same thing with better idempotency. But also by adapting the name to be specific to the cluster I'm setting up then have isolation between eg. staging and production clusters (and more straightforward destruction if needed - not sure if one should clean up the vpc for temporary clusters (e.g. staging), but i guess best practice)
(Closing this - useful to have around as docs)
@resmo sorry one more question: which parameters governs identity (and thus idempotency) in the vpc module? Is it description
+ region
?
It might help to have some documentation of this in the vpc module. (particularly asdescription
(rather than name
) doesn't sound like a label for an identity parameter)
it's description
(or name
as it is an alias https://docs.ansible.com/ansible/latest/collections/vultr/cloud/vpc_module.html#parameter-description) only. But I see it would make sense to probably also take the region into account. This would allow to have similar "names" in many regions.
Closing this as #98 has been merged.
Is your feature request related to a problem? Please describe.
I'm migrating from old "vultr_server" (https://docs.ansible.com/ansible/2.8/modules/vultr_server_module.html) ansible (late to the party) and looking for an equivalent to
private_network_enabled: true
This is mostly provided by api v2
enable_vpc
orenable_vpc2
(https://www.vultr.com/api/#tag/instances/operation/create-instance)Describe the solution you'd like
A simple way to setup default vpc on creating an instance and use
enable_vpc
orenable_vpc2
on the apiDescribe alternatives you've considered
Manual set up of vpcs - however I just need one default vpc (seems like the simplest use case) and this is what the api provides