Re: Found out all of the nics cards on a system
Jerome Verleyen <[email protected]> Wed, 20 Nov 2024 16:05:04 -0600
| Newsgroups | gmane.comp.sysutils.cfengine.general |
|---|---|
| Message-ID | <[email protected]> |
Le 19/11/2024 à 12:51, 'Nick Anderson' via help-cfengine a écrit :
>
> What i need now is to get the list of all the networds cards
> present in one system, to configure specific one on an ipv4
> network. I do use the sys.interfaces variables. But this get me
> back uniquely the configured interfaces, not alla of then.
>
> Do any of the sys vars contain what you are looking for (|cf-promises
> --show-vars|)
>
> Perhaps |sys.interfaces_data|?
>
> bundle agent __main__
> {
> vars:
> "sys_interfaces_data_keys"
> slist => getindices( "sys.interfaces_data" );
>
> reports:
> "$(sys_interfaces_data_keys)";
> }
> R: lo
> R: wlp0s20f3
> R: virbr0
> R: br-a7d465b9949b
> R: docker0
> R: enx0892048803e7
> R: enx5cff35c6864b
> R: vboxnet0
> R: tun0
Dear Nick and others
Thank's for answer me so quickly. I do some test to check out your code.
You're right in using cf-promises command to get back this variables.
I do a bundle to test it, and have some good results:
bundle agent network
{
vars:
"sys_interfaces" slist => getindices("sys.interfaces");
"sys_interfaces_data_keys" slist => getindices(
"sys.interfaces_data" );
"sys_ipv4" slist => getindices("sys.ipv4");
reports:
any::
"Value of sys_interfaces $(sys_interfaces)";
"Value of sys_interfaces_data $(sys_interfaces_data_keys)";
"value of sys_ipv4: $(sys_ipv4)";
}
That get me this report:
R: Value of sys_interfaces_data lo
R: Value of sys_interfaces_data enp1s0
R: Value of sys_interfaces_data enp7s0
R: Value of sys_interfaces_data enp8s0
R: Value of sys_interfaces_data virbr0
R: value of sys_ipv4: enp8s0
R: value of sys_ipv4: lo
R: value of sys_ipv4: enp7s0
R: value of sys_ipv4: virbr0
R: value of sys_ipv4: enp1s0
So, "sys.interfaces_data" is the good variable. But i've got an issue
that i could no explain: Why could i no get the list of the
sys.interfaces name? With the variable "sys_interfaces", I've get
anything, as show before.
But if i wirte directly in report as this:
reports:
any::
"Value of sys_interfaces $(sys.interfaces)";
I get back this report:
R: Value of sys_interfaces enp1s0
R: Value of sys_interfaces enp7s0
R: Value of sys_interfaces enp8s0
R: Value of sys_interfaces virbr0
I could not understand why the variable definition of sys_interfaces get
back a null list...
Hope that someone could help me.
Regards
--
-- Jérôme
Les jeunes gens voudraient être fidèles et ne le sont pas.
Les vieux voudraient être infidèles et ne le peuvent plus.
(Oscar Wilde)
--
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/help-cfengine/f24823e8-919b-4820-b28f-236d67543391%40ibt.unam.mx.