ansible.utils.nthhost (4.0.0) — filter

This filter returns the nth host within a network described by value.

| "added in version" 2.5.0 of ansible.utils"

Authors: Ashwini Mhatre (@amhatre)

Install collection

Install with ansible-galaxy collection install ansible.utils:==4.0.0


Add to requirements.yml

  collections:
    - name: ansible.utils
      version: 4.0.0

Description

This filter returns the nth host within a network described by value. To return the nth ip from a network, use the filter nthhost.

Nthhost also supports a negative value.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
#### examples
- name: To return the nth ip from a network, use the filter nthhost.
  debug:
    msg: "{{ '10.0.0.0/8' | ansible.utils.nthhost(305)  }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: nthhost also supports a negative value.
  debug:
    msg: "{{ '10.0.0.0/8' | ansible.utils.nthhost(-1) }}"

Inputs

    
query:
    description: nth host
    type: str

value:
    description: The network address or range to test against.
    required: true
    type: str

Outputs

data:
  description:
  - Returns nth host from network
  type: str