ansible.utils.multicast (4.0.0) — test

Test for a multicast IP address

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

Authors: Priyam Sahoo (@priyamsahoo)

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 plugin checks if the provided value is a valid multicast IP address

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.

- name: Check if 224.0.0.1 is a valid multicast IP address
  ansible.builtin.set_fact:
    data: "{{ '224.0.0.1' is ansible.utils.multicast }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# TASK [Check if 224.0.0.1 is a valid multicast IP address] **********************
# ok: [localhost] => {
#     "ansible_facts": {
#         "data": true
#     },
#     "changed": false
# }

- name: Check if ff02::1 is a valid multicast IP address
  ansible.builtin.set_fact:
    data: "{{ 'ff02::1' is ansible.utils.multicast }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# TASK [Check if ff02::1 is a valid multicast IP address] ***************************
# ok: [localhost] => {
#     "ansible_facts": {
#         "data": true
#     },
#     "changed": false
# }

- name: Check if 127.0.0.1 is not a valid multicast IP address
  ansible.builtin.set_fact:
    data: "{{ '127.0.0.1' is not ansible.utils.multicast }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# TASK [Check if 127.0.0.1 is not a valid multicast IP address] *********************
# ok: [localhost] => {
#     "ansible_facts": {
#         "data": true
#     },
#     "changed": false
# }

- name: Check if helloworld is not a valid multicast IP address
  ansible.builtin.set_fact:
    data: "{{ 'helloworld' is not ansible.utils.multicast }}"

Inputs

    
ip:
    description:
    - A string that represents the value against which the test is going to be performed
    - 'For example: C(224.0.0.1) or C(127.0.0.1)'
    required: true
    type: str

Outputs

data:
  description:
  - If jinja test satisfies plugin expression C(true)
  - If jinja test does not satisfy plugin expression C(false)