diff --git a/ansible_collections/titom73/avd_tools/molecule/default/inventory/containerlabs.yml b/ansible_collections/titom73/avd_tools/molecule/default/inventory/containerlabs.yml index 4b95b3c..78734c1 100644 --- a/ansible_collections/titom73/avd_tools/molecule/default/inventory/containerlabs.yml +++ b/ansible_collections/titom73/avd_tools/molecule/default/inventory/containerlabs.yml @@ -19,6 +19,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9021:443/tcp + - 7023:22/tcp env: TMODE: lacp avd-agg02: @@ -30,6 +31,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9022:443/tcp + - 7024:22/tcp env: TMODE: lacp avd-l2leaf01: @@ -41,6 +43,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9029:443/tcp + - 7021:22/tcp env: TMODE: lacp avd-l2leaf02: @@ -52,6 +55,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9030:443/tcp + - 7022:22/tcp env: TMODE: lacp avd-bl01a: @@ -63,6 +67,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9015:443/tcp + - 7017:22/tcp env: TMODE: lacp avd-bl01b: @@ -74,6 +79,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9016:443/tcp + - 7018:22/tcp env: TMODE: lacp avd-cl01a: @@ -85,6 +91,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9027:443/tcp + - 7019:22/tcp env: TMODE: lacp avd-cl01b: @@ -96,6 +103,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9028:443/tcp + - 7020:22/tcp env: TMODE: lacp avd-leaf1a: @@ -107,6 +115,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9011:443/tcp + - 7011:22/tcp env: TMODE: lacp avd-leaf1b: @@ -118,6 +127,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9012:443/tcp + - 7012:22/tcp env: TMODE: lacp avd-leaf2a: @@ -129,6 +139,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9013:443/tcp + - 7013:22/tcp env: TMODE: lacp avd-leaf2b: @@ -140,6 +151,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9014:443/tcp + - 7014:22/tcp env: TMODE: lacp avd-leaf3a: @@ -151,6 +163,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9017:443/tcp + - 7015:22/tcp env: TMODE: lacp avd-leaf4a: @@ -162,6 +175,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9018:443/tcp + - 7016:22/tcp env: TMODE: lacp avd-rs01: @@ -173,6 +187,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9033:443/tcp + - 10033:22/tcp env: TMODE: lacp avd-rs02: @@ -184,6 +199,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9034:443/tcp + - 10034:22/tcp env: TMODE: lacp avd-spine1: @@ -195,6 +211,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9001:443/tcp + - 10001:22/tcp env: TMODE: lacp avd-spine2: @@ -206,6 +223,7 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro ports: - 9002:443/tcp + - 10002:22/tcp env: TMODE: lacp srv-pod01: diff --git a/ansible_collections/titom73/avd_tools/molecule/default/inventory/inventory.yml b/ansible_collections/titom73/avd_tools/molecule/default/inventory/inventory.yml index 4d3d93f..729f560 100644 --- a/ansible_collections/titom73/avd_tools/molecule/default/inventory/inventory.yml +++ b/ansible_collections/titom73/avd_tools/molecule/default/inventory/inventory.yml @@ -4,13 +4,7 @@ cvp: cv_server: ansible_host: 10.73.1.239 ansible_user: ansible - ansible_password: !vault | - $ANSIBLE_VAULT;1.1;AES256 - 34396430613838346566316638623339643765633366356361616162326637363936333161313234 - 6134616333376433333737623931656234666465316237330a316162333136393266623765653166 - 32363736353335333834616433663463363237393565633866653039383664373832636437656535 - 6161643036653064370a633634616164336562653030383936343762353233313637666532396634 - 3037 + ansible_password: demo type: unset tooling: @@ -18,25 +12,28 @@ tooling: endpoints: hosts: srv-pod01: - ansible_port: 9023 + ansible_httpapi_port: 9023 + ansible_port: 10023 ansible_host: 10.73.254.41 type: endpoint srv-pod02: - ansible_port: 9024 + ansible_httpapi_port: 9024 + ansible_port: 10024 ansible_host: 10.73.254.42 type: endpoint srv-pod03: - ansible_port: 9025 + ansible_httpapi_port: 9025 + ansible_port: 10025 ansible_host: 10.73.254.43 type: endpoint # dci-rtr: - # ansible_port: 9026 + # ansible_httpapi_port: 9026 # srv-pod05-23: - # ansible_port: 9031 + # ansible_httpapi_port: 9031 # ansible_host: 10.73.254.45 # type: endpoint # srv-pod05-24: - # ansible_port: 9032 + # ansible_httpapi_port: 9032 # ansible_host: 10.73.254.46 # type: endpoint @@ -49,20 +46,24 @@ avd: type: route_server hosts: avd-rs01: - ansible_port: 9033 + ansible_httpapi_port: 9033 + ansible_port: 10033 ansible_host: 10.73.254.51 avd-rs02: - ansible_port: 9034 + ansible_httpapi_port: 9034 + ansible_port: 10034 ansible_host: 10.73.254.52 avd_spines: vars: type: spine hosts: avd-spine1: - ansible_port: 9001 + ansible_httpapi_port: 9001 + ansible_port: 10001 ansible_host: 10.73.254.101 avd-spine2: - ansible_port: 9002 + ansible_httpapi_port: 9002 + ansible_port: 10002 ansible_host: 10.73.254.102 avd_l3leafs: vars: @@ -71,43 +72,43 @@ avd: avd_leaf1: hosts: avd-leaf1a: - ansible_port: 9011 + ansible_httpapi_port: 9011 ansible_host: 10.73.254.11 avd-leaf1b: - ansible_port: 9012 + ansible_httpapi_port: 9012 ansible_host: 10.73.254.12 avd_leaf2: hosts: avd-leaf2a: - ansible_port: 9013 + ansible_httpapi_port: 9013 ansible_host: 10.73.254.13 avd-leaf2b: - ansible_port: 9014 + ansible_httpapi_port: 9014 ansible_host: 10.73.254.14 avd_leaf_esi: hosts: avd-leaf3a: - ansible_port: 9017 + ansible_httpapi_port: 9017 ansible_host: 10.73.254.17 avd-leaf4a: - ansible_port: 9018 + ansible_httpapi_port: 9018 ansible_host: 10.73.254.18 avd_bl01: hosts: avd-bl01a: - ansible_port: 9015 + ansible_httpapi_port: 9015 ansible_host: 10.73.254.15 avd-bl01b: - ansible_port: 9016 + ansible_httpapi_port: 9016 ansible_host: 10.73.254.16 # nodes for central routing (l3 nodes) avd_cl02: hosts: avd-cl01a: - ansible_port: 9027 + ansible_httpapi_port: 9027 ansible_host: 10.73.254.19 avd-cl01b: - ansible_port: 9028 + ansible_httpapi_port: 9028 ansible_host: 10.73.254.20 # nodes for central routing (l2 nodes) avd_l2leafs: @@ -117,10 +118,10 @@ avd: avd_l2leaf1: hosts: avd-l2leaf01: - ansible_port: 9029 + ansible_httpapi_port: 9029 ansible_host: 10.73.254.31 avd-l2leaf02: - ansible_port: 9030 + ansible_httpapi_port: 9030 ansible_host: 10.73.254.32 avd_edge: vars: @@ -129,12 +130,12 @@ avd: avd_edge_leaf1: hosts: avd-agg01: - ansible_port: 9021 + ansible_httpapi_port: 9021 ansible_host: 10.73.254.21 avd_edge_leaf2: hosts: avd-agg02: - ansible_port: 9022 + ansible_httpapi_port: 9022 ansible_host: 10.73.254.22 avd_services: children: diff --git a/ansible_collections/titom73/avd_tools/molecule/default/molecule.yml b/ansible_collections/titom73/avd_tools/molecule/default/molecule.yml index bbc4d0e..7e4b83d 100644 --- a/ansible_collections/titom73/avd_tools/molecule/default/molecule.yml +++ b/ansible_collections/titom73/avd_tools/molecule/default/molecule.yml @@ -31,6 +31,8 @@ provisioner: defaults: jinja2_extensions: 'jinja2.ext.loopcontrols,jinja2.ext.do,jinja2.ext.i18n' gathering: explicit + inventory: + enable_plugins: yaml inventory: links: hosts: 'inventory/inventory.yml' @@ -51,4 +53,6 @@ verifier: config_options: defaults: jinja2_extensions: 'jinja2.ext.loopcontrols,jinja2.ext.do,jinja2.ext.i18n' - gathering: explicit \ No newline at end of file + gathering: explicit + inventory: + enable_plugins: yaml \ No newline at end of file diff --git a/ansible_collections/titom73/avd_tools/roles/avd_to_clab/README.md b/ansible_collections/titom73/avd_tools/roles/avd_to_clab/README.md index ebba223..b153d8a 100644 --- a/ansible_collections/titom73/avd_tools/roles/avd_to_clab/README.md +++ b/ansible_collections/titom73/avd_tools/roles/avd_to_clab/README.md @@ -34,7 +34,10 @@ The following default variables are defined, and can be modified as desired: - `mgmt_network_v4`: Subnet for management IPs use for OOB - `eapi_base`: Base port to use to expose eAPI from containers. Uses `eapi_base` + `device_id` from `arista.avd.eos_designs` -> If host has `ansible_port` defined and different than `443`, then, this value is used instead of an autogenerated one. +Port mapping logic: + +- If host has `ansible_httpapi_port` defined and different than `443`, then, this value is used instead of an autogenerated one using `eapi_base`. +- If host has `ansible_port` defined and different than `22`, then, this value is used instead of an autogenerated one using `ssh_base`. ```yaml # cEOS Image to use @@ -48,6 +51,12 @@ containerlab_configuration: '{{ inventory_dir }}/containerlabs.yml' # Default port to generate eAPI port mapping: eapi_base + device_id eapi_base: 8000 + +# Default port to generate ssh port mapping: ssh_base + device_id +ssh_base: 7000 + +# Bind inotify settings for large topology +fs_inotify_fix: False ``` ## Extend your topology diff --git a/ansible_collections/titom73/avd_tools/roles/avd_to_clab/defaults/main.yml b/ansible_collections/titom73/avd_tools/roles/avd_to_clab/defaults/main.yml index 82961cc..b9a7142 100644 --- a/ansible_collections/titom73/avd_tools/roles/avd_to_clab/defaults/main.yml +++ b/ansible_collections/titom73/avd_tools/roles/avd_to_clab/defaults/main.yml @@ -10,6 +10,12 @@ mgmt_network_v4: 192.168.1.0/24 # Default containerlabs configuration file generated containerlab_configuration: '{{ inventory_dir }}/containerlabs.yml' +# eAPI base port to compute dynamic eAPI port mapping +eapi_base: 8000 + +# SSH base port to compute dynamic SSH port mapping +ssh_base: 7000 + # Bind inotify settings for large topology # sudo sh -c 'echo "fs.inotify.max_user_instances = 50000" > /etc/sysctl.d/99-zceos.conf' # sudo sysctl -w fs.inotify.max_user_instances=50000 diff --git a/ansible_collections/titom73/avd_tools/roles/avd_to_clab/templates/topology.yml.j2 b/ansible_collections/titom73/avd_tools/roles/avd_to_clab/templates/topology.yml.j2 index b7e57b5..dda03a5 100644 --- a/ansible_collections/titom73/avd_tools/roles/avd_to_clab/templates/topology.yml.j2 +++ b/ansible_collections/titom73/avd_tools/roles/avd_to_clab/templates/topology.yml.j2 @@ -40,10 +40,17 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro {% endif %} ports: +{# eAPI port mapping #} +{% if hostvars[node].ansible_httpapi_port is arista.avd.defined and hostvars[node].ansible_httpapi_port %} + - {{ hostvars[node].ansible_httpapi_port }}:443/tcp +{% elif node_types[node_type]['node_groups'][node_group]['nodes'].id is arista.avd.defined %} + - {{ eapi_base + node_types[node_type]['node_groups'][node_group]['nodes'].id }}:443/tcp +{% endif %} +{# SSH port mapping #} {% if hostvars[node].ansible_port is arista.avd.defined and hostvars[node].ansible_port %} - - {{ hostvars[node].ansible_port }}:443/tcp -{% else %} - - {{ eapi_base + node_types[node_type]['nodes'][node].id }}:443/tcp + - {{ hostvars[node].ansible_port }}:22/tcp +{% elif node_types[node_type]['node_groups'][node_group]['nodes'][node].id is arista.avd.defined %} + - {{ ssh_base + node_types[node_type]['node_groups'][node_group]['nodes'][node].id }}:22/tcp {% endif %} env: TMODE: lacp @@ -61,10 +68,17 @@ topology: - /etc/sysctl.d/99-zceos.conf:/etc/sysctl.d/99-zceos.conf:ro {% endif %} ports: -{% if hostvars[node].ansible_port is arista.avd.defined and hostvars[node].ansible_port != 443 %} - - {{ hostvars[node].ansible_port }}:443/tcp -{% else %} +{# eAPI port mapping #} +{% if hostvars[node].ansible_httpapi_port is arista.avd.defined and hostvars[node].ansible_port != 443 %} + - {{ hostvars[node].ansible_httpapi_port }}:443/tcp +{% elif node_types[node_type]['nodes'][node].id is arista.avd.defined %} - {{ eapi_base + node_types[node_type]['nodes'][node].id }}:443/tcp +{% endif %} +{# SSH port mapping #} +{% if hostvars[node].ansible_httpapi_port is arista.avd.defined and hostvars[node].ansible_port != 22 %} + - {{ hostvars[node].ansible_port }}:22/tcp +{% elif node_types[node_type]['nodes'][node].id is arista.avd.defined %} + - {{ ssh_base + node_types[node_type]['nodes'][node].id }}:22/tcp {% endif %} env: TMODE: lacp