Posted on August 10, 2018 5:42 pm
 |  Asked by Yasunori Ogawa
 |  352 views
RESOLVED
0
0
Print Friendly, PDF & Email

Hello

I want to configure BGP with Ansible 2.6.
I’m using playbook with following files.
[host_vars]
bgppeers:
– peer: 169.254.252.1
password: password

[roles/delete_bgppeer/tasks/main.yml]
– name: Delete BGP Peer
eos_config:
src: delete_bgppeer.j2

[roles/delete_bgppeer/templates/delete_bgppeer.j2]
router bgp 65534
{% for i in bgppeers %}
no neighbor {{ i.peer }}
{% endfor %}

When I execute the playbook ,the following error message occur.
fatal: [otmclhcs-01]: FAILED! => {“changed”: false, “data”: “no neighbor 169.254.252.1\r\n% Invalid input\r\notmclhcs-01(config-s-ansibl)#”, “msg”: “Error on executing commands [‘no neighbor 169.254.252.1’]”}

But I changed template as follows,the playbook complete normally.
router ospf 1
{% for i in bgppeers %}
router-id {{ i.peer }}
{% endfor %}

I seem This error occurs only when configuring router bgp with src module.
How can I solve this problem?

0
Posted by edmund
Answered on August 10, 2018 7:17 pm

What is the current bgp configuration on the switch? The error has the prompt as (config-s-ansibl). If you were in bgp sub-mode it would be (config-s-ansibl-router-bgp) so it looks like the no neighbor command was attempted in global config mode, which is not valid.

Hi Edmund

Thank you for your reply.
I’m using router bgp 65534 command in delete_bgppeer.j2

router bgp 65534
{% for i in bgppeers %}
no neighbor {{ i.peer }}
{% endfor %}

But Ansible don’t change to bgp sub-mode.
When I’m configuring ospf,Ansible change to ospf sub-mode.

router ospf 1
{% for i in bgppeers %}
router-id {{ i.peer }}
{% endfor %}
I can not understand these differences.

(Yasunori Ogawa at August 16, 2018 8:14 am)
0
Posted by Yasunori Ogawa
Answered on August 20, 2018 7:09 am

I used 2 spaces for jinja 2 template where I needed 3 spaces of indentation.
This problem was solved by fixing the indent to 3 spaces.

Post your Answer

You must be logged in to post an answer.