Closed displague closed 9 months ago
This feature is better accomplished using built-in loop
or with_sequence
features of Ansible. The following configs should be roughly equivalent, but we should test these out before putting them in a migration guide:
# ansible-collection-metal
equinix.metal.device:
# ... omitting other properties to focus on the change in this issue
hostnames: "{{ foo_var }}-{{ bar_var }}-%02d"
count: "10"
# ansible-collection-equinix using loop
equinix.cloud.metal_device:
# ... omitting other properties to focus on the change in this issue
hostname: "{{ foo_var }}-{{ bar_var }}-{{ '%02d' | format(item) }}"
loop: "{{ range(1, 11, 1) | list }}"
# ansible-collection-equinix using with_sequence
equinix.cloud.metal_device:
# ... omitting other properties to focus on the change in this issue
hostname: "{{ foo_var }}-{{ bar_var }}-{{ item }}"
with_sequence: start=1 end=10 stride=1 format=%02d
Using loop
, with_sequence
, and other Ansible looping constructs leads to more idiomatic Ansible playbooks and brings in options that were not possible by only using count
in ansible-collection-metal
:
%02d
for the index"{{ count_range = range(4, 17, 4) }}"
for 4, 8, 12, 16
["controlplane", "worker", "ssh_bastion"]
Given the alternatives above, I think it is fair to close this issue. count
and count_offset
are not present in the Metal POST /projects/{id}/devices
arguments and this collection takes the position of staying close to the API without adding magic to modules where there is a 1:1 relationship with API resources.
We have the following issues open which may find alternative ways to redress this:
If you feel there are reasons to keep this issue open, please comment so.
SUMMARY
The metal device module does not support the
count
andcount_offset
features that were present in the Packet and Metal collections.Is this going to be implemented in this collection? If not, what is the alternative way to accomplish this?
ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS