ansible.utils.previous_nth_usable (4.0.0) — filter

This filter returns the previous nth usable ip 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 previous nth usable ip within a network described by value.

Use previous_nth_usable to find the previous nth usable IP address in relation to another within a range

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
#### examples
- name: previous_nth_usable returns the second usable IP address for the given IP range
  debug:
    msg: "{{ '192.168.122.10/24' | ansible.utils.previous_nth_usable(2) }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: If there is no usable address, it returns an empty string.
  debug:
    msg: "{{ '192.168.122.1/24' | ansible.utils.previous_nth_usable(2) }}"

Inputs

    
value:
    description:
    - subnets or individual address input for previous_nth_usable plugin
    required: true
    type: str

offset:
    description:
    - index value
    - previous nth usable IP address
    type: int

Outputs

data:
  description:
  - Returns the previous nth usable ip within a network described by value.
  type: str