# Advice on configuring Mikrotik devices with Ansible

**URL:** <https://forum.mikrotik.com/t/advice-on-configuring-mikrotik-devices-with-ansible/170325>\
**Category:** Scripting\
**Created:** [October 13, 2023, 7:05am UTC](https://forum.mikrotik.com/t/advice-on-configuring-mikrotik-devices-with-ansible/170325 "2023-10-13T07:05:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![olivier2831](https://forum.mikrotik.com/letter_avatar/olivier2831/32/6_449c533f586939b6e5f246632a46421f.png) [@olivier2831](https://forum.mikrotik.com/u/olivier2831)\
**Post date:** [October 13, 2023, 7:05am UTC](https://forum.mikrotik.com/t/advice-on-configuring-mikrotik-devices-with-ansible/170325/1 "2023-10-13T07:05:46Z")

</div>

Hello,

I’m quite used now to manage Debian hosts with Ansible.  
I would like to also manage Mikrotik RouterOS device with Ansible.

The whole picture is:

- using Flashfig to initialize the platform (management IP, firmware, certs, creds, management accounts, enabling/disabling protocols, …)
- using Ansible to set IP addresses and VLAN, firwalling

Which Ansible module shall I favor first (and why) as some seem to use SSH while some use RouterOS API ?  
Are you aware of Mikrotik directly contributing to these modules ?

Best regards

---

<div class="post-metadata">

**Author:** ![olivier2831](https://forum.mikrotik.com/letter_avatar/olivier2831/32/6_449c533f586939b6e5f246632a46421f.png) [@olivier2831](https://forum.mikrotik.com/u/olivier2831)\
**Post date:** [October 13, 2023, 7:11am UTC](https://forum.mikrotik.com/t/advice-on-configuring-mikrotik-devices-with-ansible/170325/2 "2023-10-13T07:11:39Z")

</div>

When using CLI to configure RouterOS, I had trouble to script idempotent operations such as “create VLAN 10 if it doesn’t exist”.  
I don’t mean it’s not possible to write idempotent scripts with CLI, I only mean I had trouble doing so.

One expected benefit from using Ansible is to ease idempotent configuration.

---

<div class="post-metadata">

**Author:** ![irrwitzer](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/irrwitzer/32/2948_2.png) [@irrwitzer](https://forum.mikrotik.com/u/irrwitzer)\
**Post date:** [October 13, 2023, 10:07am UTC](https://forum.mikrotik.com/t/advice-on-configuring-mikrotik-devices-with-ansible/170325/3 "2023-10-13T10:07:44Z")

</div>

Hi Olivier,

I dind’t find a perfect ansible module for this, when I was searching in early 2022. Maybe things have changed, but I’m currently using  
[https://docs.ansible.com/ansible/latest/collections/community/routeros/index.html](https://docs.ansible.com/ansible/latest/collections/community/routeros/index.html)

```plaintext
---
collections:
  - community.routeros

```

For basic stuff. It’s not really indempotent though.

Other links in my notes:

[https://yetiops.net/posts/ansible-for-networking-part-6-mikrotik-routeros/](https://yetiops.net/posts/ansible-for-networking-part-6-mikrotik-routeros/)  
[https://docs.ansible.com/ansible/latest/collections/community/routeros/docsite/ssh-guide.html](https://docs.ansible.com/ansible/latest/collections/community/routeros/docsite/ssh-guide.html)

---

<div class="post-metadata">

**Author:** ![memelchenkov](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/memelchenkov/32/2671_2.png) [@memelchenkov](https://forum.mikrotik.com/u/memelchenkov)\
**Post date:** [October 13, 2023, 11:20am UTC](https://forum.mikrotik.com/t/advice-on-configuring-mikrotik-devices-with-ansible/170325/4 "2023-10-13T11:20:08Z")

</div>

Check TR069 instead, will it work for you or not.

---

<div class="post-metadata">

**Author:** ![olivier2831](https://forum.mikrotik.com/letter_avatar/olivier2831/32/6_449c533f586939b6e5f246632a46421f.png) [@olivier2831](https://forum.mikrotik.com/u/olivier2831)\
**Post date:** [October 13, 2023, 11:23am UTC](https://forum.mikrotik.com/t/advice-on-configuring-mikrotik-devices-with-ansible/170325/5 "2023-10-13T11:23:35Z")

</div>

> [@](#):
>
> Check TR069 instead, will it work for you or not.

Does TR069 support VLAN configuration (ie not just for WAN port but for bridge or interface) ?
