Re: [ansible-project] Re: gather factCisco Catalyst 9300 regarding l2_interfaces

2022-02-07 Thread L. Jankok
Thank you Sagar!
Much appreciated.

Op ma 7 feb. 2022 om 12:42 schreef Sagar Paul :

> Hey Lucio,
>
> The scope of the l2_interfaces module depends on the command `show
> running-config | section ^interface` the facts are generated with the
> config op from the specific command. You may want to raise a feature
> request here 
> for an update on the scope of the module.
>
> Regards,
> Sagar Paul
> *E - sagp...@redhat.com  GH - KB-perByte*
>
>
>
> On Friday, February 4, 2022 at 8:14:51 PM UTC+5:30 lja...@gmail.com wrote:
>
>> Hi Thom,
>>
>> Thank you for your time and your interest, truly appreciated.
>> With interface templates you will not see the vlans or other port
>> configurations on the interface when running show run int interface-name.
>> To see the applied configuration on the interface the command "show
>> derived-config" is needed.
>>
>> An example:
>>
>> *With a normal show run you will not see all the configs applied to the
>> switchport*
>>
>> testswitch01#show run interface g1/0/1
>>
>> interface GigabitEthernet1/0/1
>>
>> no logging event link-status
>>
>> no cdp enable
>>
>> no snmp trap link-status
>>
>> source template ENDUSER
>>
>> service-policy input PM_IN_MARK
>>
>> end
>>
>>
>> *To see all the configs applied to the switchport, do the following*
>>
>>
>> testswitch01#*show derived-config interface g1/0/1*
>>
>> Building configuration...
>>
>>
>>
>> Derived configuration : 270 bytes
>>
>> !
>>
>> interface GigabitEthernet1/0/1
>>
>> description ENDUSER-WORKSTATION
>>
>> switchport access vlan 990
>>
>> switchport mode access
>>
>> no logging event link-status
>>
>> load-interval 30
>>
>> no cdp enable
>>
>> no snmp trap link-status
>>
>> spanning-tree portfast
>>
>> service-policy input PM_IN_MARK
>>
>> end
>>
>> Op vr 4 feb. 2022 om 13:59 schreef Sagar Paul :
>>
>>> Hey Lucio,
>>>
>>> Can you share some details, I am not sure if I am getting it right.
>>>
>>> Regards,
>>> Sagar Paul
>>> *E - sag...@redhat.com  GH - KB-perByte*
>>> On Friday, February 4, 2022 at 5:53:53 PM UTC+5:30 lja...@gmail.com
>>> wrote:
>>>
 Hi Saga,

 Actually there is.

 The configuration is being applied using source templates.

 Regards,

 Lucio Jankok

 Op vr 4 feb. 2022 om 11:01 schreef Sagar Paul :

>
> Hey Lucio,
> as I see in the config that you have shared, there is no switchport or
> vlan data to parse as per the current scope of the module.
> Note -
> the interface data as shared in the above config is
> ```
> interface GigabitEthernet0/0
> vrf forwarding Mgmt-vrf
> no ip address
> shutdown
> negotiation auto
> !
> interface GigabitEthernet1/0/1
> no logging event link-status
> no cdp enable
> no snmp trap link-status
> source template redacted
> service-policy input redacted
> !
> interface GigabitEthernet1/0/2
> no logging event link-status
> shutdown
> no cdp enable
> no snmp trap link-status
> source template redacted
> service-policy input redacted
> !
> !
> interface GigabitEthernet1/0/24
> shutdown
> !
> interface GigabitEthernet1/1/1
> !
> interface GigabitEthernet1/1/2
> !
> interface GigabitEthernet1/1/3
> !
> interface GigabitEthernet1/1/4 ``` the module is supposed to generate
> blank facts for the device. Regards, Sagar Paul
> *E - sag...@redhat.com GH - KB-perByte*
>
> On Tuesday, February 1, 2022 at 9:14:29 PM UTC+5:30 lja...@gmail.com
> wrote:
>
>> Hi Sagar,
>>
>> The following is the case:
>>
>> *With the following platform I have no issues*
>>
>> platform: cisco WS-3850-24S
>> net_iostype: IOS-XE
>> net_version: 16.06.05
>>
>> output:
>> net_interfaces - show me interface configuration per interface
>> net_neighbors - shows me Mac address etc for all connected devices
>> l2_interfaces - shows me interface name, switchport mode and access
>> vlan
>>
>> ---
>>
>> *With the 9300 I don't get the complete l2_interfaces output*
>>
>> *platform: 9300-24p*
>> *net_iostype: IOS-XE*
>> *net_version: 17.03.03*
>>
>> net_interfaces - show me interface configuration per interface
>> net_neighbors - shows me Mac address etc for all connected devices
>> l2_interfaces - shows me only interface name. *missing switch port
>> mode and access vlan*
>>
>> 
>>
>> *Here is the redacted config for the 9300*
>>
>> Building configuration...
>>
>>
>>
>> Current configuration : 30751 bytes
>>
>> !
>>
>> !
>>
>> version 17.3
>>
>> service tcp-keepalives-in
>>
>> service timestamps debug datetime msec localtime show-timezone
>>
>> service timestamps log datetime msec localtime 

Re: [ansible-project] Adding if statement inside a task

2022-02-07 Thread Dick Visser
On Mon, 7 Feb 2022 at 15:29, dudu.c...@gmail.com 
wrote:

> Hi
> I have the following playbook.
> In the environment.yml file I have a parameter "tls=true"
>
> In the below task , In tghe URL I would put *https* if tls=true and *http*
> if false.
>
Try:

url: "http{{ 's' if tls else '' }}://{{ server.hostname }}.{{
domain }}:/api//{{ cluster_name }}"


-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwNedC_JpN-VTfx0kDERgABWwOsm4Yr5wyh2Xi-BgpuYwQ%40mail.gmail.com.


Re: [ansible-project] Adding if statement inside a task

2022-02-07 Thread Rilindo Foster
Hi there!

What was the problem that you are trying to solve? I don’t see an actual 
question that we can answer.

> On Feb 7, 2022, at 8:29 AM, dudu.c...@gmail.com  
> wrote:
> 
> Hi
> I have the following playbook.  
> In the environment.yml file I have a parameter "tls=true"
> 
> In the below task , In tghe URL I would put https if tls=true and http if 
> false.
>  
> - hosts: manager
>   vars_files:
> - ./environment.yml
>   tasks:
> 
>  - name: test - check connectivity to  API
> get_url:
> url: http://{{ server.hostname }}.{{ domain }}:/api//{{ 
> cluster_name }}
> dest: /tmp/
> mode: 0777
> force: yes
> url_username: "{{ username }}"
> url_password: "{{ password }}"
> validate_certs: no
> register: msg
> ignore_errors: true
> 
> Thanks 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to ansible-project+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/d87db8f5-2d22-4d65-8d16-efa6a3041012n%40googlegroups.com
>  
> .

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8D864036-7A90-4282-9EBC-E45F085A0AB8%40gmail.com.


[ansible-project] Adding if statement inside a task

2022-02-07 Thread dudu.c...@gmail.com
Hi
I have the following playbook.  
In the environment.yml file I have a parameter "tls=true"

In the below task , In tghe URL I would put *https* if tls=true and *http* 
if false.
 
- hosts: manager
  vars_files:
- ./environment.yml
  tasks:

 - name: test - check connectivity to  API
get_url:
url: http://{{ server.hostname }}.{{ domain }}:/api//{{ 
cluster_name }}
dest: /tmp/
mode: 0777
force: yes
url_username: "{{ username }}"
url_password: "{{ password }}"
validate_certs: no
register: msg
ignore_errors: true

Thanks 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d87db8f5-2d22-4d65-8d16-efa6a3041012n%40googlegroups.com.


Re: [ansible-project] Re: gather factCisco Catalyst 9300 regarding l2_interfaces

2022-02-07 Thread Sagar Paul
Hey Lucio,

The scope of the l2_interfaces module depends on the command `show 
running-config | section ^interface` the facts are generated with the 
config op from the specific command. You may want to raise a feature 
request here  for 
an update on the scope of the module.

Regards,
Sagar Paul 
*E - sagp...@redhat.com  GH - KB-perByte*



On Friday, February 4, 2022 at 8:14:51 PM UTC+5:30 lja...@gmail.com wrote:

> Hi Thom,
>
> Thank you for your time and your interest, truly appreciated.
> With interface templates you will not see the vlans or other port 
> configurations on the interface when running show run int interface-name.
> To see the applied configuration on the interface the command "show 
> derived-config" is needed.
>
> An example:
>
> *With a normal show run you will not see all the configs applied to the 
> switchport*
>
> testswitch01#show run interface g1/0/1
>
> interface GigabitEthernet1/0/1
>
> no logging event link-status
>
> no cdp enable
>
> no snmp trap link-status
>
> source template ENDUSER
>
> service-policy input PM_IN_MARK
>
> end
>
>
> *To see all the configs applied to the switchport, do the following*
>
>
> testswitch01#*show derived-config interface g1/0/1*
>
> Building configuration...
>
>  
>
> Derived configuration : 270 bytes
>
> !
>
> interface GigabitEthernet1/0/1
>
> description ENDUSER-WORKSTATION
>
> switchport access vlan 990
>
> switchport mode access
>
> no logging event link-status
>
> load-interval 30
>
> no cdp enable
>
> no snmp trap link-status
>
> spanning-tree portfast
>
> service-policy input PM_IN_MARK
>
> end
>
> Op vr 4 feb. 2022 om 13:59 schreef Sagar Paul :
>
>> Hey Lucio,
>>
>> Can you share some details, I am not sure if I am getting it right.
>>
>> Regards,
>> Sagar Paul 
>> *E - sag...@redhat.com  GH - KB-perByte*
>> On Friday, February 4, 2022 at 5:53:53 PM UTC+5:30 lja...@gmail.com 
>> wrote:
>>
>>> Hi Saga,
>>>
>>> Actually there is.
>>>
>>> The configuration is being applied using source templates.
>>>
>>> Regards,
>>>
>>> Lucio Jankok
>>>
>>> Op vr 4 feb. 2022 om 11:01 schreef Sagar Paul :
>>>

 Hey Lucio,
 as I see in the config that you have shared, there is no switchport or 
 vlan data to parse as per the current scope of the module.
 Note - 
 the interface data as shared in the above config is 
 ```
 interface GigabitEthernet0/0
 vrf forwarding Mgmt-vrf
 no ip address
 shutdown
 negotiation auto
 !
 interface GigabitEthernet1/0/1
 no logging event link-status
 no cdp enable
 no snmp trap link-status
 source template redacted
 service-policy input redacted
 !
 interface GigabitEthernet1/0/2
 no logging event link-status
 shutdown
 no cdp enable
 no snmp trap link-status
 source template redacted
 service-policy input redacted
 !
 !
 interface GigabitEthernet1/0/24
 shutdown
 !
 interface GigabitEthernet1/1/1
 !
 interface GigabitEthernet1/1/2
 !
 interface GigabitEthernet1/1/3
 !
 interface GigabitEthernet1/1/4 ``` the module is supposed to generate 
 blank facts for the device. Regards, Sagar Paul 
 *E - sag...@redhat.com GH - KB-perByte*

 On Tuesday, February 1, 2022 at 9:14:29 PM UTC+5:30 lja...@gmail.com 
 wrote:

> Hi Sagar,
>
> The following is the case:
>
> *With the following platform I have no issues*
>
> platform: cisco WS-3850-24S
> net_iostype: IOS-XE
> net_version: 16.06.05
>
> output:
> net_interfaces - show me interface configuration per interface
> net_neighbors - shows me Mac address etc for all connected devices
> l2_interfaces - shows me interface name, switchport mode and access 
> vlan
>
> ---
>
> *With the 9300 I don't get the complete l2_interfaces output*
>
> *platform: 9300-24p*
> *net_iostype: IOS-XE*
> *net_version: 17.03.03*
>
> net_interfaces - show me interface configuration per interface
> net_neighbors - shows me Mac address etc for all connected devices
> l2_interfaces - shows me only interface name. *missing switch port 
> mode and access vlan*
>
> 
>
> *Here is the redacted config for the 9300*
>
> Building configuration...
>
>  
>
> Current configuration : 30751 bytes
>
> !
>
> !
>
> version 17.3
>
> service tcp-keepalives-in
>
> service timestamps debug datetime msec localtime show-timezone
>
> service timestamps log datetime msec localtime show-timezone
>
> service password-encryption
>
> service compress-config
>
> service call-home
>
> no platform punt-keepalive disable-kernel-core
>
> !
>
> hostname redacted
>
> !
>
> !
>
> vrf 

Re: [ansible-project] How to extract a list of values of a field within a list of dictionaries when a key matches another list of values

2022-02-07 Thread jean-christophe manciot
Thanks, your first answer is exactly what I was looking for. :-)

On Monday, February 7, 2022 at 2:32:38 AM UTC+1 uto...@gmail.com wrote:

> This produces the list you want:
>
> ---
> - name: Extracting a list of values of a field within a list of dictionaries 
> when a key matches another list of values
>   hosts:
> - localhost
>   strategy: debug
>   tasks:
> - name: Extract a list of values of a field within a list of dictionaries 
> when a key matches another list of values
>   set_fact:
> db_used_ports: |
> {% set ports=[] %}
> {% for dd0 in domain_definition %}
> {%   set db_servers_names=dd0.db_servers|default([]) %}
> {%   for dd1 in domain_definition %}
> {% if dd1['name'] in db_servers_names %}
> {%   set _ = ports.append(dd1.port) %}
> {% endif %}
> {%   endfor %}
> {% endfor %}{{ ports }}"
>   vars:
> domain_definition:
>   - name: server11
> cluster: cluster1
> db_servers:
>   - server12
>   - server21
> port: '8080'
>   - name: server12
> cluster: cluster1
> db_servers:
>   - server22
> port: '8090'
>   - name: server13
> cluster: cluster1
> port: '8091'
>   - name: server21
> cluster: cluster2
> db_servers:
>   - server12
>   - server22
> port: '9080'
>   - name: server22
> cluster: cluster2
> port: '9090'
>
> - name: Show the extracted ports
>   debug:
> msg: "{{ db_used_ports }}"
>
> On 2/5/22 9:56 AM, jean-christophe manciot wrote:
>
> Let's assume the following fictional list of dictionaries:
> domain_definition:
> - name: server11
>   cluster: cluster1
>   db_servers:
> - server12
> - server21
>   port: '8080'
> - name: server12
>   cluster: cluster1
>   db_servers:
> - server22
>   port: '8090'
> - name: server13
>   cluster: cluster1
>   port: '8091'
> - name: server21
>   cluster: cluster2
>   db_servers:
> - server12
> - server22
>   port: '9080'
> - name: server22
>   cluster: cluster2
>   port: '9090'
> The goal is to list all ports of used  'db_servers', so the expected list 
> is:
> - '8090'
> - '9080'
> - '9090'
> - '8090'
> - '9090'
>
> The *constraint* is to use one (some operation is performed for each 
> item) and only one loop (the list is huge in reality).
>
> The following does not work because selectattr expects a value, not a list 
> of values:
> - name: Extracting a list of values of a field within a list of 
> dictionaries when a key matches another list of values
>   hosts:
> - localhost
>   strategy: debug
>   tasks:
> - name: Extracting a list of values of a field within a 
> list of dictionaries when a key matches another list of values
>   vars:
> domain_definition:
> - name: server11
>   cluster: cluster1
>   db_servers:
> - server12
> - server21
>   port: '8080'
> - name: server12
>   cluster: cluster1
>   db_servers:
> - server22
>   port: '8090'
> - name: server13
>   cluster: cluster1
>   port: '8091'
> - name: server21
>   cluster: cluster2
>   db_servers:
> - server12
> - server22
>   port: '9080'
> - name: server22
>   cluster: cluster2
>   port: '9090'
> db_servers_names: "{{ item.db_servers |
>