Vyos BGP configuration using Ansible

I have this BGP configuration setup on Vyos 1.3

vyos@vyos# show protocols bgp
bgp 65535 {
address-family {
ipv4-unicast {
network 172.16.0.0/16 {
}
}
ipv6-unicast {
network 2001:db8:1::/48 {
}
}
}
neighbor 192.168.50.233 {
address-family {
ipv4-unicast {
}
}
remote-as 65535
}

I want to implement this same configuration using ansible module.

I have checked BGP module.
https://docs.ansible.com/ansible/latest/collections/vyos/vyos/vyos_bgp_global_module.html

There are parameters for setting up ‘network’, ‘remote-as’, ‘route-reflector’ etc but
I did not see any parameters for ‘address-family’, ‘ipv4-unicast’ and setting up network inside it.
Also I did not see any parameter to setup as-path-list specifying regex.

How should I proceed further? I know I can use jinja file but is there any way I can use BGP modules to setup above BGP configuration?

Hi @qwerty ,

Try using this ansible module to handle ‘address-family’:
https://docs.ansible.com/ansible/latest/collections/vyos/vyos/vyos_bgp_address_family_module.html#ansible-collections-vyos-vyos-vyos-bgp-address-family-module

And you can configure any commands with this module:
https://docs.ansible.com/ansible/latest/collections/vyos/vyos/vyos_config_module.html#ansible-collections-vyos-vyos-vyos-config-module

Hi @Nikolay ,

I am getting this error.

ERROR! couldn’t resolve module/action ‘vyos.vyos.vyos_bgp_global’. This often indicates a misspelling, missing collection, or incorrect module path.

I am using Ansible 2.9 version. Do I need to use ansible 4.0 version to work with BGP modules?

Don’t worry I figured it out.
I installed the required modules using ansible-galaxy and it worked.

Hi @qwerty,

Yes, these modules are part of ansible-galaxy.
The good news is that they work :grinning: