dist_sort

dist_sort

Synopsis

Deterministically sort a list to distribute the elements in the list evenly. Based on external values such as host or static modifier. Returns a string as named key sorted_list.

  • This module returns a list of servers uniquely sorted based on a index from a look up value location within a group. The group should be an existing Ansible inventory group. This will module returns the sorted list as a delimited string.

Examples

- dist_sort:
    value_to_lookup: "Hostname-in-ansible-group_name"
    ref_list: "{{ groups['group_name'] }}"
    src_list: "Server1,Server2,Server3"
  register: test_var

# With a pre-set delimiter
- dist_sort:
    value_to_lookup: "Hostname-in-ansible-group_name"
    ref_list: "{{ groups['group_name'] }}"
    src_list: "Server1|Server2|Server3"
    delimiter: '|'
  register: test_var

# With a set modifier
- dist_sort:
    value_to_lookup: "Hostname-in-ansible-group_name"
    ref_list: "{{ groups['group_name'] }}"
    src_list: "Server1#Server2#Server3"
    delimiter: '#'
    sort_modifier: 5
  register: test_var
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.