mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 03:00:23 -07:00
Interfaces file spaces fix (#6131)
* interfaces_file: added test case for #6120
* interfaces_file: reverted code to #fafabed
* interfaces_file: added changelog fragment
* interfaces_file: added missing licenses
* interfaces_file: improved test coverage
* interfaces_file: fixed retrieving option values
* Update plugins/modules/interfaces_file.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/modules/interfaces_file.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update tests/unit/plugins/modules/interfaces_file/test_interfaces_file.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/modules/interfaces_file.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/modules/interfaces_file.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/modules/interfaces_file.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/modules/interfaces_file.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/modules/interfaces_file.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update plugins/modules/interfaces_file.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update tests/unit/plugins/modules/interfaces_file/test_interfaces_file.py
Co-authored-by: Felix Fontein <felix@fontein.de>
* interfaces_file: spacing fix
---------
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
6b8a1cd8e6
commit
abcba9dbbe
93 changed files with 995 additions and 63 deletions
|
@ -0,0 +1,8 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
||||
mtu 1500
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,8 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
||||
mtu 1500
|
|
@ -0,0 +1,8 @@
|
|||
[0] fail_json message: Error: interface aggi not found
|
||||
options:
|
||||
{
|
||||
"iface": "aggi",
|
||||
"option": "up",
|
||||
"state": "present",
|
||||
"value": "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,8 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
||||
mtu 1500
|
|
@ -0,0 +1,17 @@
|
|||
[0] fail_json message: Error: interface aggi not found
|
||||
options:
|
||||
{
|
||||
"iface": "aggi",
|
||||
"option": "up",
|
||||
"state": "present",
|
||||
"value": "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi"
|
||||
}
|
||||
=====
|
||||
[1] fail_json message: Error: interface aggi not found
|
||||
options:
|
||||
{
|
||||
"iface": "aggi",
|
||||
"option": "up",
|
||||
"state": "present",
|
||||
"value": "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,8 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
||||
mtu 1500
|
|
@ -0,0 +1,17 @@
|
|||
[0] fail_json message: Error: interface aggi not found
|
||||
options:
|
||||
{
|
||||
"iface": "aggi",
|
||||
"option": "up",
|
||||
"state": "present",
|
||||
"value": "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi"
|
||||
}
|
||||
=====
|
||||
[1] fail_json message: Error: interface aggi not found
|
||||
options:
|
||||
{
|
||||
"iface": "aggi",
|
||||
"option": "up",
|
||||
"state": "absent",
|
||||
"value": null
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,8 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
||||
mtu 1500
|
|
@ -0,0 +1,17 @@
|
|||
[0] fail_json message: Error: interface aggi not found
|
||||
options:
|
||||
{
|
||||
"iface": "aggi",
|
||||
"option": "up",
|
||||
"state": "absent",
|
||||
"value": null
|
||||
}
|
||||
=====
|
||||
[1] fail_json message: Error: interface aggi not found
|
||||
options:
|
||||
{
|
||||
"iface": "aggi",
|
||||
"option": "up",
|
||||
"state": "present",
|
||||
"value": "route add -net 224.0.0.0 netmask 240.0.0.0 dev aggi"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,8 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 192.168.0.42
|
||||
netmask 255.255.255.0
|
||||
mtu 1500
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,9 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
||||
mtu 1500
|
||||
post-up XXXX_ipv4
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,9 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
||||
mtu 1500
|
||||
pre-up XXXX_ipv4
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,8 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
||||
mtu 1500
|
|
@ -0,0 +1,9 @@
|
|||
fail_json message: Error: interface eth0 not found
|
||||
options:
|
||||
{
|
||||
"address_family": "inet6",
|
||||
"iface": "eth0",
|
||||
"option": "address",
|
||||
"state": "present",
|
||||
"value": "fc00::42"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,8 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
||||
mtu 1500
|
|
@ -0,0 +1,9 @@
|
|||
fail_json message: Error: interface eth0 not found
|
||||
options:
|
||||
{
|
||||
"address_family": "inet6",
|
||||
"iface": "eth0",
|
||||
"option": "post-up",
|
||||
"state": "present",
|
||||
"value": "XXXX_ipv6"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,8 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
||||
mtu 1500
|
|
@ -0,0 +1,9 @@
|
|||
fail_json message: Error: interface eth0 not found
|
||||
options:
|
||||
{
|
||||
"address_family": "inet6",
|
||||
"iface": "eth0",
|
||||
"option": "pre-up",
|
||||
"state": "present",
|
||||
"value": "XXXX_ipv6"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,8 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
||||
mtu 1500
|
|
@ -0,0 +1,8 @@
|
|||
fail_json message: Error: interface eth1 not found
|
||||
options:
|
||||
{
|
||||
"iface": "eth1",
|
||||
"option": "method",
|
||||
"state": "present",
|
||||
"value": "dhcp"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,7 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,8 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
||||
mtu 1350
|
|
@ -0,0 +1,8 @@
|
|||
[0] fail_json message: Error: interface aggi not found
|
||||
options:
|
||||
{
|
||||
"iface": "aggi",
|
||||
"option": "mtu",
|
||||
"state": "present",
|
||||
"value": "1350"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,8 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
||||
mtu 1500
|
|
@ -0,0 +1,8 @@
|
|||
[0] fail_json message: Error: interface aggi not found
|
||||
options:
|
||||
{
|
||||
"iface": "aggi",
|
||||
"option": "slaves",
|
||||
"state": "present",
|
||||
"value": "int1 int3"
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"eth0": {
|
||||
"address": "10.0.0.1",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "static",
|
||||
"mtu": "1500",
|
||||
"netmask": "255.255.255.0",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
},
|
||||
"lo": {
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"method": "loopback",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -0,0 +1,8 @@
|
|||
iface lo inet loopback
|
||||
auto lo
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 10.0.0.1
|
||||
netmask 255.255.255.0
|
||||
mtu 1500
|
|
@ -0,0 +1,3 @@
|
|||
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -44,6 +44,8 @@ golden_output_path = os.path.join(os.path.dirname(__file__), 'interfaces_file_fi
|
|||
|
||||
|
||||
class TestInterfacesFileModule(unittest.TestCase):
|
||||
unittest.TestCase.maxDiff = None
|
||||
|
||||
def getTestFiles(self, include_filter=None, exclude_filter=None):
|
||||
flist = next(os.walk(fixture_path))[2]
|
||||
flist = [file for file in flist if not file.endswith('.license')]
|
||||
|
@ -73,10 +75,22 @@ class TestInterfacesFileModule(unittest.TestCase):
|
|||
def compareInterfacesToFile(self, ifaces, path, testname=None):
|
||||
if not testname:
|
||||
testname = "%s.%s.json" % (path, inspect.stack()[1][3])
|
||||
self.compareStringWithFile(json.dumps(ifaces, sort_keys=True, indent=4, separators=(',', ': ')), testname)
|
||||
|
||||
testfilepath = os.path.join(golden_output_path, testname)
|
||||
string = json.dumps(ifaces, sort_keys=True, indent=4, separators=(',', ': '))
|
||||
if string and not string.endswith('\n'):
|
||||
string += '\n'
|
||||
goldenstring = string
|
||||
goldenData = ifaces
|
||||
if not os.path.isfile(testfilepath):
|
||||
with io.open(testfilepath, 'wb') as f:
|
||||
f.write(string.encode())
|
||||
else:
|
||||
with open(testfilepath, 'r') as goldenfile:
|
||||
goldenData = json.load(goldenfile)
|
||||
self.assertEqual(goldenData, ifaces)
|
||||
|
||||
def compareStringWithFile(self, string, path):
|
||||
# self.assertEqual("","_",msg=path)
|
||||
testfilepath = os.path.join(golden_output_path, path)
|
||||
if string and not string.endswith('\n'):
|
||||
string += '\n'
|
||||
|
@ -89,7 +103,7 @@ class TestInterfacesFileModule(unittest.TestCase):
|
|||
with open(testfilepath, 'r') as goldenfile:
|
||||
goldenstring = goldenfile.read()
|
||||
goldenfile.close()
|
||||
self.assertEqual(string, goldenstring)
|
||||
self.assertEqual(goldenstring, string)
|
||||
|
||||
def test_no_changes(self):
|
||||
for testfile in self.getTestFiles():
|
||||
|
@ -224,7 +238,9 @@ class TestInterfacesFileModule(unittest.TestCase):
|
|||
|
||||
self.compareInterfacesLinesToFile(lines, testfile, "%s_%s" % (testfile, testname))
|
||||
self.compareInterfacesToFile(ifaces, testfile, "%s_%s.json" % (testfile, testname))
|
||||
self.compareFileToBackup(path, backupp)
|
||||
if testfile not in ["no_leading_spaces"]:
|
||||
# skip if eth0 has MTU value
|
||||
self.compareFileToBackup(path, backupp)
|
||||
|
||||
def test_change_method(self):
|
||||
testcases = {
|
||||
|
@ -269,6 +285,195 @@ class TestInterfacesFileModule(unittest.TestCase):
|
|||
# Restore backup
|
||||
move(backupp, path)
|
||||
|
||||
def test_getValueFromLine(self):
|
||||
testcases = [
|
||||
{
|
||||
"line": " address 1.2.3.5",
|
||||
"value": "1.2.3.5",
|
||||
}
|
||||
]
|
||||
for testcase in testcases:
|
||||
value = interfaces_file.getValueFromLine(testcase["line"])
|
||||
self.assertEqual(testcase["value"], value)
|
||||
|
||||
def test_get_interface_options(self):
|
||||
testcases = {
|
||||
"basic": {
|
||||
"iface_lines": [
|
||||
{
|
||||
"address_family": "inet",
|
||||
"iface": "eno1",
|
||||
"line": "iface eno1 inet static",
|
||||
"line_type": "iface",
|
||||
"params": {
|
||||
"address": "",
|
||||
"address_family": "inet",
|
||||
"down": [],
|
||||
"gateway": "",
|
||||
"method": "static",
|
||||
"netmask": "",
|
||||
"post-up": [],
|
||||
"pre-up": [],
|
||||
"up": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"address_family": "inet",
|
||||
"iface": "eno1",
|
||||
"line": " address 1.2.3.5",
|
||||
"line_type": "option",
|
||||
"option": "address",
|
||||
"value": "1.2.3.5"
|
||||
},
|
||||
{
|
||||
"address_family": "inet",
|
||||
"iface": "eno1",
|
||||
"line": " netmask 255.255.255.0",
|
||||
"line_type": "option",
|
||||
"option": "netmask",
|
||||
"value": "255.255.255.0"
|
||||
},
|
||||
{
|
||||
"address_family": "inet",
|
||||
"iface": "eno1",
|
||||
"line": " gateway 1.2.3.1",
|
||||
"line_type": "option",
|
||||
"option": "gateway",
|
||||
"value": "1.2.3.1"
|
||||
}
|
||||
],
|
||||
"iface_options": [
|
||||
{
|
||||
"address_family": "inet",
|
||||
"iface": "eno1",
|
||||
"line": " address 1.2.3.5",
|
||||
"line_type": "option",
|
||||
"option": "address",
|
||||
"value": "1.2.3.5"
|
||||
},
|
||||
{
|
||||
"address_family": "inet",
|
||||
"iface": "eno1",
|
||||
"line": " netmask 255.255.255.0",
|
||||
"line_type": "option",
|
||||
"option": "netmask",
|
||||
"value": "255.255.255.0"
|
||||
},
|
||||
{
|
||||
"address_family": "inet",
|
||||
"iface": "eno1",
|
||||
"line": " gateway 1.2.3.1",
|
||||
"line_type": "option",
|
||||
"option": "gateway",
|
||||
"value": "1.2.3.1"
|
||||
}
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
for testname in testcases.keys():
|
||||
iface_options = interfaces_file.get_interface_options(testcases[testname]["iface_lines"])
|
||||
self.assertEqual(testcases[testname]["iface_options"], iface_options)
|
||||
|
||||
def test_get_interface_options(self):
|
||||
testcases = {
|
||||
"select address": {
|
||||
"iface_options": [
|
||||
{
|
||||
"address_family": "inet",
|
||||
"iface": "eno1",
|
||||
"line": " address 1.2.3.5",
|
||||
"line_type": "option",
|
||||
"option": "address",
|
||||
"value": "1.2.3.5"
|
||||
},
|
||||
{
|
||||
"address_family": "inet",
|
||||
"iface": "eno1",
|
||||
"line": " netmask 255.255.255.0",
|
||||
"line_type": "option",
|
||||
"option": "netmask",
|
||||
"value": "255.255.255.0"
|
||||
},
|
||||
{
|
||||
"address_family": "inet",
|
||||
"iface": "eno1",
|
||||
"line": " gateway 1.2.3.1",
|
||||
"line_type": "option",
|
||||
"option": "gateway",
|
||||
"value": "1.2.3.1"
|
||||
}
|
||||
],
|
||||
"target_options": [
|
||||
{
|
||||
"address_family": "inet",
|
||||
"iface": "eno1",
|
||||
"line": " address 1.2.3.5",
|
||||
"line_type": "option",
|
||||
"option": "address",
|
||||
"value": "1.2.3.5"
|
||||
}
|
||||
],
|
||||
"option": "address"
|
||||
},
|
||||
}
|
||||
|
||||
for testname in testcases.keys():
|
||||
target_options = interfaces_file.get_target_options(testcases[testname]["iface_options"], testcases[testname]["option"])
|
||||
self.assertEqual(testcases[testname]["target_options"], target_options)
|
||||
|
||||
def test_update_existing_option_line(self):
|
||||
testcases = {
|
||||
"update address": {
|
||||
"target_option": {
|
||||
"address_family": "inet",
|
||||
"iface": "eno1",
|
||||
"line": " address 1.2.3.5",
|
||||
"line_type": "option",
|
||||
"option": "address",
|
||||
"value": "1.2.3.5"
|
||||
},
|
||||
"value": "1.2.3.4",
|
||||
"result": " address 1.2.3.4",
|
||||
},
|
||||
}
|
||||
|
||||
for testname in testcases.keys():
|
||||
updated = interfaces_file.update_existing_option_line(testcases[testname]["target_option"], testcases[testname]["value"])
|
||||
self.assertEqual(testcases[testname]["result"], updated)
|
||||
|
||||
def test_predefined(self):
|
||||
testcases = {
|
||||
"idempotency": {
|
||||
"source_lines": [
|
||||
"iface eno1 inet static",
|
||||
" address 1.2.3.5",
|
||||
" netmask 255.255.255.0",
|
||||
" gateway 1.2.3.1",
|
||||
],
|
||||
"input": {
|
||||
"iface": "eno1",
|
||||
"option": "address",
|
||||
"value": "1.2.3.5",
|
||||
'state': 'present',
|
||||
},
|
||||
"result_lines": [
|
||||
"iface eno1 inet static",
|
||||
" address 1.2.3.5",
|
||||
" netmask 255.255.255.0",
|
||||
" gateway 1.2.3.1",
|
||||
],
|
||||
"changed": False,
|
||||
},
|
||||
}
|
||||
|
||||
for testname in testcases.keys():
|
||||
lines, ifaces = interfaces_file.read_interfaces_lines(module, testcases[testname]["source_lines"])
|
||||
changed, lines = interfaces_file.set_interface_option(module, lines, testcases[testname]["input"]['iface'], testcases[testname]["input"]['option'],
|
||||
testcases[testname]["input"]['value'], testcases[testname]["input"]['state'])
|
||||
self.assertEqual(testcases[testname]["result_lines"], [d['line'] for d in lines if 'line' in d])
|
||||
assert testcases[testname]['changed'] == changed
|
||||
|
||||
def test_inet_inet6(self):
|
||||
testcases = {
|
||||
"change_ipv4": [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue