diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 8ddd51c..d51363f 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -41,21 +41,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_' ~ bridge_name | replace('-', '_')]['ipv4']['address'] }}" - - "neighbor {{ hostvars['secondary']['ansible_' ~ bridge_name | replace('-', '_')]['ipv4']['address'] }} remote-as 5678" + - "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" - network 192.168.1.0/24 - address-family ipv4 unicast - - " neighbor {{ hostvars['secondary']['ansible_' ~ bridge_name | replace('-', '_')]['ipv4']['address'] }} prefix-list pl-allowed-adv out" + - " neighbor {{ hostvars['secondary']['ansible_facts'][bridge_name | replace('-', '_')]['ipv4']['address'] }} 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_' ~ bridge_name | replace('-', '_')]['ipv4']['address'] }}" - - "neighbor {{ hostvars['primary']['ansible_' ~ bridge_name | replace('-', '_')]['ipv4']['address'] }} remote-as 1234" + - "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" - address-family ipv4 unicast - - " neighbor {{ hostvars['primary']['ansible_' ~ bridge_name | replace('-', '_')]['ipv4']['address'] }} prefix-list pl-allowed-adv in" + - " neighbor {{ hostvars['primary']['ansible_facts'][bridge_name | replace('-', '_')]['ipv4']['address'] }} 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 @@ -64,8 +64,8 @@ provisioner: prepare: prepare.yml converge: playbook.yml verify: verify.yml - # config_options: - # defaults: - # inject_facts_as_vars: false + config_options: + defaults: + inject_facts_as_vars: false scenario: name: default diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml index 026989e..1ecf320 100644 --- a/molecule/default/verify.yml +++ b/molecule/default/verify.yml @@ -26,7 +26,7 @@ - name: Ping vlans ip address shell: | set -e - ping -c2 "{{ hostvars[inventory_hostname]['ansible_eth1']['ipv4']['address'] }}" + ping -c2 "{{ hostvars[inventory_hostname]['ansible_facts']['eth1']['ipv4']['address'] }}" changed_when: false register: _ping_vlan until: _ping_vlan is success diff --git a/tasks/frr_install.yml b/tasks/frr_install.yml index b0d57d3..7b3a33e 100644 --- a/tasks/frr_install.yml +++ b/tasks/frr_install.yml @@ -18,7 +18,7 @@ become_user: root block: - name: Apply package management distro specific configuration - include_tasks: "frr_install_{{ ansible_pkg_mgr | lower }}.yml" + include_tasks: "frr_install_{{ ansible_facts['pkg_mgr'] | lower }}.yml" - name: Install required distro packages package: diff --git a/tasks/main.yml b/tasks/main.yml index 6f46a94..314abe0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -14,7 +14,7 @@ # limitations under the License. - name: Gather variables for each operating system - include_vars: "{{ ansible_os_family | lower }}.yml" + include_vars: "{{ ansible_facts['os_family'] | lower }}.yml" - name: Create required vlan interfaces include_tasks: frr_vlans.yml diff --git a/templates/frr.conf.j2 b/templates/frr.conf.j2 index 3ebed53..04a5623 100644 --- a/templates/frr.conf.j2 +++ b/templates/frr.conf.j2 @@ -3,7 +3,7 @@ ! frr defaults traditional ! -hostname {{ ansible_hostname }} +hostname {{ ansible_facts['hostname'] }} log syslog informational ! ! staticd config diff --git a/vars/debian.yml b/vars/debian.yml index e913c08..989919a 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -25,7 +25,7 @@ frr_repos_keys: state: present frr_repos: - - repo: "deb {{ apt_repo_url | default('https://deb.frrouting.org/frr ' ~ ansible_distribution_release ~ ' frr-stable') }}" + - repo: "deb {{ apt_repo_url | default('https://deb.frrouting.org/frr ' ~ ansible_facts['distribution_release'] ~ ' frr-stable') }}" state: present filename: "frr"