About salt grains.ipv4 get the IP list is not all ip as network.ipaddrs
Description of Issue/Question
grains.ipv4 return the ip is less the the interface actually configed , but through module network.interfaces get the all IP configed
on test node , output of ip addr show is :
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 52:54:00:da:a7:10 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global noprefixroute dynamic eth0
valid_lft 81065sec preferred_lft 81065sec
inet6 fe80::5054:ff:feda:a710/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:de:c0:09 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.11/24 brd 192.168.2.255 scope global noprefixroute eth1
valid_lft forever preferred_lft forever
inet 192.168.3.11/24 scope global eth1
valid_lft forever preferred_lft forever
inet 192.168.4.11/24 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fede:c009/64 scope link
valid_lft forever preferred_lft forever
and ifconfig output is :
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::5054:ff:feda:a710 prefixlen 64 scopeid 0x20<link>
ether 52:54:00:da:a7:10 txqueuelen 1000 (Ethernet)
RX packets 2789 bytes 260675 (254.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 2000 bytes 197898 (193.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.11 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 fe80::a00:27ff:fede:c009 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:de:c0:09 txqueuelen 1000 (Ethernet)
RX packets 170 bytes 17520 (17.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 171 bytes 19815 (19.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 636 bytes 64352 (62.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 636 bytes 64352 (62.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
and
[root@master1 ~]# salt master1.example.net grains.item ipv4
master1.example.net:
----------
ipv4:
- 10.0.2.15
- 127.0.0.1
- 192.168.2.11
And
[root@master1 ~]# salt master1.example.net network.ipaddrs
master1.example.net:
- 10.0.2.15
- 192.168.2.11
- 192.168.3.11
- 192.168.4.11
And what's the reasons?
Steps to Reproduce Issue
I use salt to collect all the nodes information , through salt grains and some basic modules
Versions Report
Salt Version:
Salt: 2018.3.0
Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.7.2
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.28.2
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.1
mysql-python: 1.2.5
pycparser: Not Installed
pycrypto: 3.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.5 (default, Apr 11 2018, 07:36:10)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: centos 7.5.1804 Core
locale: UTF-8
machine: x86_64
release: 3.10.0-862.3.2.el7.x86_64
system: Linux
version: CentOS Linux 7.5.1804 Core
@WangWenchao Thanks for the report. Appears to be a bug. The grain should contain all the ipv4 addresses that the system is configured with.
@WangWenchao Looking closer at the information above you appear to be running the two commands against two different machines. By default, network.ipaddrs does not include the loopback device when it is called to populate the ipv4 grains value, it includes the parameter (include_loopback=True) to include the loopback device. If you run both commands against the same machine, including include_loopback=True for the network.ipaddrs command, are the results as expected?
thank your point out . Here is the different of the output
[root@master1 ~]# salt master1.example.net grains.item ipv4
master1.example.net:
----------
ipv4:
- 10.0.2.15
- 127.0.0.1
- 192.168.2.11
[root@master1 ~]# salt master1.example.net network.ipaddrs
master1.example.net:
- 10.0.2.15
- 192.168.2.11
- 192.168.3.11
- 192.168.4.11
That makes more sense. Looks like it's not picking up the additional ip addresses.
@WangWenchao So far I haven't been able to duplicate this one, the ipv4 grains is populated by the network.ipaddrs module so if the IPs are showing up there they should be showing up in the grain. How are you adding in the additional IP addresses?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.