Remove become blocks from tasks

As become is applied to most of the tasks in the role, let's remove
them and suggest applying become on the playbook level instead.
We do not have become applied on task level in any other managed
role.

This also helps to workaround PAM/apparmor issue with CentOS
in Docker for molecule test.

We also deal with an intermittent failures in Docker, as interface
naming/ordering is random and non-deterministic with no way of
controlling it.

Thus, instead of detecting an IP address by interface, we hardcode the
IP address both for containers and in FRR configurations.

Change-Id: I73471dd895eea5c6abfbec24681c796d5e7d813d
This commit is contained in:
Dmitriy Rabotyagov 2025-04-02 09:52:10 +02:00
parent 7583efdafa
commit 970fab180c
8 changed files with 78 additions and 97 deletions

View File

@ -2,5 +2,7 @@
- name: Installing frr
hosts: frr
become: true
become_user: root
roles:
- role: "frrouting"

View File

@ -14,8 +14,6 @@
# limitations under the License.
- name: Restart frr
become: true
become_user: root
service:
name: frr
state: restarted
@ -23,8 +21,6 @@
register: frr_restart
- name: Reload frr
become: true
become_user: root
service:
name: frr
state: reloaded

View File

@ -16,8 +16,12 @@ platforms:
pre_build_image: true
networks:
- name: frr
ipv4_address: 172.18.0.2
- name: noop
docker_networks:
- name: frr
ipam_config:
- subnet: 172.18.0.0/16
- name: noop
ipam_config:
- subnet: 192.168.1.0/24
@ -30,6 +34,7 @@ platforms:
pre_build_image: true
networks:
- name: frr
ipv4_address: 172.18.0.3
provisioner:
name: ansible
lint:
@ -41,21 +46,21 @@ provisioner:
- ip route 10.0.0.0/24 192.168.1.10
frr_bgpd_config:
- router bgp 1234
- "bgp router-id {{ hostvars['primary']['ansible_facts'][bridge_name | replace('-', '_')]['ipv4']['address'] }}"
- "neighbor {{ hostvars['secondary']['ansible_facts'][bridge_name | replace('-', '_')]['ipv4']['address'] }} remote-as 5678"
- "bgp router-id 172.18.0.2"
- "neighbor 172.18.0.3 remote-as 5678"
- network 192.168.1.0/24
- address-family ipv4 unicast
- " neighbor {{ hostvars['secondary']['ansible_facts'][bridge_name | replace('-', '_')]['ipv4']['address'] }} prefix-list pl-allowed-adv out"
- " neighbor 172.18.0.3 prefix-list pl-allowed-adv out"
- "exit-address-family"
- ip prefix-list pl-allowed-adv seq 5 permit 192.168.1.0/24
- ip prefix-list pl-allowed-adv seq 10 deny any
secondary:
frr_bgpd_config:
- router bgp 5678
- "bgp router-id {{ hostvars['secondary']['ansible_facts'][bridge_name | replace('-', '_')]['ipv4']['address'] }}"
- "neighbor {{ hostvars['primary']['ansible_facts'][bridge_name | replace('-', '_')]['ipv4']['address'] }} remote-as 1234"
- "bgp router-id 172.18.0.3"
- "neighbor 172.18.0.2 remote-as 1234"
- address-family ipv4 unicast
- " neighbor {{ hostvars['primary']['ansible_facts'][bridge_name | replace('-', '_')]['ipv4']['address'] }} prefix-list pl-allowed-adv in"
- " neighbor 172.18.0.2 prefix-list pl-allowed-adv in"
- exit-address-family
- ip prefix-list pl-allowed-adv seq 5 permit 192.168.1.0/24
- ip prefix-list pl-allowed-adv seq 10 deny any

View File

@ -2,8 +2,5 @@
- name: Installing frr
hosts: frr
vars:
bridge_name: eth0
roles:
- role: "{{ playbook_dir | dirname | dirname | basename }}"

View File

@ -15,9 +15,6 @@
- name: Installing frr
hosts: all
vars:
bridge_name: default
tasks:
- name: Wait after service restart
pause:
@ -43,15 +40,11 @@
when: ansible_facts.services['frr.service'].state != 'running'
- name: Get summary
become: true
become_user: root
command: "vtysh -c 'show bgp summary'"
register: _frr_get_summary
changed_when: false
- name: Get routes
become: true
become_user: root
command: "vtysh -c 'show ip route'"
register: _frr_get_routes
changed_when: false

View File

@ -13,10 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Install frr
become: true
become_user: root
block:
- name: Apply package management distro specific configuration
include_tasks: "frr_install_{{ ansible_facts['pkg_mgr'] | lower }}.yml"

View File

@ -13,10 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Configure frr
become: true
become_user: root
block:
- name: Enable integrated config
lineinfile:
create: true

View File

@ -13,10 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Add required vlans
become: true
become_user: root
block:
- name: Install vlan package
package:
name: vlan