1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

test for ipaddr filter (#52088)

based upon work of mscherer

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2019-02-13 16:53:43 +05:30 committed by GitHub
parent 51270be883
commit 22bddb434a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 18 deletions

View file

@ -4,6 +4,7 @@ set -eux
# Requirements have to be installed prior to running ansible-playbook
# because plugins and requirements are loaded before the task runs
pip install jmespath
pip install jmespath netaddr
ANSIBLE_ROLES_PATH=../ ansible-playbook filters.yml -i ../../inventory -e @../../integration_config.yml "$@"

View file

@ -1,20 +1,7 @@
# test code
# (c) 2014, Michael DeHaan <michael.dehaan@gmail.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# test code for filters
# Copyright: (c) 2014, Michael DeHaan <michael.dehaan@gmail.com>
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: a dummy task to test the changed and success filters
shell: echo hi
@ -266,3 +253,16 @@
that:
- "unions|type_debug == 'list'"
- "unions|length == 4"
- name: Test ipaddr filter
assert:
that:
- "'192.168.0.1/32' | ipaddr('netmask') == '255.255.255.255'"
- "'192.168.0.1/24' | ipaddr('netmask') == '255.255.255.0'"
- "not '192.168.0.1/31' | ipaddr('broadcast')"
- "'192.168.0.1/24' | ipaddr('broadcast') == '192.168.0.255'"
- "'192.168.0.1/24' | ipaddr('prefix') == 24"
- "'192.168.0.1/24' | ipaddr('address') == '192.168.0.1'"
- "'192.168.0.1/24' | ipaddr('network') == '192.168.0.0'"
- "'fe80::dead:beef/64' | ipaddr('broadcast') == 'fe80::ffff:ffff:ffff:ffff'"
- "'::1/120' | ipaddr('netmask') == 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ff00'"