Skip to content
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

count field is not supported on Metal device module #124

Closed
displague opened this issue Oct 5, 2023 · 2 comments
Closed

count field is not supported on Metal device module #124

displague opened this issue Oct 5, 2023 · 2 comments
Labels
question Further information is requested

Comments

@displague
Copy link
Member

SUMMARY

The metal device module does not support the count and count_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
  • Bug Report
COMPONENT NAME
ANSIBLE VERSION

CONFIGURATION

OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS

@ctreatma
Copy link
Contributor

ctreatma commented Oct 5, 2023

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:

  • using a format other than %02d for the index
  • using an increment other than 1, e.g. "{{ count_range = range(4, 17, 4) }}" for 4, 8, 12, 16
  • iterating over a custom list such as ["controlplane", "worker", "ssh_bastion"]

@displague
Copy link
Member Author

displague commented Oct 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants