From cae1c6cc42fa786095433692a6d685f029bbde2e Mon Sep 17 00:00:00 2001
From: omnom62 <75066712+omnom62@users.noreply.github.com>
Date: Fri, 20 Dec 2024 05:33:39 +1000
Subject: VyOS v1.4 support for BGP (T6892 & T6888 & T6822) (#367)

* VyOS v1.4 support for BGP (T6892)

* WIP: chnages to scanners and facts for BGP on v1.4

* scanners and facts modification to support as_numberless commands

* remove optional regex groups

* VyOS v1.4 BGP system-as  functionality

* bgp_af linter

* bgp_global mods and testing

* bgp_global v.1.4 support

* linter fixes

* bgp_global and bgp_af fixed 1.3 test cases

* unit tests for bgp modules for both versions

* obsolete stranzas removed from bgp_global for both versions

* some typos removed

* bgp_global rst updates

* t6829 related draft changes

* Draft changes to unit tests fot original set and t6888 updates

* changelog

* D.R.Y for bgp_global and testmodule names

* linter fixes

* fixtures for bgp_af options  testts

* stranzas options processing

* T6888 bgp option test func and  cases

* clean-up draft code and update to rm_templates

* v14 system-as change supported in conf and tests

* T6822 BGP global passive bugfix

* clean-up

* T6829: update integration tests

* T6829: fix integration tests for global

* T6829: fix integration tests for bgp_global

* T6829: fix for 1.4 AF integration tests

* T6829: fix unit tests after removing obsolete items

* T6829: fix sanity test failures

* T6829: fix documentation

* Lint and comments are addressed

* rtt.yaml and fix to integration tests

* updated fragments for bgp_global

* lint fixes

---------

Co-authored-by: Gaige B. Paulsen <gaige@cluetrust.com>
---
 .../tests/cli/_get_version.yaml                    |  28 ++++
 .../tests/cli/_parsed_config.cfg                   |  12 +-
 .../tests/cli/_parsed_config_1_3.cfg               |   9 ++
 .../tests/cli/_populate.yaml                       |  27 +++-
 .../tests/cli/_preconfig.yaml                      |   8 ++
 .../tests/cli/_remove_config.yaml                  |   2 +-
 .../vyos_bgp_address_family/tests/cli/deleted.yaml |   2 +-
 .../vyos_bgp_address_family/tests/cli/merged.yaml  |   4 +-
 .../tests/cli/overridden.yaml                      |   2 +-
 .../vyos_bgp_address_family/tests/cli/parsed.yaml  |  35 ++++-
 .../tests/cli/rendered.yaml                        |   2 +-
 .../tests/cli/replaced.yaml                        |   2 +-
 .../vyos_bgp_address_family/tests/cli/rtt.yaml     |   4 +-
 .../targets/vyos_bgp_address_family/vars/main.yaml |  98 --------------
 .../vyos_bgp_address_family/vars/pre-v1_4.yaml     | 103 ++++++++++++++
 .../targets/vyos_bgp_address_family/vars/v1_4.yaml | 113 ++++++++++++++++
 .../vyos_bgp_global/tests/cli/_get_version.yaml    |  28 ++++
 .../vyos_bgp_global/tests/cli/_parsed_config.cfg   |  43 +++---
 .../tests/cli/_parsed_config_1_3.cfg               |  19 +++
 .../vyos_bgp_global/tests/cli/_populate.yaml       |  51 ++++---
 .../vyos_bgp_global/tests/cli/_populate_af.yaml    |  23 +++-
 .../vyos_bgp_global/tests/cli/_remove_config.yaml  |   2 +-
 .../targets/vyos_bgp_global/tests/cli/deleted.yaml |   2 +-
 .../vyos_bgp_global/tests/cli/deleted_af.yaml      |   1 -
 .../targets/vyos_bgp_global/tests/cli/merged.yaml  |  22 +--
 .../targets/vyos_bgp_global/tests/cli/parsed.yaml  |  34 ++++-
 .../targets/vyos_bgp_global/tests/cli/purged.yaml  |   9 ++
 .../vyos_bgp_global/tests/cli/rendered.yaml        |  20 +--
 .../vyos_bgp_global/tests/cli/replaced.yaml        |  14 +-
 .../vyos_bgp_global/tests/cli/replaced_af.yaml     |  12 +-
 .../targets/vyos_bgp_global/vars/main.yaml         | 149 ---------------------
 .../targets/vyos_bgp_global/vars/pre-v1_4.yaml     |  91 +++++++++++++
 .../targets/vyos_bgp_global/vars/v1_4.yaml         |  90 +++++++++++++
 33 files changed, 679 insertions(+), 382 deletions(-)
 create mode 100644 tests/integration/targets/vyos_bgp_address_family/tests/cli/_get_version.yaml
 create mode 100644 tests/integration/targets/vyos_bgp_address_family/tests/cli/_parsed_config_1_3.cfg
 create mode 100644 tests/integration/targets/vyos_bgp_address_family/vars/pre-v1_4.yaml
 create mode 100644 tests/integration/targets/vyos_bgp_address_family/vars/v1_4.yaml
 create mode 100644 tests/integration/targets/vyos_bgp_global/tests/cli/_get_version.yaml
 create mode 100644 tests/integration/targets/vyos_bgp_global/tests/cli/_parsed_config_1_3.cfg
 create mode 100644 tests/integration/targets/vyos_bgp_global/vars/pre-v1_4.yaml
 create mode 100644 tests/integration/targets/vyos_bgp_global/vars/v1_4.yaml

(limited to 'tests/integration/targets')

diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/_get_version.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/_get_version.yaml
new file mode 100644
index 0000000..2588b19
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/_get_version.yaml
@@ -0,0 +1,28 @@
+- name: make sure to get facts
+  vyos.vyos.vyos_facts:
+  vars:
+    ansible_connection: ansible.netcommon.network_cli
+  register: vyos_facts
+  when: vyos_version is not defined
+
+- name: debug vyos_facts
+  debug:
+    var: vyos_facts
+
+- name: pull version from facts
+  set_fact:
+    vyos_version: "{{ vyos_facts.ansible_facts.ansible_net_version.split('-')[0].split(' ')[-1] }}"
+  when: vyos_version is not defined
+
+- name: fix '.0' versions
+  set_fact:
+    vyos_version: "{{ vyos_version }}.0"
+  when: vyos_version.count('.') == 1
+
+- name: include correct vars
+  include_vars: pre-v1_4.yaml
+  when: vyos_version is version('1.4.0', '<', version_type='semver')
+
+- name: include correct vars
+  include_vars: v1_4.yaml
+  when: vyos_version is version('1.4.0', '>=', version_type='semver')
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_bgp_address_family/tests/cli/_parsed_config.cfg
index 2aecc80..afb0987 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/_parsed_config.cfg
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/_parsed_config.cfg
@@ -1,9 +1,9 @@
 set policy access-list 20 description 'acl20'
 set policy access-list 40 description 'acl40'
 set policy route-map map01 description 'map01'
-set protocols bgp 65536 address-family ipv6-unicast aggregate-address 5000:1:1::/64 summary-only
-set protocols bgp 65536 address-family ipv6-unicast network 21e0:1:1::/64 route-map 'map01'
-set protocols bgp 65536 address-family ipv6-unicast redistribute ripng metric '20'
-set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast route-map export 'map01'
-set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast soft-reconfiguration inbound
-set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged next-hop
+set protocols bgp address-family ipv6-unicast aggregate-address 5000:1:1::/64 summary-only
+set protocols bgp address-family ipv6-unicast network 21e0:1:1::/64 route-map 'map01'
+set protocols bgp address-family ipv6-unicast redistribute ripng metric '20'
+set protocols bgp neighbor 192.0.2.25 address-family ipv6-unicast route-map export 'map01'
+set protocols bgp neighbor 192.0.2.25 address-family ipv6-unicast soft-reconfiguration inbound
+set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged next-hop
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/_parsed_config_1_3.cfg b/tests/integration/targets/vyos_bgp_address_family/tests/cli/_parsed_config_1_3.cfg
new file mode 100644
index 0000000..2aecc80
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/_parsed_config_1_3.cfg
@@ -0,0 +1,9 @@
+set policy access-list 20 description 'acl20'
+set policy access-list 40 description 'acl40'
+set policy route-map map01 description 'map01'
+set protocols bgp 65536 address-family ipv6-unicast aggregate-address 5000:1:1::/64 summary-only
+set protocols bgp 65536 address-family ipv6-unicast network 21e0:1:1::/64 route-map 'map01'
+set protocols bgp 65536 address-family ipv6-unicast redistribute ripng metric '20'
+set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast route-map export 'map01'
+set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast soft-reconfiguration inbound
+set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged next-hop
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/_populate.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/_populate.yaml
index ecbcc70..4158a65 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/_populate.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/_populate.yaml
@@ -1,7 +1,10 @@
 ---
 - ansible.builtin.include_tasks: _remove_config.yaml
 
-- name: Setup
+- name: ensure facts
+  include_tasks: _get_version.yaml
+
+- name: Setup (Pre 1.4)
   vyos.vyos.vyos_config:
     lines:
       - set policy access-list 20 description 'acl20'
@@ -17,3 +20,25 @@
   ignore_errors: true
   vars:
     ansible_connection: ansible.netcommon.network_cli
+  when: vyos_version is version('1.4.0', '<', version_type='semver')
+
+- name: Setup (1.4+)
+  vyos.vyos.vyos_config:
+    lines:
+      - set policy access-list 20 description 'acl20'
+      - set policy access-list 40 description 'acl40'
+      - set policy access-list6 10 description 'acl10'
+      - set policy route-map map01 description 'map01'
+      - set protocols bgp system-as 65536
+      - set protocols bgp address-family ipv6-unicast aggregate-address 5000:1:1::/64 summary-only
+      - set protocols bgp address-family ipv6-unicast network 21e0:1:1::/64 route-map 'map01'
+      - set protocols bgp address-family ipv6-unicast redistribute ripng metric '20'
+      - set protocols bgp neighbor 192.0.2.25 remote-as 65535
+      - set protocols bgp neighbor 192.0.2.25 address-family ipv6-unicast route-map export 'map01'
+      - set protocols bgp neighbor 192.0.2.25 address-family ipv6-unicast soft-reconfiguration inbound
+      - set protocols bgp neighbor 203.0.113.5 remote-as 65534
+      - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged next-hop
+  ignore_errors: true
+  vars:
+    ansible_connection: ansible.netcommon.network_cli
+  when: vyos_version is version('1.4.0', '>=', version_type='semver')
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/_preconfig.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/_preconfig.yaml
index 5024a70..65adbb4 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/_preconfig.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/_preconfig.yaml
@@ -9,3 +9,11 @@
   ignore_errors: true
   vars:
     ansible_connection: ansible.netcommon.network_cli
+
+- name: setup for 1.4+
+  vyos.vyos.vyos_config:
+    lines:
+      - set protocols bgp system-as 65536
+      - set protocols bgp neighbor 203.0.113.5 remote-as 65534
+      - set protocols bgp neighbor 192.0.2.25 remote-as 65534
+  when: vyos_version is version('1.4.0', '>=', version_type='semver')
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/_remove_config.yaml
index 39d8bd0..36600e2 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/_remove_config.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/_remove_config.yaml
@@ -2,7 +2,7 @@
 - name: Remove pre-existing bgp processes
   vyos.vyos.vyos_config:
     lines:
-      - delete protocols bgp 65536
+      - delete protocols bgp
       - delete policy access-list 20
       - delete policy access-list 40
       - delete policy access-list6 10
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/deleted.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/deleted.yaml
index 15bfe84..2a76006 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/deleted.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/deleted.yaml
@@ -24,7 +24,7 @@
 
     - assert:
         that:
-          - result.commands|length == 3
+          - result.commands|length == deleted.commands|length
           - result.changed == true
           - result.commands|symmetric_difference(deleted.commands) == []
           - result.after == ansible_facts['network_resources']['bgp_address_family']
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/merged.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/merged.yaml
index 4e66a78..acfae74 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/merged.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/merged.yaml
@@ -45,11 +45,11 @@
 
     - assert:
         that:
-          - result.commands|length == 9
+          - result.commands|length == merged.commands|length
           - result.changed == true
           - result.commands|symmetric_difference(merged.commands) == []
           - result.after == ansible_facts['network_resources']['bgp_address_family']
-          - result.before == {}
+          - result.before == merged.before
           - result.after == merged.after
 
     - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT)
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/overridden.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/overridden.yaml
index 90b40de..ec0b616 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/overridden.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/overridden.yaml
@@ -33,7 +33,7 @@
 
     - assert:
         that:
-          - result.commands|length == 10
+          - result.commands|length == overridden.commands|length
           - result.changed == true
           - result.commands|symmetric_difference(overridden.commands) == []
           - result.after == ansible_facts['network_resources']['bgp_address_family']
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/parsed.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/parsed.yaml
index da9c141..65e9b1b 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/parsed.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/parsed.yaml
@@ -2,13 +2,34 @@
 - debug:
     msg: START vyos_bgp_address_family parsed integration tests on connection={{ ansible_connection }}
 
-- name: Provide the running configuration for parsing (config to be parsed)
-  register: result
-  vyos.vyos.vyos_bgp_address_family:
-    running_config: "{{ lookup('file', '_parsed_config.cfg') }}"
-    state: parsed
+- name: ensure facts
+  include_tasks: _get_version.yaml
+
+- name: version 1.3
+  block:
+    - name: Provide the running configuration for parsing (config to be parsed)
+      register: result
+      vyos.vyos.vyos_bgp_address_family:
+        running_config: "{{ lookup('file', '_parsed_config_1_3.cfg') }}"
+        state: parsed
+    - name: set result
+      set_fact:
+        parsed_result: "{{ result }}"
+  when: vyos_version is version('1.4.0', '<', version_type='semver')
+
+- name: version 1.4+
+  block:
+    - name: Provide the running configuration for parsing (config to be parsed)
+      register: result
+      vyos.vyos.vyos_bgp_address_family:
+        running_config: "{{ lookup('file', '_parsed_config.cfg') }}"
+        state: parsed
+    - name: set result
+      set_fact:
+        parsed_result: "{{ result }}"
+  when: vyos_version is version('1.4.0', '>=', version_type='semver')
 
 - assert:
     that:
-      - result.changed == false
-      - result.parsed == populate.config
+      - parsed_result.changed == false
+      - parsed_result.parsed == populate.config
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/rendered.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/rendered.yaml
index 0ef116e..151f896 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/rendered.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/rendered.yaml
@@ -39,4 +39,4 @@
     - assert:
         that:
           - result.changed == false
-          - result.rendered|symmetric_difference(merged.commands) == []
+          - result.rendered|symmetric_difference(rendered.commands) == []
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/replaced.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/replaced.yaml
index 9b6f330..15e45be 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/replaced.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/replaced.yaml
@@ -33,7 +33,7 @@
 
     - assert:
         that:
-          - result.commands|length == 9
+          - result.commands|length == replaced.commands|length
           - result.changed == true
           - result.commands|symmetric_difference(replaced.commands) == []
           - result.after == ansible_facts['network_resources']['bgp_address_family']
diff --git a/tests/integration/targets/vyos_bgp_address_family/tests/cli/rtt.yaml b/tests/integration/targets/vyos_bgp_address_family/tests/cli/rtt.yaml
index baab61b..49aeba7 100644
--- a/tests/integration/targets/vyos_bgp_address_family/tests/cli/rtt.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/tests/cli/rtt.yaml
@@ -2,6 +2,8 @@
 - debug:
     msg: START vyos_bgp_address_family rtt integration tests on connection={{ ansible_connection }}
 
+- include_tasks: _get_version.yaml
+
 - include_tasks: _remove_config.yaml
 
 - include_tasks: _preconfig.yaml
@@ -45,7 +47,7 @@
 
     - assert:
         that:
-          - baseconfig.commands|length == 9
+          - baseconfig.commands|length == merged.commands|length
           - baseconfig.changed == true
           - baseconfig.commands|symmetric_difference(merged.commands) == []
           - baseconfig.after == ansible_facts['network_resources']['bgp_address_family']
diff --git a/tests/integration/targets/vyos_bgp_address_family/vars/main.yaml b/tests/integration/targets/vyos_bgp_address_family/vars/main.yaml
index 448918a..ed97d53 100644
--- a/tests/integration/targets/vyos_bgp_address_family/vars/main.yaml
+++ b/tests/integration/targets/vyos_bgp_address_family/vars/main.yaml
@@ -1,99 +1 @@
 ---
-merged:
-  commands:
-    - set protocols bgp 65536 address-family ipv6-unicast redistribute static metric 50
-    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast allowas-in number 4
-    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged med
-    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast default-originate route-map map01
-    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast distribute-list export 10
-    - set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast maximum-prefix 45
-    - set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast nexthop-self
-    - set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast route-map export map01
-    - set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast route-map import map01
-  after:
-    address_family:
-      - afi: ipv6
-        redistribute:
-          - metric: 50
-            protocol: static
-    as_number: 65536
-    neighbors:
-      - address_family:
-          - afi: ipv6
-            maximum_prefix: 45
-            nexthop_self: true
-            route_map:
-              - action: export
-                route_map: map01
-              - action: import
-                route_map: map01
-        neighbor_address: 192.0.2.25
-      - address_family:
-          - afi: ipv6
-            allowas_in: 4
-            attribute_unchanged:
-              med: true
-            default_originate: map01
-            distribute_list:
-              - acl: 10
-                action: export
-        neighbor_address: 203.0.113.5
-
-replaced:
-  commands:
-    - delete protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged
-    - delete protocols bgp 65536 address-family ipv6 aggregate-address
-    - delete protocols bgp 65536 address-family ipv6 network
-    - delete protocols bgp 65536 address-family ipv6-unicast redistribute ripng
-    - set protocols bgp 65536 address-family ipv6-unicast redistribute static metric 50
-    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast allowas-in number 4
-    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged med
-    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast default-originate route-map map01
-    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast distribute-list export 10
-
-overridden:
-  commands:
-    - delete protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged
-    - delete protocols bgp 65536 neighbor 192.0.2.25 address-family
-    - delete protocols bgp 65536 address-family ipv6-unicast redistribute ripng
-    - delete protocols bgp 65536 address-family ipv6 aggregate-address
-    - delete protocols bgp 65536 address-family ipv6 network
-    - set protocols bgp 65536 address-family ipv6-unicast redistribute static metric 50
-    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast allowas-in number 4
-    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged med
-    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast default-originate route-map map01
-    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast distribute-list export 10
-
-deleted:
-  commands:
-    - delete protocols bgp 65536 address-family ipv6-unicast
-    - delete protocols bgp 65536 neighbor 203.0.113.5 address-family
-    - delete protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast
-
-populate:
-  config:
-    address_family:
-      - afi: ipv6
-        aggregate_address:
-          - summary_only: true
-            prefix: 5000:1:1::/64
-        networks:
-          - prefix: 21e0:1:1::/64
-            route_map: map01
-        redistribute:
-          - metric: 20
-            protocol: ripng
-    as_number: 65536
-    neighbors:
-      - address_family:
-          - afi: ipv6
-            route_map:
-              - action: export
-                route_map: map01
-            soft_reconfiguration: true
-        neighbor_address: 192.0.2.25
-      - address_family:
-          - afi: ipv6
-            attribute_unchanged:
-              next_hop: true
-        neighbor_address: 203.0.113.5
diff --git a/tests/integration/targets/vyos_bgp_address_family/vars/pre-v1_4.yaml b/tests/integration/targets/vyos_bgp_address_family/vars/pre-v1_4.yaml
new file mode 100644
index 0000000..c50db90
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_address_family/vars/pre-v1_4.yaml
@@ -0,0 +1,103 @@
+---
+rendered:
+  commands: "{{ merged.commands }}"
+
+merged:
+  commands:
+    - set protocols bgp 65536 address-family ipv6-unicast redistribute static metric 50
+    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast allowas-in number 4
+    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged med
+    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast default-originate route-map map01
+    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast distribute-list export 10
+    - set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast maximum-prefix 45
+    - set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast nexthop-self
+    - set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast route-map export map01
+    - set protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast route-map import map01
+  before: {}
+  after:
+    address_family:
+      - afi: ipv6
+        redistribute:
+          - metric: 50
+            protocol: static
+    as_number: 65536
+    neighbors:
+      - address_family:
+          - afi: ipv6
+            maximum_prefix: 45
+            nexthop_self: true
+            route_map:
+              - action: export
+                route_map: map01
+              - action: import
+                route_map: map01
+        neighbor_address: 192.0.2.25
+      - address_family:
+          - afi: ipv6
+            allowas_in: 4
+            attribute_unchanged:
+              med: true
+            default_originate: map01
+            distribute_list:
+              - acl: 10
+                action: export
+        neighbor_address: 203.0.113.5
+
+replaced:
+  commands:
+    - delete protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged
+    - delete protocols bgp 65536 address-family ipv6 aggregate-address
+    - delete protocols bgp 65536 address-family ipv6 network
+    - delete protocols bgp 65536 address-family ipv6-unicast redistribute ripng
+    - set protocols bgp 65536 address-family ipv6-unicast redistribute static metric 50
+    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast allowas-in number 4
+    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged med
+    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast default-originate route-map map01
+    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast distribute-list export 10
+
+overridden:
+  commands:
+    - delete protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged
+    - delete protocols bgp 65536 neighbor 192.0.2.25 address-family
+    - delete protocols bgp 65536 address-family ipv6-unicast redistribute ripng
+    - delete protocols bgp 65536 address-family ipv6 aggregate-address
+    - delete protocols bgp 65536 address-family ipv6 network
+    - set protocols bgp 65536 address-family ipv6-unicast redistribute static metric 50
+    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast allowas-in number 4
+    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged med
+    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast default-originate route-map map01
+    - set protocols bgp 65536 neighbor 203.0.113.5 address-family ipv6-unicast distribute-list export 10
+
+deleted:
+  commands:
+    - delete protocols bgp 65536 address-family ipv6-unicast
+    - delete protocols bgp 65536 neighbor 203.0.113.5 address-family
+    - delete protocols bgp 65536 neighbor 192.0.2.25 address-family ipv6-unicast
+
+populate:
+  config:
+    address_family:
+      - afi: ipv6
+        aggregate_address:
+          - summary_only: true
+            prefix: 5000:1:1::/64
+        networks:
+          - prefix: 21e0:1:1::/64
+            route_map: map01
+        redistribute:
+          - metric: 20
+            protocol: ripng
+    as_number: 65536
+    neighbors:
+      - address_family:
+          - afi: ipv6
+            route_map:
+              - action: export
+                route_map: map01
+            soft_reconfiguration: true
+        neighbor_address: 192.0.2.25
+      - address_family:
+          - afi: ipv6
+            attribute_unchanged:
+              next_hop: true
+        neighbor_address: 203.0.113.5
diff --git a/tests/integration/targets/vyos_bgp_address_family/vars/v1_4.yaml b/tests/integration/targets/vyos_bgp_address_family/vars/v1_4.yaml
new file mode 100644
index 0000000..a56e9eb
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_address_family/vars/v1_4.yaml
@@ -0,0 +1,113 @@
+---
+rendered:
+  commands:
+    - set protocols bgp system-as 65536
+    - set protocols bgp address-family ipv6-unicast redistribute static metric 50
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast allowas-in number 4
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged med
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast default-originate route-map map01
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast distribute-list export 10
+    - set protocols bgp neighbor 192.0.2.25 address-family ipv6-unicast maximum-prefix 45
+    - set protocols bgp neighbor 192.0.2.25 address-family ipv6-unicast nexthop-self
+    - set protocols bgp neighbor 192.0.2.25 address-family ipv6-unicast route-map export map01
+    - set protocols bgp neighbor 192.0.2.25 address-family ipv6-unicast route-map import map01
+
+merged:
+  commands:
+    - set protocols bgp address-family ipv6-unicast redistribute static metric 50
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast allowas-in number 4
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged med
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast default-originate route-map map01
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast distribute-list export 10
+    - set protocols bgp neighbor 192.0.2.25 address-family ipv6-unicast maximum-prefix 45
+    - set protocols bgp neighbor 192.0.2.25 address-family ipv6-unicast nexthop-self
+    - set protocols bgp neighbor 192.0.2.25 address-family ipv6-unicast route-map export map01
+    - set protocols bgp neighbor 192.0.2.25 address-family ipv6-unicast route-map import map01
+  before:
+    as_number: 65536
+  after:
+    address_family:
+      - afi: ipv6
+        redistribute:
+          - metric: 50
+            protocol: static
+    as_number: 65536
+    neighbors:
+      - address_family:
+          - afi: ipv6
+            maximum_prefix: 45
+            nexthop_self: true
+            route_map:
+              - action: export
+                route_map: map01
+              - action: import
+                route_map: map01
+        neighbor_address: 192.0.2.25
+      - address_family:
+          - afi: ipv6
+            allowas_in: 4
+            attribute_unchanged:
+              med: true
+            default_originate: map01
+            distribute_list:
+              - acl: 10
+                action: export
+        neighbor_address: 203.0.113.5
+
+replaced:
+  commands:
+    - delete protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged
+    - delete protocols bgp address-family ipv6 aggregate-address
+    - delete protocols bgp address-family ipv6 network
+    - delete protocols bgp address-family ipv6-unicast redistribute ripng
+    - set protocols bgp address-family ipv6-unicast redistribute static metric 50
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast allowas-in number 4
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged med
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast default-originate route-map map01
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast distribute-list export 10
+
+overridden:
+  commands:
+    - delete protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged
+    - delete protocols bgp neighbor 192.0.2.25 address-family
+    - delete protocols bgp address-family ipv6-unicast redistribute ripng
+    - delete protocols bgp address-family ipv6 aggregate-address
+    - delete protocols bgp address-family ipv6 network
+    - set protocols bgp address-family ipv6-unicast redistribute static metric 50
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast allowas-in number 4
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast attribute-unchanged med
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast default-originate route-map map01
+    - set protocols bgp neighbor 203.0.113.5 address-family ipv6-unicast distribute-list export 10
+
+deleted:
+  commands:
+    - delete protocols bgp address-family ipv6-unicast
+    - delete protocols bgp neighbor 203.0.113.5 address-family
+    - delete protocols bgp neighbor 192.0.2.25 address-family ipv6-unicast
+
+populate:
+  config:
+    address_family:
+      - afi: ipv6
+        aggregate_address:
+          - summary_only: true
+            prefix: 5000:1:1::/64
+        networks:
+          - prefix: 21e0:1:1::/64
+            route_map: map01
+        redistribute:
+          - metric: 20
+            protocol: ripng
+    neighbors:
+      - address_family:
+          - afi: ipv6
+            route_map:
+              - action: export
+                route_map: map01
+            soft_reconfiguration: true
+        neighbor_address: 192.0.2.25
+      - address_family:
+          - afi: ipv6
+            attribute_unchanged:
+              next_hop: true
+        neighbor_address: 203.0.113.5
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/_get_version.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/_get_version.yaml
new file mode 100644
index 0000000..2588b19
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/_get_version.yaml
@@ -0,0 +1,28 @@
+- name: make sure to get facts
+  vyos.vyos.vyos_facts:
+  vars:
+    ansible_connection: ansible.netcommon.network_cli
+  register: vyos_facts
+  when: vyos_version is not defined
+
+- name: debug vyos_facts
+  debug:
+    var: vyos_facts
+
+- name: pull version from facts
+  set_fact:
+    vyos_version: "{{ vyos_facts.ansible_facts.ansible_net_version.split('-')[0].split(' ')[-1] }}"
+  when: vyos_version is not defined
+
+- name: fix '.0' versions
+  set_fact:
+    vyos_version: "{{ vyos_version }}.0"
+  when: vyos_version.count('.') == 1
+
+- name: include correct vars
+  include_vars: pre-v1_4.yaml
+  when: vyos_version is version('1.4.0', '<', version_type='semver')
+
+- name: include correct vars
+  include_vars: v1_4.yaml
+  when: vyos_version is version('1.4.0', '>=', version_type='semver')
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/_parsed_config.cfg b/tests/integration/targets/vyos_bgp_global/tests/cli/_parsed_config.cfg
index 2338b03..e8f7881 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/cli/_parsed_config.cfg
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/_parsed_config.cfg
@@ -1,30 +1,19 @@
 set policy access-list 20 description 'acl20'
 set policy access-list 40 description 'acl40'
 set policy route-map map01 description 'map01'
-set protocols bgp 65536 aggregate-address 192.0.2.0/24 'summary-only'
-set protocols bgp 65536 aggregate-address 203.0.113.0/24 'as-set'
-set protocols bgp 65536 maximum-paths ebgp '20'
-set protocols bgp 65536 maximum-paths ibgp '55'
-set protocols bgp 65536 neighbor 192.0.2.25 'disable-connected-check'
-set protocols bgp 65536 neighbor 192.0.2.25 timers holdtime '30'
-set protocols bgp 65536 neighbor 192.0.2.25 timers keepalive '10'
-set protocols bgp 65536 neighbor 203.0.113.5 attribute-unchanged 'as-path'
-set protocols bgp 65536 neighbor 203.0.113.5 attribute-unchanged 'med'
-set protocols bgp 65536 neighbor 203.0.113.5 attribute-unchanged 'next-hop'
-set protocols bgp 65536 neighbor 203.0.113.5 ebgp-multihop '2'
-set protocols bgp 65536 neighbor 203.0.113.5 remote-as '101'
-set protocols bgp 65536 neighbor 203.0.113.5 update-source '192.0.2.25'
-set protocols bgp 65536 neighbor 5001::64 distribute-list export '20'
-set protocols bgp 65536 neighbor 5001::64 distribute-list import '40'
-set protocols bgp 65536 neighbor 5001::64 maximum-prefix '34'
-set protocols bgp 65536 network 192.1.13.0/24 'backdoor'
-set protocols bgp 65536 parameters bestpath as-path 'confed'
-set protocols bgp 65536 parameters bestpath 'compare-routerid'
-set protocols bgp 65536 parameters confederation identifier '66'
-set protocols bgp 65536 parameters confederation peers '20'
-set protocols bgp 65536 parameters confederation peers '55'
-set protocols bgp 65536 parameters default 'no-ipv4-unicast'
-set protocols bgp 65536 parameters router-id '192.1.2.9'
-set protocols bgp 65536 redistribute connected route-map 'map01'
-set protocols bgp 65536 redistribute kernel metric '45'
-set protocols bgp 65536 timers keepalive '35'
+set protocols bgp system-as '65536'
+set protocols bgp neighbor 192.0.2.25 'disable-connected-check'
+set protocols bgp neighbor 192.0.2.25 timers holdtime '30'
+set protocols bgp neighbor 192.0.2.25 timers keepalive '10'
+set protocols bgp neighbor 192.0.2.25 remote-as '102'
+set protocols bgp neighbor 203.0.113.5 ebgp-multihop '2'
+set protocols bgp neighbor 203.0.113.5 remote-as '101'
+set protocols bgp neighbor 203.0.113.5 update-source '192.0.2.25'
+set protocols bgp neighbor 5001::64 remote-as '103'
+set protocols bgp parameters bestpath as-path 'confed'
+set protocols bgp parameters bestpath 'compare-routerid'
+set protocols bgp parameters confederation identifier '66'
+set protocols bgp parameters confederation peers '20'
+set protocols bgp parameters confederation peers '55'
+set protocols bgp parameters router-id '192.1.2.9'
+set protocols bgp timers keepalive '35'
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/_parsed_config_1_3.cfg b/tests/integration/targets/vyos_bgp_global/tests/cli/_parsed_config_1_3.cfg
new file mode 100644
index 0000000..fbf2326
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/_parsed_config_1_3.cfg
@@ -0,0 +1,19 @@
+set policy access-list 20 description 'acl20'
+set policy access-list 40 description 'acl40'
+set policy route-map map01 description 'map01'
+set protocols bgp 65536 neighbor 192.0.2.25 'disable-connected-check'
+set protocols bgp 65536 neighbor 192.0.2.25 timers holdtime '30'
+set protocols bgp 65536 neighbor 192.0.2.25 timers keepalive '10'
+set protocols bgp 65536 neighbor 192.0.2.25 remote-as '102'
+set protocols bgp 65536 neighbor 203.0.113.5 ebgp-multihop '2'
+set protocols bgp 65536 neighbor 203.0.113.5 remote-as '101'
+set protocols bgp 65536 neighbor 203.0.113.5 update-source '192.0.2.25'
+set protocols bgp 65536 neighbor 5001::64 remote-as '103'
+set protocols bgp 65536 parameters bestpath as-path 'confed'
+set protocols bgp 65536 parameters bestpath 'compare-routerid'
+set protocols bgp 65536 parameters confederation identifier '66'
+set protocols bgp 65536 parameters confederation peers '20'
+set protocols bgp 65536 parameters confederation peers '55'
+set protocols bgp 65536 parameters default local-pref 100
+set protocols bgp 65536 parameters router-id '192.1.2.9'
+set protocols bgp 65536 timers keepalive '35'
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/_populate.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/_populate.yaml
index 0f281c9..17fa22b 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/cli/_populate.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/_populate.yaml
@@ -1,39 +1,60 @@
 ---
 - ansible.builtin.include_tasks: _remove_config.yaml
 
-- name: Setup
+- name: ensure facts
+  include_tasks: _get_version.yaml
+
+- name: Setup 1.3-
   vyos.vyos.vyos_config:
     lines:
       - set policy access-list 20 description 'acl20'
       - set policy access-list 40 description 'acl40'
       - set policy route-map map01 description 'map01'
-      - set protocols bgp 65536 aggregate-address 192.0.2.0/24 'summary-only'
-      - set protocols bgp 65536 aggregate-address 203.0.113.0/24 'as-set'
-      - set protocols bgp 65536 maximum-paths ebgp '20'
-      - set protocols bgp 65536 maximum-paths ibgp '55'
       - set protocols bgp 65536 neighbor 192.0.2.25 'disable-connected-check'
       - set protocols bgp 65536 neighbor 192.0.2.25 timers holdtime '30'
       - set protocols bgp 65536 neighbor 192.0.2.25 timers keepalive '10'
-      - set protocols bgp 65536 neighbor 203.0.113.5 attribute-unchanged 'as-path'
-      - set protocols bgp 65536 neighbor 203.0.113.5 attribute-unchanged 'med'
-      - set protocols bgp 65536 neighbor 203.0.113.5 attribute-unchanged 'next-hop'
+      - set protocols bgp 65536 neighbor 192.0.2.25 remote-as '102'
       - set protocols bgp 65536 neighbor 203.0.113.5 ebgp-multihop '2'
       - set protocols bgp 65536 neighbor 203.0.113.5 remote-as '101'
       - set protocols bgp 65536 neighbor 203.0.113.5 update-source '192.0.2.25'
-      - set protocols bgp 65536 neighbor 5001::64 distribute-list export '20'
-      - set protocols bgp 65536 neighbor 5001::64 distribute-list import '40'
-      - set protocols bgp 65536 neighbor 5001::64 maximum-prefix '34'
-      - set protocols bgp 65536 network 192.1.13.0/24 'backdoor'
+      - set protocols bgp 65536 neighbor 5001::64 remote-as '103'
       - set protocols bgp 65536 parameters bestpath as-path 'confed'
       - set protocols bgp 65536 parameters bestpath 'compare-routerid'
       - set protocols bgp 65536 parameters confederation identifier '66'
       - set protocols bgp 65536 parameters confederation peers '20'
       - set protocols bgp 65536 parameters confederation peers '55'
-      - set protocols bgp 65536 parameters default 'no-ipv4-unicast'
+      - set protocols bgp 65536 parameters default local-pref 100
       - set protocols bgp 65536 parameters router-id '192.1.2.9'
-      - set protocols bgp 65536 redistribute connected route-map 'map01'
-      - set protocols bgp 65536 redistribute kernel metric '45'
       - set protocols bgp 65536 timers keepalive '35'
   ignore_errors: true
   vars:
     ansible_connection: ansible.netcommon.network_cli
+  when: vyos_version is version('1.4.0', '<', version_type='semver')
+
+- name: Setup 1.4+
+  vyos.vyos.vyos_config:
+    lines:
+      - set policy access-list 20 description 'acl20'
+      - set policy access-list 40 description 'acl40'
+      - set policy route-map map01 description 'map01'
+      - set protocols bgp system-as 65536
+      - set protocols bgp neighbor 192.0.2.25 'disable-connected-check'
+      - set protocols bgp neighbor 192.0.2.25 timers holdtime '30'
+      - set protocols bgp neighbor 192.0.2.25 timers keepalive '10'
+      - set protocols bgp neighbor 192.0.2.25 remote-as '102'
+      - set protocols bgp neighbor 203.0.113.5 ebgp-multihop '2'
+      - set protocols bgp neighbor 203.0.113.5 remote-as '101'
+      - set protocols bgp neighbor 203.0.113.5 update-source '192.0.2.25'
+      - set protocols bgp neighbor 5001::64 remote-as '103'
+      - set protocols bgp parameters bestpath as-path 'confed'
+      - set protocols bgp parameters bestpath 'compare-routerid'
+      - set protocols bgp parameters confederation identifier '66'
+      - set protocols bgp parameters confederation peers '20'
+      - set protocols bgp parameters confederation peers '55'
+      - set protocols bgp parameters default local-pref 100
+      - set protocols bgp parameters router-id '192.1.2.9'
+      - set protocols bgp timers keepalive '35'
+  ignore_errors: true
+  vars:
+    ansible_connection: ansible.netcommon.network_cli
+  when: vyos_version is version('1.4.0', '>=', version_type='semver')
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/_populate_af.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/_populate_af.yaml
index 59f3d92..0a06aeb 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/cli/_populate_af.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/_populate_af.yaml
@@ -1,12 +1,29 @@
 ---
-- name: setup
+- name: ensure facts
+  include_tasks: _get_version.yaml
+
+- name: setup 1.3- AF
   vyos.vyos.vyos_config:
     lines:
       - set protocols bgp 65536 neighbor 5001::64 address-family 'ipv6-unicast'
       - set protocols bgp 65536 neighbor 5001::64 ebgp-multihop '2'
-      - set protocols bgp 65536 neighbor 5001::64 maximum-prefix '34'
-      - set protocols bgp 65536 neighbor 5001::64 remote-as '65535'
+      - set protocols bgp 65536 neighbor 5001::64 remote-as '103'
       - set protocols bgp 65536 neighbor 5001::64 update-source '2001:db8::1'
+
   ignore_errors: true
   vars:
     ansible_connection: ansible.netcommon.network_cli
+  when: vyos_version is version('1.4.0', '<', version_type='semver')
+
+- name: setup 1.4+ AF
+  vyos.vyos.vyos_config:
+    lines:
+      - set protocols bgp system-as 65536
+      - set protocols bgp neighbor 5001::64 address-family 'ipv6-unicast'
+      - set protocols bgp neighbor 5001::64 ebgp-multihop '2'
+      - set protocols bgp neighbor 5001::64 remote-as '103'
+      - set protocols bgp neighbor 5001::64 update-source '2001:db8::1'
+  ignore_errors: true
+  vars:
+    ansible_connection: ansible.netcommon.network_cli
+  when: vyos_version is version('1.4.0', '>=', version_type='semver')
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/_remove_config.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/_remove_config.yaml
index 07d4aa4..9ccdb09 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/cli/_remove_config.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/_remove_config.yaml
@@ -2,7 +2,7 @@
 - name: Remove pre-existing bgp processes
   vyos.vyos.vyos_config:
     lines:
-      - delete protocols bgp 65536
+      - delete protocols bgp
       - delete policy access-list 20
       - delete policy access-list 40
       - delete policy route-map map01
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml
index 5920c8f..e652e12 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/deleted.yaml
@@ -17,7 +17,7 @@
 
     - assert:
         that:
-          - result.commands|length == 9
+          - result.commands|length == deleted.commands | length
           - result.changed == true
           - result.commands|symmetric_difference(deleted.commands) == []
           - result.after == ansible_facts['network_resources']['bgp_global']
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/deleted_af.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/deleted_af.yaml
index 88e6be0..d67d312 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/cli/deleted_af.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/deleted_af.yaml
@@ -18,6 +18,5 @@
     - assert:
         that:
           - result.msg == 'Use the _bgp_address_family module to delete the address_family under neighbor 5001::64, before replacing/deleting the neighbor.'
-
   always:
     - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml
index 388bbcc..e11cd1e 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/merged.yaml
@@ -12,24 +12,6 @@
       vyos.vyos.vyos_bgp_global: &id001
         config:
           as_number: "65536"
-          aggregate_address:
-            - prefix: 203.0.113.0/24
-              as_set: true
-            - prefix: 192.0.2.0/24
-              summary_only: true
-          network:
-            - address: 192.1.13.0/24
-              backdoor: true
-          redistribute:
-            - protocol: kernel
-              metric: 45
-            - protocol: connected
-              route_map: map01
-          maximum_paths:
-            - path: ebgp
-              count: 20
-            - path: ibgp
-              count: 55
           timers:
             keepalive: 35
           bgp_params:
@@ -37,7 +19,7 @@
               as_path: confed
               compare_routerid: true
             default:
-              no_ipv4_unicast: true
+              local_pref: 100
             router_id: 192.1.2.9
         state: merged
 
@@ -46,7 +28,7 @@
 
     - assert:
         that:
-          - result.commands|length == 12
+          - result.commands|length == merged.commands | length
           - result.changed == true
           - result.commands|symmetric_difference(merged.commands) == []
           - result.after == ansible_facts['network_resources']['bgp_global']
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml
index eca85ce..293c204 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/parsed.yaml
@@ -2,13 +2,33 @@
 - debug:
     msg: START vyos_bgp_global parsed integration tests on connection={{ ansible_connection }}
 
-- name: Provide the running configuration for parsing (config to be parsed)
-  register: result
-  vyos.vyos.vyos_bgp_global:
-    running_config: "{{ lookup('file', '_parsed_config.cfg') }}"
-    state: parsed
+- name: ensure facts
+  include_tasks: _get_version.yaml
 
+- name: version 1.3
+  block:
+    - name: Provide the running configuration for parsing (config to be parsed)
+      register: result
+      vyos.vyos.vyos_bgp_global:
+        running_config: "{{ lookup('file', '_parsed_config_1_3.cfg') }}"
+        state: parsed
+    - name: set result
+      set_fact:
+        parsed_result: "{{ result }}"
+  when: vyos_version is version('1.4.0', '<', version_type='semver')
+
+- name: version 1.4+
+  block:
+    - name: Provide the running configuration for parsing (config to be parsed)
+      register: result
+      vyos.vyos.vyos_bgp_global:
+        running_config: "{{ lookup('file', '_parsed_config.cfg') }}"
+        state: parsed
+    - name: set result
+      set_fact:
+        parsed_result: "{{ result }}"
+  when: vyos_version is version('1.4.0', '>=', version_type='semver')
 - assert:
     that:
-      - result.changed == false
-      - result.parsed == populate.global
+      - parsed_result.changed == false
+      - parsed_result.parsed == populate.global
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml
index 71748f5..dfc2e43 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/purged.yaml
@@ -21,6 +21,15 @@
           - result.changed == true
           - "'delete protocols bgp 65536' in result.commands"
           - ansible_facts.network_resources.bgp_global == []
+      when: vyos_version is version('1.4.0', '<', version_type='semver')
+
+    - assert:
+        that:
+          - result.commands|length == 1
+          - result.changed == true
+          - "'delete protocols bgp' in result.commands"
+          - ansible_facts.network_resources.bgp_global == []
+      when: vyos_version is version('1.4.0', '>=', version_type='semver')
 
   always:
     - include_tasks: _remove_config.yaml
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/rendered.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/rendered.yaml
index f37ef88..39fc12a 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/cli/rendered.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/rendered.yaml
@@ -8,24 +8,6 @@
       vyos.vyos.vyos_bgp_global:
         config:
           as_number: "65536"
-          aggregate_address:
-            - prefix: 203.0.113.0/24
-              as_set: true
-            - prefix: 192.0.2.0/24
-              summary_only: true
-          network:
-            - address: 192.1.13.0/24
-              backdoor: true
-          redistribute:
-            - protocol: kernel
-              metric: 45
-            - protocol: connected
-              route_map: map01
-          maximum_paths:
-            - path: ebgp
-              count: 20
-            - path: ibgp
-              count: 55
           timers:
             keepalive: 35
           bgp_params:
@@ -33,7 +15,7 @@
               as_path: confed
               compare_routerid: true
             default:
-              no_ipv4_unicast: true
+              local_pref: 100
             router_id: 192.1.2.9
         state: rendered
 
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml
index ae2c5c7..22323c3 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/replaced.yaml
@@ -10,12 +10,6 @@
       vyos.vyos.vyos_bgp_global: &id001
         config:
           as_number: "65536"
-          network:
-            - address: 203.0.113.0/24
-              route_map: map01
-          redistribute:
-            - protocol: static
-              route_map: map01
           bgp_params:
             always_compare_med: true
             dampening:
@@ -26,8 +20,6 @@
             bestpath:
               as_path: confed
               compare_routerid: true
-            default:
-              no_ipv4_unicast: true
           neighbor:
             - address: 192.0.2.43
               disable_connected_check: true
@@ -37,9 +29,11 @@
               timers:
                 holdtime: 30
                 keepalive: 10
+              remote_as: 102
             - address: 203.0.113.0
               capability:
-                orf: receive
+                dynamic: true
+              remote_as: 102
         state: replaced
 
     - vyos.vyos.vyos_facts:
@@ -47,7 +41,7 @@
 
     - assert:
         that:
-          - result.commands|length == 24
+          - result.commands|length == replaced.commands|length
           - result.changed == true
           - result.commands|symmetric_difference(replaced.commands) == []
           - result.after == ansible_facts['network_resources']['bgp_global']
diff --git a/tests/integration/targets/vyos_bgp_global/tests/cli/replaced_af.yaml b/tests/integration/targets/vyos_bgp_global/tests/cli/replaced_af.yaml
index c9b2319..3054ea1 100644
--- a/tests/integration/targets/vyos_bgp_global/tests/cli/replaced_af.yaml
+++ b/tests/integration/targets/vyos_bgp_global/tests/cli/replaced_af.yaml
@@ -13,12 +13,6 @@
       vyos.vyos.vyos_bgp_global:
         config:
           as_number: "65536"
-          network:
-            - address: 203.0.113.0/24
-              route_map: map01
-          redistribute:
-            - protocol: static
-              route_map: map01
           bgp_params:
             always_compare_med: true
             dampening:
@@ -29,8 +23,6 @@
             bestpath:
               as_path: confed
               compare_routerid: true
-            default:
-              no_ipv4_unicast: true
           neighbor:
             - address: 192.0.2.43
               disable_connected_check: true
@@ -40,9 +32,11 @@
               timers:
                 holdtime: 30
                 keepalive: 10
+              remote_as: 102
             - address: 203.0.113.0
               capability:
-                orf: receive
+                dynamic: true
+              remote_as: 102
         state: replaced
 
     - assert:
diff --git a/tests/integration/targets/vyos_bgp_global/vars/main.yaml b/tests/integration/targets/vyos_bgp_global/vars/main.yaml
index e195c2d..ed97d53 100644
--- a/tests/integration/targets/vyos_bgp_global/vars/main.yaml
+++ b/tests/integration/targets/vyos_bgp_global/vars/main.yaml
@@ -1,150 +1 @@
 ---
-merged:
-  commands:
-    - set protocols bgp 65536 redistribute kernel metric 45
-    - set protocols bgp 65536 redistribute connected route-map map01
-    - set protocols bgp 65536 network 192.1.13.0/24 backdoor
-    - set protocols bgp 65536 aggregate-address 203.0.113.0/24 as-set
-    - set protocols bgp 65536 aggregate-address 192.0.2.0/24 summary-only
-    - set protocols bgp 65536 parameters bestpath as-path confed
-    - set protocols bgp 65536 parameters bestpath compare-routerid
-    - set protocols bgp 65536 parameters default no-ipv4-unicast
-    - set protocols bgp 65536 parameters router-id 192.1.2.9
-    - set protocols bgp 65536 maximum-paths ebgp 20
-    - set protocols bgp 65536 maximum-paths ibgp 55
-    - set protocols bgp 65536 timers keepalive 35
-  after:
-    aggregate_address:
-      - prefix: 192.0.2.0/24
-        summary_only: true
-      - prefix: 203.0.113.0/24
-        as_set: true
-    as_number: 65536
-    bgp_params:
-      bestpath:
-        as_path: confed
-        compare_routerid: true
-      default:
-        no_ipv4_unicast: true
-      router_id: 192.1.2.9
-    maximum_paths:
-      - count: 20
-        path: ebgp
-      - count: 55
-        path: ibgp
-    network:
-      - address: 192.1.13.0/24
-        backdoor: true
-    redistribute:
-      - protocol: connected
-        route_map: map01
-      - metric: 45
-        protocol: kernel
-    timers:
-      keepalive: 35
-
-replaced:
-  commands:
-    - delete protocols bgp 65536 timers
-    - delete protocols bgp 65536 maximum-paths
-    - delete protocols bgp 65536 parameters router-id 192.1.2.9
-    - delete protocols bgp 65536 parameters confederation
-    - delete protocols bgp 65536 aggregate-address
-    - delete protocols bgp 65536 network 192.1.13.0/24
-    - delete protocols bgp 65536 redistribute kernel
-    - delete protocols bgp 65536 redistribute connected
-    - delete protocols bgp 65536 neighbor 5001::64
-    - delete protocols bgp 65536 neighbor 203.0.113.5
-    - delete protocols bgp 65536 neighbor 192.0.2.25
-    - set protocols bgp 65536 neighbor 192.0.2.43 disable-connected-check
-    - set protocols bgp 65536 neighbor 192.0.2.43 advertisement-interval 72
-    - set protocols bgp 65536 neighbor 192.0.2.43 capability dynamic
-    - set protocols bgp 65536 neighbor 192.0.2.43 timers holdtime 30
-    - set protocols bgp 65536 neighbor 192.0.2.43 timers keepalive 10
-    - set protocols bgp 65536 neighbor 203.0.113.0 capability orf prefix-list receive
-    - set protocols bgp 65536 redistribute static route-map map01
-    - set protocols bgp 65536 network 203.0.113.0/24 route-map map01
-    - set protocols bgp 65536 parameters always-compare-med
-    - set protocols bgp 65536 parameters dampening half-life 33
-    - set protocols bgp 65536 parameters dampening max-suppress-time 20
-    - set protocols bgp 65536 parameters dampening re-use 60
-    - set protocols bgp 65536 parameters dampening start-suppress-time 5
-
-deleted:
-  commands:
-    - delete protocols bgp 65536 timers
-    - delete protocols bgp 65536 maximum-paths
-    - delete protocols bgp 65536 parameters
-    - delete protocols bgp 65536 aggregate-address
-    - delete protocols bgp 65536 network
-    - delete protocols bgp 65536 redistribute
-    - delete protocols bgp 65536 neighbor 5001::64
-    - delete protocols bgp 65536 neighbor 203.0.113.5
-    - delete protocols bgp 65536 neighbor 192.0.2.25
-
-rendered:
-  commands:
-    - set interfaces ethernet eth1 firewall in name 'INBOUND'
-    - set interfaces ethernet eth1 firewall out name 'OUTBOUND'
-    - set interfaces ethernet eth1 firewall local name 'LOCAL'
-    - set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL'
-    - set interfaces ethernet eth2 firewall in name 'INBOUND'
-    - set interfaces ethernet eth2 firewall out name 'OUTBOUND'
-    - set interfaces ethernet eth2 firewall local name 'LOCAL'
-    - set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL'
-
-populate:
-  global:
-    aggregate_address:
-      - prefix: 192.0.2.0/24
-        summary_only: true
-      - prefix: 203.0.113.0/24
-        as_set: true
-    as_number: 65536
-    bgp_params:
-      bestpath:
-        as_path: confed
-        compare_routerid: true
-      confederation:
-        - identifier: 66
-        - peers: 20
-        - peers: 55
-      default:
-        no_ipv4_unicast: true
-      router_id: 192.1.2.9
-    maximum_paths:
-      - count: 20
-        path: ebgp
-      - count: 55
-        path: ibgp
-    neighbor:
-      - address: 192.0.2.25
-        disable_connected_check: true
-        timers:
-          holdtime: 30
-          keepalive: 10
-      - address: 203.0.113.5
-        attribute_unchanged:
-          as_path: true
-          med: true
-          next_hop: true
-        ebgp_multihop: 2
-        remote_as: 101
-        update_source: 192.0.2.25
-      - address: 5001::64
-        distribute_list:
-          - acl: 20
-            action: export
-          - acl: 40
-            action: import
-        maximum_prefix: 34
-    network:
-      - address: 192.1.13.0/24
-        backdoor: true
-    redistribute:
-      - protocol: connected
-        route_map: map01
-      - metric: 45
-        protocol: kernel
-    timers:
-      keepalive: 35
diff --git a/tests/integration/targets/vyos_bgp_global/vars/pre-v1_4.yaml b/tests/integration/targets/vyos_bgp_global/vars/pre-v1_4.yaml
new file mode 100644
index 0000000..efac1b9
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/vars/pre-v1_4.yaml
@@ -0,0 +1,91 @@
+---
+merged:
+  commands:
+    - set protocols bgp 65536 parameters bestpath as-path confed
+    - set protocols bgp 65536 parameters bestpath compare-routerid
+    - set protocols bgp 65536 parameters default local-pref 100
+    - set protocols bgp 65536 parameters router-id 192.1.2.9
+    - set protocols bgp 65536 timers keepalive 35
+  after:
+    as_number: 65536
+    bgp_params:
+      bestpath:
+        as_path: confed
+        compare_routerid: true
+      default:
+        local_pref: 100
+      router_id: 192.1.2.9
+    timers:
+      keepalive: 35
+
+replaced:
+  commands:
+    - delete protocols bgp 65536 timers
+    - delete protocols bgp 65536 parameters router-id 192.1.2.9
+    - delete protocols bgp 65536 parameters default
+    - delete protocols bgp 65536 parameters confederation
+    - delete protocols bgp 65536 neighbor 5001::64
+    - delete protocols bgp 65536 neighbor 203.0.113.5
+    - delete protocols bgp 65536 neighbor 192.0.2.25
+    - set protocols bgp 65536 neighbor 192.0.2.43 disable-connected-check
+    - set protocols bgp 65536 neighbor 192.0.2.43 advertisement-interval 72
+    - set protocols bgp 65536 neighbor 192.0.2.43 capability dynamic
+    - set protocols bgp 65536 neighbor 192.0.2.43 timers holdtime 30
+    - set protocols bgp 65536 neighbor 192.0.2.43 timers keepalive 10
+    - set protocols bgp 65536 neighbor 192.0.2.43 remote-as 102
+    - set protocols bgp 65536 neighbor 203.0.113.0 capability dynamic
+    - set protocols bgp 65536 neighbor 203.0.113.0 remote-as 102
+    - set protocols bgp 65536 parameters always-compare-med
+    - set protocols bgp 65536 parameters dampening half-life 33
+    - set protocols bgp 65536 parameters dampening max-suppress-time 20
+    - set protocols bgp 65536 parameters dampening re-use 60
+    - set protocols bgp 65536 parameters dampening start-suppress-time 5
+
+deleted:
+  commands:
+    - delete protocols bgp 65536 timers
+    - delete protocols bgp 65536 parameters
+    - delete protocols bgp 65536 neighbor 5001::64
+    - delete protocols bgp 65536 neighbor 203.0.113.5
+    - delete protocols bgp 65536 neighbor 192.0.2.25
+
+rendered:
+  commands:
+    - set interfaces ethernet eth1 firewall in name 'INBOUND'
+    - set interfaces ethernet eth1 firewall out name 'OUTBOUND'
+    - set interfaces ethernet eth1 firewall local name 'LOCAL'
+    - set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL'
+    - set interfaces ethernet eth2 firewall in name 'INBOUND'
+    - set interfaces ethernet eth2 firewall out name 'OUTBOUND'
+    - set interfaces ethernet eth2 firewall local name 'LOCAL'
+    - set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL'
+
+populate:
+  global:
+    as_number: 65536
+    bgp_params:
+      bestpath:
+        as_path: confed
+        compare_routerid: true
+      confederation:
+        - identifier: 66
+        - peers: 20
+        - peers: 55
+      default:
+        local_pref: 100
+      router_id: 192.1.2.9
+    neighbor:
+      - address: 192.0.2.25
+        disable_connected_check: true
+        timers:
+          holdtime: 30
+          keepalive: 10
+        remote_as: 102
+      - address: 203.0.113.5
+        ebgp_multihop: 2
+        remote_as: 101
+        update_source: 192.0.2.25
+      - address: 5001::64
+        remote_as: 103
+    timers:
+      keepalive: 35
diff --git a/tests/integration/targets/vyos_bgp_global/vars/v1_4.yaml b/tests/integration/targets/vyos_bgp_global/vars/v1_4.yaml
new file mode 100644
index 0000000..1dd462b
--- /dev/null
+++ b/tests/integration/targets/vyos_bgp_global/vars/v1_4.yaml
@@ -0,0 +1,90 @@
+---
+merged:
+  commands:
+    - set protocols bgp system-as 65536
+    - set protocols bgp parameters bestpath as-path confed
+    - set protocols bgp parameters bestpath compare-routerid
+    - set protocols bgp parameters default local-pref 100
+    - set protocols bgp parameters router-id 192.1.2.9
+    - set protocols bgp timers keepalive 35
+  after:
+    as_number: 65536
+    bgp_params:
+      bestpath:
+        as_path: confed
+        compare_routerid: true
+      default:
+        local_pref: 100
+      router_id: 192.1.2.9
+    timers:
+      keepalive: 35
+
+replaced:
+  commands:
+    - delete protocols bgp timers
+    - delete protocols bgp parameters router-id 192.1.2.9
+    - delete protocols bgp parameters default
+    - delete protocols bgp parameters confederation
+    - delete protocols bgp neighbor 5001::64
+    - delete protocols bgp neighbor 203.0.113.5
+    - delete protocols bgp neighbor 192.0.2.25
+    - set protocols bgp neighbor 192.0.2.43 disable-connected-check
+    - set protocols bgp neighbor 192.0.2.43 advertisement-interval 72
+    - set protocols bgp neighbor 192.0.2.43 capability dynamic
+    - set protocols bgp neighbor 192.0.2.43 timers holdtime 30
+    - set protocols bgp neighbor 192.0.2.43 timers keepalive 10
+    - set protocols bgp neighbor 192.0.2.43 remote-as 102
+    - set protocols bgp neighbor 203.0.113.0 capability dynamic
+    - set protocols bgp neighbor 203.0.113.0 remote-as 102
+    - set protocols bgp parameters always-compare-med
+    - set protocols bgp parameters dampening half-life 33
+    - set protocols bgp parameters dampening max-suppress-time 20
+    - set protocols bgp parameters dampening re-use 60
+    - set protocols bgp parameters dampening start-suppress-time 5
+
+deleted:
+  commands:
+    - delete protocols bgp timers
+    - delete protocols bgp parameters
+    - delete protocols bgp neighbor 5001::64
+    - delete protocols bgp neighbor 203.0.113.5
+    - delete protocols bgp neighbor 192.0.2.25
+
+rendered:
+  commands:
+    - set interfaces ethernet eth1 firewall in name 'INBOUND'
+    - set interfaces ethernet eth1 firewall out name 'OUTBOUND'
+    - set interfaces ethernet eth1 firewall local name 'LOCAL'
+    - set interfaces ethernet eth1 firewall local ipv6-name 'V6-LOCAL'
+    - set interfaces ethernet eth2 firewall in name 'INBOUND'
+    - set interfaces ethernet eth2 firewall out name 'OUTBOUND'
+    - set interfaces ethernet eth2 firewall local name 'LOCAL'
+    - set interfaces ethernet eth2 firewall local ipv6-name 'V6-LOCAL'
+
+populate:
+  global:
+    as_number: 65536
+    bgp_params:
+      bestpath:
+        as_path: confed
+        compare_routerid: true
+      confederation:
+        - identifier: 66
+        - peers: 20
+        - peers: 55
+      router_id: 192.1.2.9
+    neighbor:
+      - address: 192.0.2.25
+        disable_connected_check: true
+        timers:
+          holdtime: 30
+          keepalive: 10
+        remote_as: 102
+      - address: 203.0.113.5
+        ebgp_multihop: 2
+        remote_as: 101
+        update_source: 192.0.2.25
+      - address: 5001::64
+        remote_as: 103
+    timers:
+      keepalive: 35
-- 
cgit v1.2.3