Compare commits

..

No commits in common. "main" and "2.0.0-a1" have entirely different histories.

142 changed files with 1533 additions and 19341 deletions

View file

@ -1,6 +0,0 @@
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# Reformat YAML: https://github.com/ansible-collections/community.routeros/pull/369
08152376de116e7d933d19ee25318f7a2eb222ae

View file

@ -1,15 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
ci:
patterns:
- "*"

View file

@ -1,9 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
backport_branch_prefix: patchback/backports/
backport_label_prefix: backport-
target_branch_prefix: stable-
...

186
.github/workflows/ansible-test.yml vendored Normal file
View file

@ -0,0 +1,186 @@
name: CI
on:
# Run CI against all pushes (direct commits, also merged PRs), Pull Requests
push:
pull_request:
# Run CI once per day (at 06:00 UTC)
schedule:
- cron: '0 6 * * *'
jobs:
###
# Sanity tests (REQUIRED)
#
# https://docs.ansible.com/ansible/latest/dev_guide/testing_sanity.html
sanity:
name: Sanity (Ⓐ${{ matrix.ansible }})
strategy:
matrix:
ansible:
# It's important that Sanity is tested against all stable-X.Y branches
# Testing against `devel` may fail as new tests are added.
- stable-2.9
- stable-2.10
- stable-2.11
- devel
runs-on: ubuntu-latest
steps:
# ansible-test requires the collection to be in a directory in the form
# .../ansible_collections/community/routeros/
- name: Check out code
uses: actions/checkout@v2
with:
path: ansible_collections/community/routeros
- name: Set up Python
uses: actions/setup-python@v2
with:
# it is just required to run that once as "ansible-test sanity" in the docker image
# will run on all python versions it supports.
python-version: 3.8
# Install the head of the given branch (devel, stable-2.10)
- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
- name: Install collection dependencies
run: git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.netcommon.git ansible_collections/ansible/netcommon
# NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429)
# run: ansible-galaxy collection install ansible.netcommon -p .
# run ansible-test sanity inside of Docker.
# The docker container has all the pinned dependencies that are required
# and all python versions ansible supports.
- name: Run sanity tests
run: ansible-test sanity --docker -v --color
working-directory: ./ansible_collections/community/routeros
###
# Unit tests (OPTIONAL)
#
# https://docs.ansible.com/ansible/latest/dev_guide/testing_units.html
units:
runs-on: ubuntu-latest
name: Units (Ⓐ${{ matrix.ansible }})
strategy:
# As soon as the first unit test fails, cancel the others to free up the CI queue
fail-fast: true
matrix:
ansible:
- stable-2.9
- stable-2.10
- stable-2.11
- devel
steps:
- name: Check out code
uses: actions/checkout@v2
with:
path: ansible_collections/community/routeros
- name: Set up Python ${{ matrix.ansible }}
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
- name: Install collection dependencies
run: git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.netcommon.git ansible_collections/ansible/netcommon
# NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429)
# run: ansible-galaxy collection install ansible.netcommon -p .
# Run the unit tests
- name: Run unit tests for all Python versions
run: ansible-test units -v --color --docker --coverage
working-directory: ./ansible_collections/community/routeros
# ansible-test support producing code coverage date
- name: Generate coverage report
run: ansible-test coverage xml -v --requirements --group-by command --group-by version
working-directory: ./ansible_collections/community/routeros
# See the reports at https://codecov.io/gh/ansible_collections/ansible-collections/community.routeros
- uses: codecov/codecov-action@v1
with:
fail_ci_if_error: false
###
# Integration tests (RECOMMENDED)
#
# https://docs.ansible.com/ansible/latest/dev_guide/testing_integration.html
# If the application you are testing is available as a docker container and you want to test
# multiple versions see the following for an example:
# https://github.com/ansible-collections/community.zabbix/tree/master/.github/workflows
# integration:
# runs-on: ubuntu-latest
# name: I (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }}})
# strategy:
# fail-fast: false
# matrix:
# ansible:
# - stable-2.9
# - stable-2.10
# - stable-2.11
# - devel
# python:
# - 2.6
# - 2.7
# - 3.5
# - 3.6
# - 3.7
# - 3.8
# - 3.9
# - "3.10"
# exclude:
# - ansible: stable-2.9
# python: 3.9
# - ansible: stable-2.9
# python: "3.10"
# - ansible: stable-2.10
# python: "3.10"
# - ansible: stable-2.11
# python: "3.10"
#
# steps:
# - name: Check out code
# uses: actions/checkout@v2
# with:
# path: ansible_collections/community/routeros
#
# - name: Set up Python ${{ matrix.ansible }}
# uses: actions/setup-python@v2
# with:
# python-version: 3.8
#
# - name: Install ansible-base (${{ matrix.ansible }})
# run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
#
# - name: Install collection dependencies
# run: git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.netcommon.git ansible_collections/ansible/netcommon
# # NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429)
# # run: ansible-galaxy collection install ansible.netcommon -p .
#
# # Run the integration tests
# - name: Run integration test
# run: ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python }} --docker --coverage
# working-directory: ./ansible_collections/community/routeros
#
# # ansible-test support producing code coverage date
# - name: Generate coverage report
# run: ansible-test coverage xml -v --requirements --group-by command --group-by version
# working-directory: ./ansible_collections/community/routeros
#
# # See the reports at https://codecov.io/gh/ansible_collections/ansible-collections/community.routeros
# - uses: codecov/codecov-action@v1
# with:
# fail_ci_if_error: false

View file

@ -1,97 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
name: Collection Docs
concurrency:
group: docs-pr-${{ github.head_ref }}
cancel-in-progress: true
'on':
pull_request_target:
types: [opened, synchronize, reopened, closed]
env:
GHP_BASE_URL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
jobs:
build-docs:
permissions:
contents: read
name: Build Ansible Docs
uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-pr.yml@main
with:
collection-name: community.routeros
init-lenient: false
init-fail-on-error: true
squash-hierarchy: true
init-project: Community.Routeros Collection
init-copyright: Community.Routeros Contributors
init-title: Community.Routeros Collection Documentation
init-html-short-title: Community.Routeros Collection Docs
init-extra-html-theme-options: |
documentation_home_url=https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/branch/main/
render-file-line: '> * `$<status>` [$<path_tail>](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr/${{ github.event.number }}/$<path_tail>)'
provide-link-targets: |
ansible_collections.ansible.netcommon.network_cli_connection__parameter-ssh_type
publish-docs-gh-pages:
# for now we won't run this on forks
if: github.repository == 'ansible-collections/community.routeros'
permissions:
contents: write
pages: write
id-token: write
needs: [build-docs]
name: Publish Ansible Docs
uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-publish-gh-pages.yml@main
with:
artifact-name: ${{ needs.build-docs.outputs.artifact-name }}
action: ${{ (github.event.action == 'closed' || needs.build-docs.outputs.changed != 'true') && 'teardown' || 'publish' }}
publish-gh-pages-branch: true
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
comment:
permissions:
pull-requests: write
runs-on: ubuntu-latest
needs: [build-docs, publish-docs-gh-pages]
name: PR comments
steps:
- name: PR comment
uses: ansible-community/github-docs-build/actions/ansible-docs-build-comment@main
with:
body-includes: '## Docs Build'
reactions: heart
action: ${{ needs.build-docs.outputs.changed != 'true' && 'remove' || '' }}
on-closed-body: |
## Docs Build 📝
This PR is closed and any previously published docsite has been unpublished.
on-merged-body: |
## Docs Build 📝
Thank you for contribution!✨
This PR has been merged and the docs are now incorporated into `main`:
${{ env.GHP_BASE_URL }}/branch/main
body: |
## Docs Build 📝
Thank you for contribution!✨
The docs for **this PR** have been published here:
${{ env.GHP_BASE_URL }}/pr/${{ github.event.number }}
You can compare to the docs for the `main` branch here:
${{ env.GHP_BASE_URL }}/branch/main
The docsite for **this PR** is also available for download as an artifact from this run:
${{ needs.build-docs.outputs.artifact-url }}
File changes:
${{ needs.build-docs.outputs.diff-files-rendered }}
${{ needs.build-docs.outputs.diff-rendered }}

View file

@ -1,55 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
name: Collection Docs
concurrency:
group: docs-push-${{ github.sha }}
cancel-in-progress: true
'on':
push:
branches:
- main
- stable-*
tags:
- '*'
# Run CI once per day (at 05:15 UTC)
schedule:
- cron: '15 5 * * *'
# Allow manual trigger (for newer antsibull-docs, sphinx-ansible-theme, ... versions)
workflow_dispatch:
jobs:
build-docs:
permissions:
contents: read
name: Build Ansible Docs
uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-push.yml@main
with:
collection-name: community.routeros
init-lenient: true
init-fail-on-error: true
squash-hierarchy: true
init-project: Community.Routeros Collection
init-copyright: Community.Routeros Contributors
init-title: Community.Routeros Collection Documentation
init-html-short-title: Community.Routeros Collection Docs
init-extra-html-theme-options: |
documentation_home_url=https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/branch/main/
publish-docs-gh-pages:
# for now we won't run this on forks
if: github.repository == 'ansible-collections/community.routeros'
permissions:
contents: write
pages: write
id-token: write
needs: [build-docs]
name: Publish Ansible Docs
uses: ansible-community/github-docs-build/.github/workflows/_shared-docs-build-publish-gh-pages.yml@main
with:
artifact-name: ${{ needs.build-docs.outputs.artifact-name }}
publish-gh-pages-branch: true
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

40
.github/workflows/extra-tests.yml vendored Normal file
View file

@ -0,0 +1,40 @@
name: extra-tests
on:
# Run CI against all pushes (direct commits, also merged PRs), Pull Requests
push:
pull_request:
# Run CI once per day (at 06:00 UTC)
# This ensures that even if there haven't been commits that we are still testing against latest version of ansible-test for each ansible-base version
schedule:
- cron: '0 6 * * *'
env:
NAMESPACE: community
COLLECTION_NAME: routeros
jobs:
extra-sanity:
name: Extra Sanity
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
with:
path: ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install ansible-core
run: pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
- name: Install collection dependencies
run: git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git ./ansible_collections/community/internal_test_tools
# NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429)
# run: ansible-galaxy collection install community.internal_test_tools -p .
- name: Run sanity tests
run: ../../community/internal_test_tools/tools/run.py --color
working-directory: ./ansible_collections/${{env.NAMESPACE}}/${{env.COLLECTION_NAME}}

82
.github/workflows/import-galaxy.yml vendored Normal file
View file

@ -0,0 +1,82 @@
name: import-galaxy
on:
# Run CI against all pushes (direct commits, also merged PRs) to main, and all Pull Requests
push:
branches:
- main
pull_request:
env:
# Adjust this to your collection
NAMESPACE: community
COLLECTION_NAME: routeros
jobs:
build-collection:
name: Build collection artifact
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
with:
path: ./checkout
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install ansible-core
run: pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
- name: Make sure galaxy.yml has version entry
run: >-
python -c
'import yaml ;
f = open("galaxy.yml", "rb") ;
data = yaml.safe_load(f) ;
f.close() ;
data["version"] = data.get("version") or "0.0.1" ;
f = open("galaxy.yml", "wb") ;
f.write(yaml.dump(data).encode("utf-8")) ;
f.close() ;
'
working-directory: ./checkout
- name: Build collection
run: ansible-galaxy collection build
working-directory: ./checkout
- name: Copy artifact into subdirectory
run: mkdir ./artifact && mv ./checkout/${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}-*.tar.gz ./artifact
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: ${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}-${{ github.sha }}
path: ./artifact/
import-galaxy:
name: Import artifact with Galaxy importer
runs-on: ubuntu-latest
needs:
- build-collection
steps:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install ansible-core
run: pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
- name: Install galaxy-importer
run: pip install galaxy-importer --disable-pip-version-check
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: ${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}-${{ github.sha }}
- name: Run Galaxy importer
run: python -m galaxy_importer.main ${{ env.NAMESPACE }}-${{ env.COLLECTION_NAME }}-*.tar.gz

View file

@ -1,35 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
name: nox
'on':
push:
branches:
- main
- stable-*
pull_request:
# Run CI once per day (at 05:15 UTC)
schedule:
- cron: '15 5 * * *'
workflow_dispatch:
jobs:
nox:
runs-on: ubuntu-latest
name: "Run extra sanity tests"
steps:
- name: Check out collection
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Run nox
uses: ansible-community/antsibull-nox@main
ansible-test:
uses: ansible-community/antsibull-nox/.github/workflows/reusable-nox-matrix.yml@main
with:
upload-codecov: true
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

5
.gitignore vendored
View file

@ -1,10 +1,5 @@
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
/tests/output/ /tests/output/
/changelogs/.plugin-cache.yaml /changelogs/.plugin-cache.yaml
/tests/integration/inventory
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/

View file

@ -1,53 +0,0 @@
---
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2025 Felix Fontein <felix@fontein.de>
extends: default
ignore: |
/changelogs/
rules:
line-length:
max: 300
level: error
document-start:
present: true
document-end: false
truthy:
level: error
allowed-values:
- 'true'
- 'false'
indentation:
spaces: 2
indent-sequences: true
key-duplicates: enable
trailing-spaces: enable
new-line-at-end-of-file: disable
hyphens:
max-spaces-after: 1
empty-lines:
max: 2
max-start: 0
max-end: 0
commas:
max-spaces-before: 0
min-spaces-after: 1
max-spaces-after: 1
colons:
max-spaces-before: 0
max-spaces-after: 1
brackets:
min-spaces-inside: 0
max-spaces-inside: 0
braces:
min-spaces-inside: 0
max-spaces-inside: 1
octal-values:
forbid-implicit-octal: true
forbid-explicit-octal: true
comments:
min-spaces-from-content: 1
comments-indentation: false

View file

@ -1,54 +0,0 @@
---
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2025 Felix Fontein <felix@fontein.de>
extends: default
ignore: |
/changelogs/
rules:
line-length:
max: 160
level: error
document-start:
present: false
document-end:
present: false
truthy:
level: error
allowed-values:
- 'true'
- 'false'
indentation:
spaces: 2
indent-sequences: true
key-duplicates: enable
trailing-spaces: enable
new-line-at-end-of-file: disable
hyphens:
max-spaces-after: 1
empty-lines:
max: 2
max-start: 0
max-end: 0
commas:
max-spaces-before: 0
min-spaces-after: 1
max-spaces-after: 1
colons:
max-spaces-before: 0
max-spaces-after: 1
brackets:
min-spaces-inside: 0
max-spaces-inside: 0
braces:
min-spaces-inside: 0
max-spaces-inside: 1
octal-values:
forbid-implicit-octal: true
forbid-explicit-octal: true
comments:
min-spaces-from-content: 1
comments-indentation: false

View file

@ -1,54 +0,0 @@
---
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2025 Felix Fontein <felix@fontein.de>
extends: default
ignore: |
/changelogs/
rules:
line-length:
max: 160
level: error
document-start:
present: true
document-end:
present: false
truthy:
level: error
allowed-values:
- 'true'
- 'false'
indentation:
spaces: 2
indent-sequences: true
key-duplicates: enable
trailing-spaces: enable
new-line-at-end-of-file: disable
hyphens:
max-spaces-after: 1
empty-lines:
max: 2
max-start: 0
max-end: 0
commas:
max-spaces-before: 0
min-spaces-after: 1
max-spaces-after: 1
colons:
max-spaces-before: 0
max-spaces-after: 1
brackets:
min-spaces-inside: 0
max-spaces-inside: 0
braces:
min-spaces-inside: 0
max-spaces-inside: 1
octal-values:
forbid-implicit-octal: true
forbid-explicit-octal: true
comments:
min-spaces-from-content: 1
comments-indentation: false

View file

@ -1,53 +0,0 @@
---
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2025 Felix Fontein <felix@fontein.de>
extends: default
ignore: |
/changelogs/
rules:
line-length:
max: 160
level: error
document-start: disable
document-end:
present: false
truthy:
level: error
allowed-values:
- 'true'
- 'false'
indentation:
spaces: 2
indent-sequences: true
key-duplicates: enable
trailing-spaces: enable
new-line-at-end-of-file: disable
hyphens:
max-spaces-after: 1
empty-lines:
max: 2
max-start: 0
max-end: 0
commas:
max-spaces-before: 0
min-spaces-after: 1
max-spaces-after: 1
colons:
max-spaces-before: 0
max-spaces-after: 1
brackets:
min-spaces-inside: 0
max-spaces-inside: 0
braces:
min-spaces-inside: 0
max-spaces-inside: 1
octal-values:
forbid-implicit-octal: true
forbid-explicit-octal: true
comments:
min-spaces-from-content: 1
comments-indentation: false

View file

@ -1,977 +0,0 @@
# Community RouterOS Release Notes
**Topics**
- <a href="#v3-9-0">v3\.9\.0</a>
- <a href="#release-summary">Release Summary</a>
- <a href="#minor-changes">Minor Changes</a>
- <a href="#bugfixes">Bugfixes</a>
- <a href="#v3-8-1">v3\.8\.1</a>
- <a href="#release-summary-1">Release Summary</a>
- <a href="#bugfixes-1">Bugfixes</a>
- <a href="#v3-8-0">v3\.8\.0</a>
- <a href="#release-summary-2">Release Summary</a>
- <a href="#minor-changes-1">Minor Changes</a>
- <a href="#v3-7-0">v3\.7\.0</a>
- <a href="#release-summary-3">Release Summary</a>
- <a href="#minor-changes-2">Minor Changes</a>
- <a href="#v3-6-0">v3\.6\.0</a>
- <a href="#release-summary-4">Release Summary</a>
- <a href="#minor-changes-3">Minor Changes</a>
- <a href="#v3-5-0">v3\.5\.0</a>
- <a href="#release-summary-5">Release Summary</a>
- <a href="#minor-changes-4">Minor Changes</a>
- <a href="#v3-4-0">v3\.4\.0</a>
- <a href="#release-summary-6">Release Summary</a>
- <a href="#minor-changes-5">Minor Changes</a>
- <a href="#bugfixes-2">Bugfixes</a>
- <a href="#v3-3-0">v3\.3\.0</a>
- <a href="#release-summary-7">Release Summary</a>
- <a href="#minor-changes-6">Minor Changes</a>
- <a href="#v3-2-0">v3\.2\.0</a>
- <a href="#release-summary-8">Release Summary</a>
- <a href="#minor-changes-7">Minor Changes</a>
- <a href="#v3-1-0">v3\.1\.0</a>
- <a href="#release-summary-9">Release Summary</a>
- <a href="#minor-changes-8">Minor Changes</a>
- <a href="#bugfixes-3">Bugfixes</a>
- <a href="#v3-0-0">v3\.0\.0</a>
- <a href="#release-summary-10">Release Summary</a>
- <a href="#breaking-changes--porting-guide">Breaking Changes / Porting Guide</a>
- <a href="#removed-features-previously-deprecated">Removed Features \(previously deprecated\)</a>
- <a href="#v2-20-0">v2\.20\.0</a>
- <a href="#release-summary-11">Release Summary</a>
- <a href="#minor-changes-9">Minor Changes</a>
- <a href="#v2-19-0">v2\.19\.0</a>
- <a href="#release-summary-12">Release Summary</a>
- <a href="#minor-changes-10">Minor Changes</a>
- <a href="#v2-18-0">v2\.18\.0</a>
- <a href="#release-summary-13">Release Summary</a>
- <a href="#minor-changes-11">Minor Changes</a>
- <a href="#deprecated-features">Deprecated Features</a>
- <a href="#bugfixes-4">Bugfixes</a>
- <a href="#v2-17-0">v2\.17\.0</a>
- <a href="#release-summary-14">Release Summary</a>
- <a href="#minor-changes-12">Minor Changes</a>
- <a href="#v2-16-0">v2\.16\.0</a>
- <a href="#release-summary-15">Release Summary</a>
- <a href="#minor-changes-13">Minor Changes</a>
- <a href="#v2-15-0">v2\.15\.0</a>
- <a href="#release-summary-16">Release Summary</a>
- <a href="#minor-changes-14">Minor Changes</a>
- <a href="#v2-14-0">v2\.14\.0</a>
- <a href="#release-summary-17">Release Summary</a>
- <a href="#minor-changes-15">Minor Changes</a>
- <a href="#v2-13-0">v2\.13\.0</a>
- <a href="#release-summary-18">Release Summary</a>
- <a href="#minor-changes-16">Minor Changes</a>
- <a href="#bugfixes-5">Bugfixes</a>
- <a href="#v2-12-0">v2\.12\.0</a>
- <a href="#release-summary-19">Release Summary</a>
- <a href="#minor-changes-17">Minor Changes</a>
- <a href="#v2-11-0">v2\.11\.0</a>
- <a href="#release-summary-20">Release Summary</a>
- <a href="#minor-changes-18">Minor Changes</a>
- <a href="#v2-10-0">v2\.10\.0</a>
- <a href="#release-summary-21">Release Summary</a>
- <a href="#minor-changes-19">Minor Changes</a>
- <a href="#bugfixes-6">Bugfixes</a>
- <a href="#v2-9-0">v2\.9\.0</a>
- <a href="#release-summary-22">Release Summary</a>
- <a href="#minor-changes-20">Minor Changes</a>
- <a href="#bugfixes-7">Bugfixes</a>
- <a href="#v2-8-3">v2\.8\.3</a>
- <a href="#release-summary-23">Release Summary</a>
- <a href="#known-issues">Known Issues</a>
- <a href="#v2-8-2">v2\.8\.2</a>
- <a href="#release-summary-24">Release Summary</a>
- <a href="#bugfixes-8">Bugfixes</a>
- <a href="#v2-8-1">v2\.8\.1</a>
- <a href="#release-summary-25">Release Summary</a>
- <a href="#bugfixes-9">Bugfixes</a>
- <a href="#v2-8-0">v2\.8\.0</a>
- <a href="#release-summary-26">Release Summary</a>
- <a href="#minor-changes-21">Minor Changes</a>
- <a href="#bugfixes-10">Bugfixes</a>
- <a href="#v2-7-0">v2\.7\.0</a>
- <a href="#release-summary-27">Release Summary</a>
- <a href="#minor-changes-22">Minor Changes</a>
- <a href="#bugfixes-11">Bugfixes</a>
- <a href="#v2-6-0">v2\.6\.0</a>
- <a href="#release-summary-28">Release Summary</a>
- <a href="#minor-changes-23">Minor Changes</a>
- <a href="#bugfixes-12">Bugfixes</a>
- <a href="#v2-5-0">v2\.5\.0</a>
- <a href="#release-summary-29">Release Summary</a>
- <a href="#minor-changes-24">Minor Changes</a>
- <a href="#bugfixes-13">Bugfixes</a>
- <a href="#v2-4-0">v2\.4\.0</a>
- <a href="#release-summary-30">Release Summary</a>
- <a href="#minor-changes-25">Minor Changes</a>
- <a href="#bugfixes-14">Bugfixes</a>
- <a href="#known-issues-1">Known Issues</a>
- <a href="#v2-3-1">v2\.3\.1</a>
- <a href="#release-summary-31">Release Summary</a>
- <a href="#known-issues-2">Known Issues</a>
- <a href="#v2-3-0">v2\.3\.0</a>
- <a href="#release-summary-32">Release Summary</a>
- <a href="#minor-changes-26">Minor Changes</a>
- <a href="#bugfixes-15">Bugfixes</a>
- <a href="#v2-2-1">v2\.2\.1</a>
- <a href="#release-summary-33">Release Summary</a>
- <a href="#bugfixes-16">Bugfixes</a>
- <a href="#v2-2-0">v2\.2\.0</a>
- <a href="#release-summary-34">Release Summary</a>
- <a href="#minor-changes-27">Minor Changes</a>
- <a href="#bugfixes-17">Bugfixes</a>
- <a href="#new-modules">New Modules</a>
- <a href="#v2-1-0">v2\.1\.0</a>
- <a href="#release-summary-35">Release Summary</a>
- <a href="#minor-changes-28">Minor Changes</a>
- <a href="#bugfixes-18">Bugfixes</a>
- <a href="#new-modules-1">New Modules</a>
- <a href="#v2-0-0">v2\.0\.0</a>
- <a href="#release-summary-36">Release Summary</a>
- <a href="#minor-changes-29">Minor Changes</a>
- <a href="#breaking-changes--porting-guide-1">Breaking Changes / Porting Guide</a>
- <a href="#bugfixes-19">Bugfixes</a>
- <a href="#new-plugins">New Plugins</a>
- <a href="#filter">Filter</a>
- <a href="#v1-2-0">v1\.2\.0</a>
- <a href="#release-summary-37">Release Summary</a>
- <a href="#minor-changes-30">Minor Changes</a>
- <a href="#bugfixes-20">Bugfixes</a>
- <a href="#v1-1-0">v1\.1\.0</a>
- <a href="#release-summary-38">Release Summary</a>
- <a href="#minor-changes-31">Minor Changes</a>
- <a href="#v1-0-1">v1\.0\.1</a>
- <a href="#release-summary-39">Release Summary</a>
- <a href="#bugfixes-21">Bugfixes</a>
- <a href="#v1-0-0">v1\.0\.0</a>
- <a href="#release-summary-40">Release Summary</a>
- <a href="#bugfixes-22">Bugfixes</a>
- <a href="#v0-1-1">v0\.1\.1</a>
- <a href="#release-summary-41">Release Summary</a>
- <a href="#bugfixes-23">Bugfixes</a>
- <a href="#v0-1-0">v0\.1\.0</a>
- <a href="#release-summary-42">Release Summary</a>
- <a href="#minor-changes-32">Minor Changes</a>
<a id="v3-9-0"></a>
## v3\.9\.0
<a id="release-summary"></a>
### Release Summary
Bugfix and feature release\.
<a id="minor-changes"></a>
### Minor Changes
* api\_info\, api modify \- add <code>remote\-log\-format</code>\, <code>remote\-protocol</code>\, and <code>event\-delimiter</code> to <code>system logging action</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/381](https\://github\.com/ansible\-collections/community\.routeros/pull/381)\)\.
* api\_info\, api\_modify \- add <code>disable\-link\-local\-address</code> and <code>stale\-neighbor\-timeout</code> fields to <code>ipv6 settings</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/380](https\://github\.com/ansible\-collections/community\.routeros/pull/380)\)\.
* api\_info\, api\_modify \- adjust neighbor limit fields in <code>ipv6 settings</code> to match RouterOS 7\.18 and newer \([https\://github\.com/ansible\-collections/community\.routeros/pull/380](https\://github\.com/ansible\-collections/community\.routeros/pull/380)\)\.
* api\_info\, api\_modify \- set <code>passthrough</code> default in <code>ip firewall mangle</code> to <code>true</code> for RouterOS 7\.19 and newer \([https\://github\.com/ansible\-collections/community\.routeros/pull/382](https\://github\.com/ansible\-collections/community\.routeros/pull/382)\)\.
* api\_info\, api\_modify \- since RouterOS 7\.17 VRF is supported for OVPN server\. It now supports multiple entries\, while <code>api\_modify</code> so far only accepted a single entry\. The <code>interface ovpn\-server server</code> path now allows multiple entries on RouterOS 7\.17 and newer \([https\://github\.com/ansible\-collections/community\.routeros/pull/383](https\://github\.com/ansible\-collections/community\.routeros/pull/383)\)\.
<a id="bugfixes"></a>
### Bugfixes
* routeros terminal plugin \- fix <code>terminal\_stdout\_re</code> pattern to handle long system identities when connecting to RouterOS through SSH \([https\://github\.com/ansible\-collections/community\.routeros/pull/386](https\://github\.com/ansible\-collections/community\.routeros/pull/386)\)\.
<a id="v3-8-1"></a>
## v3\.8\.1
<a id="release-summary-1"></a>
### Release Summary
Bugfix release\.
<a id="bugfixes-1"></a>
### Bugfixes
* facts and api\_facts modules \- prevent deprecation warnings when used with ansible\-core 2\.19 \([https\://github\.com/ansible\-collections/community\.routeros/pull/384](https\://github\.com/ansible\-collections/community\.routeros/pull/384)\)\.
<a id="v3-8-0"></a>
## v3\.8\.0
<a id="release-summary-2"></a>
### Release Summary
Feature release\.
<a id="minor-changes-1"></a>
### Minor Changes
* api\_info\, api\_modify \- add <code>interface ethernet switch port\-isolation</code> which is supported since RouterOS 6\.43 \([https\://github\.com/ansible\-collections/community\.routeros/pull/375](https\://github\.com/ansible\-collections/community\.routeros/pull/375)\)\.
* api\_info\, api\_modify \- add <code>routing bfd configuration</code>\. Officially stabilized BFD support for BGP and OSPF is available since RouterOS 7\.11
\([https\://github\.com/ansible\-collections/community\.routeros/pull/375](https\://github\.com/ansible\-collections/community\.routeros/pull/375)\)\.
* api\_modify\, api\_info \- support API path <code>ip ipsec mode\-config</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/376](https\://github\.com/ansible\-collections/community\.routeros/pull/376)\)\.
<a id="v3-7-0"></a>
## v3\.7\.0
<a id="release-summary-3"></a>
### Release Summary
Feature release\.
<a id="minor-changes-2"></a>
### Minor Changes
* api\_find\_and\_modify \- allow to control whether <code>dynamic</code> and/or <code>builtin</code> entries are ignored with the new <code>ignore\_dynamic</code> and <code>ignore\_builtin</code> options \([https\://github\.com/ansible\-collections/community\.routeros/issues/372](https\://github\.com/ansible\-collections/community\.routeros/issues/372)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/373](https\://github\.com/ansible\-collections/community\.routeros/pull/373)\)\.
* api\_info\, api\_modify \- add <code>port\-cost\-mode</code> to <code>interface bridge</code> which is supported since RouterOS 7\.13 \([https\://github\.com/ansible\-collections/community\.routeros/pull/371](https\://github\.com/ansible\-collections/community\.routeros/pull/371)\)\.
<a id="v3-6-0"></a>
## v3\.6\.0
<a id="release-summary-4"></a>
### Release Summary
Feature release\.
<a id="minor-changes-3"></a>
### Minor Changes
* api\_info\, api\_modify \- add <code>mdns\-repeat\-ifaces</code> to <code>ip dns</code> for RouterOS 7\.16 and newer \([https\://github\.com/ansible\-collections/community\.routeros/pull/358](https\://github\.com/ansible\-collections/community\.routeros/pull/358)\)\.
* api\_info\, api\_modify \- field name change in <code>routing bgp connection</code> path implemented by RouterOS 7\.19 and newer \([https\://github\.com/ansible\-collections/community\.routeros/pull/360](https\://github\.com/ansible\-collections/community\.routeros/pull/360)\)\.
* api\_info\, api\_modify \- rename <code>is\-responder</code> property in <code>interface wireguard peers</code> to <code>responder</code> for RouterOS 7\.17 and newer \([https\://github\.com/ansible\-collections/community\.routeros/pull/364](https\://github\.com/ansible\-collections/community\.routeros/pull/364)\)\.
<a id="v3-5-0"></a>
## v3\.5\.0
<a id="release-summary-5"></a>
### Release Summary
Feature release\.
<a id="minor-changes-4"></a>
### Minor Changes
* api\_info\, api\_modify \- change default for <code>/ip/cloud/ddns\-enabled</code> for RouterOS 7\.17 and newer from <code>yes</code> to <code>auto</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/350](https\://github\.com/ansible\-collections/community\.routeros/pull/350)\)\.
<a id="v3-4-0"></a>
## v3\.4\.0
<a id="release-summary-6"></a>
### Release Summary
Feature and bugfix release\.
<a id="minor-changes-5"></a>
### Minor Changes
* api\_info\, api\_modify \- add support for the <code>ip dns forwarders</code> path implemented by RouterOS 7\.17 and newer \([https\://github\.com/ansible\-collections/community\.routeros/pull/343](https\://github\.com/ansible\-collections/community\.routeros/pull/343)\)\.
<a id="bugfixes-2"></a>
### Bugfixes
* api\_info\, api\_modify \- remove the primary key <code>action</code> from the <code>interface wifi provisioning</code> path\, since RouterOS also allows to create completely duplicate entries \([https\://github\.com/ansible\-collections/community\.routeros/issues/344](https\://github\.com/ansible\-collections/community\.routeros/issues/344)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/345](https\://github\.com/ansible\-collections/community\.routeros/pull/345)\)\.
<a id="v3-3-0"></a>
## v3\.3\.0
<a id="release-summary-7"></a>
### Release Summary
Feature release\.
<a id="minor-changes-6"></a>
### Minor Changes
* api\_info\, api\_modify \- add missing attribute <code>require\-message\-auth</code> for the <code>radius</code> path which exists since RouterOS version 7\.15 \([https\://github\.com/ansible\-collections/community\.routeros/issues/338](https\://github\.com/ansible\-collections/community\.routeros/issues/338)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/339](https\://github\.com/ansible\-collections/community\.routeros/pull/339)\)\.
* api\_info\, api\_modify \- add the <code>interface 6to4</code> path\. Used to manage IPv6 tunnels via tunnel\-brokers like HE\, where native IPv6 is not provided \([https\://github\.com/ansible\-collections/community\.routeros/pull/342](https\://github\.com/ansible\-collections/community\.routeros/pull/342)\)\.
* api\_info\, api\_modify \- add the <code>interface wireless access\-list</code> and <code>interface wireless connect\-list</code> paths \([https\://github\.com/ansible\-collections/community\.routeros/issues/284](https\://github\.com/ansible\-collections/community\.routeros/issues/284)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/340](https\://github\.com/ansible\-collections/community\.routeros/pull/340)\)\.
* api\_info\, api\_modify \- add the <code>use\-interface\-duid</code> option for <code>ipv6 dhcp\-client</code> path\. This option prevents issues with Fritzbox modems and routers\, when using virtual interfaces \(like VLANs\) may create duplicated records in hosts config\, this breaks original \"expose\-host\" function\. Also add the <code>script</code>\, <code>custom\-duid</code> and <code>validate\-server\-duid</code> as backport from 7\.15 version update \([https\://github\.com/ansible\-collections/community\.routeros/pull/341](https\://github\.com/ansible\-collections/community\.routeros/pull/341)\)\.
<a id="v3-2-0"></a>
## v3\.2\.0
<a id="release-summary-8"></a>
### Release Summary
Feature release\.
<a id="minor-changes-7"></a>
### Minor Changes
* api\_info\, api\_modify \- add support for the <code>routing filter community\-list</code> path implemented by RouterOS 7 and newer \([https\://github\.com/ansible\-collections/community\.routeros/pull/331](https\://github\.com/ansible\-collections/community\.routeros/pull/331)\)\.
<a id="v3-1-0"></a>
## v3\.1\.0
<a id="release-summary-9"></a>
### Release Summary
Bugfix and feature release\.
<a id="minor-changes-8"></a>
### Minor Changes
* api\_info\, api\_modify \- add missing fields <code>comment</code>\, <code>next\-pool</code> to <code>ip pool</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/327](https\://github\.com/ansible\-collections/community\.routeros/pull/327)\)\.
<a id="bugfixes-3"></a>
### Bugfixes
* api\_info\, api\_modify \- fields <code>log</code> and <code>log\-prefix</code> in paths <code>ip firewall filter</code>\, <code>ip firewall mangle</code>\, <code>ip firewall nat</code>\, <code>ip firewall raw</code> now have the correct default values \([https\://github\.com/ansible\-collections/community\.routeros/pull/324](https\://github\.com/ansible\-collections/community\.routeros/pull/324)\)\.
<a id="v3-0-0"></a>
## v3\.0\.0
<a id="release-summary-10"></a>
### Release Summary
Major release that drops support for End of Life Python versions and fixes check mode for community\.routeros\.command\.
<a id="breaking-changes--porting-guide"></a>
### Breaking Changes / Porting Guide
* command \- the module no longer declares that it supports check mode \([https\://github\.com/ansible\-collections/community\.routeros/pull/318](https\://github\.com/ansible\-collections/community\.routeros/pull/318)\)\.
<a id="removed-features-previously-deprecated"></a>
### Removed Features \(previously deprecated\)
* The collection no longer supports Ansible 2\.9\, ansible\-base 2\.10\, ansible\-core 2\.11\, ansible\-core 2\.12\, ansible\-core 2\.13\, and ansible\-core 2\.14\. If you need to continue using End of Life versions of Ansible/ansible\-base/ansible\-core\, please use community\.routeros 2\.x\.y \([https\://github\.com/ansible\-collections/community\.routeros/pull/318](https\://github\.com/ansible\-collections/community\.routeros/pull/318)\)\.
<a id="v2-20-0"></a>
## v2\.20\.0
<a id="release-summary-11"></a>
### Release Summary
Feature release\.
<a id="minor-changes-9"></a>
### Minor Changes
* api\_info\, api\_modify \- add new parameters from the RouterOS 7\.16 release \([https\://github\.com/ansible\-collections/community\.routeros/pull/323](https\://github\.com/ansible\-collections/community\.routeros/pull/323)\)\.
* api\_info\, api\_modify \- add support <code>interface l2tp\-client</code> configuration \([https\://github\.com/ansible\-collections/community\.routeros/pull/322](https\://github\.com/ansible\-collections/community\.routeros/pull/322)\)\.
* api\_info\, api\_modify \- add support for the <code>cpu\-frequency</code>\, <code>memory\-frequency</code>\, <code>preboot\-etherboot</code> and <code>preboot\-etherboot\-server</code> properties in <code>system routerboard settings</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/320](https\://github\.com/ansible\-collections/community\.routeros/pull/320)\)\.
* api\_info\, api\_modify \- add support for the <code>matching\-type</code> property in <code>ip dhcp\-server matcher</code> introduced by RouterOS 7\.16 \([https\://github\.com/ansible\-collections/community\.routeros/pull/321](https\://github\.com/ansible\-collections/community\.routeros/pull/321)\)\.
<a id="v2-19-0"></a>
## v2\.19\.0
<a id="release-summary-12"></a>
### Release Summary
Feature release\.
<a id="minor-changes-10"></a>
### Minor Changes
* api\_info\, api\_modify \- add support for the <code>ip dns adlist</code> path implemented by RouterOS 7\.15 and newer \([https\://github\.com/ansible\-collections/community\.routeros/pull/310](https\://github\.com/ansible\-collections/community\.routeros/pull/310)\)\.
* api\_info\, api\_modify \- add support for the <code>mld\-version</code> and <code>multicast\-querier</code> properties in <code>interface bridge</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/315](https\://github\.com/ansible\-collections/community\.routeros/pull/315)\)\.
* api\_info\, api\_modify \- add support for the <code>routing filter num\-list</code> path implemented by RouterOS 7 and newer \([https\://github\.com/ansible\-collections/community\.routeros/pull/313](https\://github\.com/ansible\-collections/community\.routeros/pull/313)\)\.
* api\_info\, api\_modify \- add support for the <code>routing igmp\-proxy</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/309](https\://github\.com/ansible\-collections/community\.routeros/pull/309)\)\.
* api\_modify\, api\_info \- add read\-only <code>default</code> field to <code>snmp community</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/311](https\://github\.com/ansible\-collections/community\.routeros/pull/311)\)\.
<a id="v2-18-0"></a>
## v2\.18\.0
<a id="release-summary-13"></a>
### Release Summary
Feature release\.
<a id="minor-changes-11"></a>
### Minor Changes
* api\_info \- allow to restrict the output by limiting fields to specific values with the new <code>restrict</code> option \([https\://github\.com/ansible\-collections/community\.routeros/pull/305](https\://github\.com/ansible\-collections/community\.routeros/pull/305)\)\.
* api\_info\, api\_modify \- add support for the <code>ip dhcp\-server matcher</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/300](https\://github\.com/ansible\-collections/community\.routeros/pull/300)\)\.
* api\_info\, api\_modify \- add support for the <code>ipv6 nd prefix</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/303](https\://github\.com/ansible\-collections/community\.routeros/pull/303)\)\.
* api\_info\, api\_modify \- add support for the <code>name</code> and <code>is\-responder</code> properties under the <code>interface wireguard peers</code> path introduced in RouterOS 7\.15 \([https\://github\.com/ansible\-collections/community\.routeros/pull/304](https\://github\.com/ansible\-collections/community\.routeros/pull/304)\)\.
* api\_info\, api\_modify \- add support for the <code>routing ospf static\-neighbor</code> path in RouterOS 7 \([https\://github\.com/ansible\-collections/community\.routeros/pull/302](https\://github\.com/ansible\-collections/community\.routeros/pull/302)\)\.
* api\_info\, api\_modify \- set default for <code>force</code> in <code>ip dhcp\-server option</code> to an explicit <code>false</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/300](https\://github\.com/ansible\-collections/community\.routeros/pull/300)\)\.
* api\_modify \- allow to restrict what is updated by limiting fields to specific values with the new <code>restrict</code> option \([https\://github\.com/ansible\-collections/community\.routeros/pull/305](https\://github\.com/ansible\-collections/community\.routeros/pull/305)\)\.
<a id="deprecated-features"></a>
### Deprecated Features
* The collection deprecates support for all Ansible/ansible\-base/ansible\-core versions that are currently End of Life\, [according to the ansible\-core support matrix](https\://docs\.ansible\.com/ansible\-core/devel/reference\_appendices/release\_and\_maintenance\.html\#ansible\-core\-support\-matrix)\. This means that the next major release of the collection will no longer support Ansible 2\.9\, ansible\-base 2\.10\, ansible\-core 2\.11\, ansible\-core 2\.12\, ansible\-core 2\.13\, and ansible\-core 2\.14\.
<a id="bugfixes-4"></a>
### Bugfixes
* api\_modify\, api\_info \- change the default of <code>ingress\-filtering</code> in paths <code>interface bridge</code> and <code>interface bridge port</code> back to <code>false</code> for RouterOS before version 7 \([https\://github\.com/ansible\-collections/community\.routeros/pull/305](https\://github\.com/ansible\-collections/community\.routeros/pull/305)\)\.
<a id="v2-17-0"></a>
## v2\.17\.0
<a id="release-summary-14"></a>
### Release Summary
Feature release\.
<a id="minor-changes-12"></a>
### Minor Changes
* api\_info\, api\_modify \- add <code>system health settings</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/294](https\://github\.com/ansible\-collections/community\.routeros/pull/294)\)\.
* api\_info\, api\_modify \- add missing path <code>/system resource irq rps</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/295](https\://github\.com/ansible\-collections/community\.routeros/pull/295)\)\.
* api\_info\, api\_modify \- add parameter <code>host\-key\-type</code> for <code>ip ssh</code> path \([https\://github\.com/ansible\-collections/community\.routeros/issues/280](https\://github\.com/ansible\-collections/community\.routeros/issues/280)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/297](https\://github\.com/ansible\-collections/community\.routeros/pull/297)\)\.
<a id="v2-16-0"></a>
## v2\.16\.0
<a id="release-summary-15"></a>
### Release Summary
Feature release\.
<a id="minor-changes-13"></a>
### Minor Changes
* api\_info\, api\_modify \- add missing path <code>/ppp secret</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/286](https\://github\.com/ansible\-collections/community\.routeros/pull/286)\)\.
* api\_info\, api\_modify \- minor changes <code>/interface ethernet</code> path fields \([https\://github\.com/ansible\-collections/community\.routeros/pull/288](https\://github\.com/ansible\-collections/community\.routeros/pull/288)\)\.
<a id="v2-15-0"></a>
## v2\.15\.0
<a id="release-summary-16"></a>
### Release Summary
Feature release\.
<a id="minor-changes-14"></a>
### Minor Changes
* api\_info\, api\_modify \- Add RouterOS 7\.x support to <code>/mpls ldp</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/271](https\://github\.com/ansible\-collections/community\.routeros/pull/271)\)\.
* api\_info\, api\_modify \- add <code>/ip route rule</code> path for RouterOS 6\.x \([https\://github\.com/ansible\-collections/community\.routeros/pull/278](https\://github\.com/ansible\-collections/community\.routeros/pull/278)\)\.
* api\_info\, api\_modify \- add <code>/routing filter</code> path for RouterOS 6\.x \([https\://github\.com/ansible\-collections/community\.routeros/pull/279](https\://github\.com/ansible\-collections/community\.routeros/pull/279)\)\.
* api\_info\, api\_modify \- add default value for <code>from\-pool</code> field in <code>/ipv6 address</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/270](https\://github\.com/ansible\-collections/community\.routeros/pull/270)\)\.
* api\_info\, api\_modify \- add missing path <code>/interface pppoe\-server server</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/273](https\://github\.com/ansible\-collections/community\.routeros/pull/273)\)\.
* api\_info\, api\_modify \- add missing path <code>/ip dhcp\-relay</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/276](https\://github\.com/ansible\-collections/community\.routeros/pull/276)\)\.
* api\_info\, api\_modify \- add missing path <code>/queue simple</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/269](https\://github\.com/ansible\-collections/community\.routeros/pull/269)\)\.
* api\_info\, api\_modify \- add missing path <code>/queue type</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/274](https\://github\.com/ansible\-collections/community\.routeros/pull/274)\)\.
* api\_info\, api\_modify \- add missing paths <code>/routing bgp aggregate</code>\, <code>/routing bgp network</code> and <code>/routing bgp peer</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/277](https\://github\.com/ansible\-collections/community\.routeros/pull/277)\)\.
* api\_info\, api\_modify \- add support for paths <code>/mpls interface</code>\, <code>/mpls ldp accept\-filter</code>\, <code>/mpls ldp advertise\-filter</code> and <code>mpls ldp interface</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/272](https\://github\.com/ansible\-collections/community\.routeros/pull/272)\)\.
<a id="v2-14-0"></a>
## v2\.14\.0
<a id="release-summary-17"></a>
### Release Summary
Feature release\.
<a id="minor-changes-15"></a>
### Minor Changes
* api\_info\, api\_modify \- add read\-only fields <code>installed\-version</code>\, <code>latest\-version</code> and <code>status</code> in <code>system package update</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/263](https\://github\.com/ansible\-collections/community\.routeros/pull/263)\)\.
* api\_info\, api\_modify \- added support for <code>interface wifi</code> and its sub\-paths \([https\://github\.com/ansible\-collections/community\.routeros/pull/266](https\://github\.com/ansible\-collections/community\.routeros/pull/266)\)\.
* api\_info\, api\_modify \- remove default value for read\-only <code>running</code> field in <code>interface wireless</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/264](https\://github\.com/ansible\-collections/community\.routeros/pull/264)\)\.
<a id="v2-13-0"></a>
## v2\.13\.0
<a id="release-summary-18"></a>
### Release Summary
Bugfix and feature release\.
<a id="minor-changes-16"></a>
### Minor Changes
* api\_info\, api\_modify \- make path <code>user group</code> modifiable and add <code>comment</code> attribute \([https\://github\.com/ansible\-collections/community\.routeros/issues/256](https\://github\.com/ansible\-collections/community\.routeros/issues/256)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/257](https\://github\.com/ansible\-collections/community\.routeros/pull/257)\)\.
* api\_modify\, api\_info \- add support for the <code>ip vrf</code> path in RouterOS 7 \([https\://github\.com/ansible\-collections/community\.routeros/pull/259](https\://github\.com/ansible\-collections/community\.routeros/pull/259)\)
<a id="bugfixes-5"></a>
### Bugfixes
* facts \- fix date not getting removed for idempotent config export \([https\://github\.com/ansible\-collections/community\.routeros/pull/262](https\://github\.com/ansible\-collections/community\.routeros/pull/262)\)\.
<a id="v2-12-0"></a>
## v2\.12\.0
<a id="release-summary-19"></a>
### Release Summary
Feature release\.
<a id="minor-changes-17"></a>
### Minor Changes
* api\_info\, api\_modify \- add <code>interface ovpn\-client</code> path \([https\://github\.com/ansible\-collections/community\.routeros/issues/242](https\://github\.com/ansible\-collections/community\.routeros/issues/242)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/244](https\://github\.com/ansible\-collections/community\.routeros/pull/244)\)\.
* api\_info\, api\_modify \- add <code>radius</code> path \([https\://github\.com/ansible\-collections/community\.routeros/issues/241](https\://github\.com/ansible\-collections/community\.routeros/issues/241)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/245](https\://github\.com/ansible\-collections/community\.routeros/pull/245)\)\.
* api\_info\, api\_modify \- add <code>routing rule</code> path \([https\://github\.com/ansible\-collections/community\.routeros/issues/162](https\://github\.com/ansible\-collections/community\.routeros/issues/162)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/246](https\://github\.com/ansible\-collections/community\.routeros/pull/246)\)\.
* api\_info\, api\_modify \- add missing path <code>routing bgp template</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/243](https\://github\.com/ansible\-collections/community\.routeros/pull/243)\)\.
* api\_info\, api\_modify \- add support for the <code>tx\-power</code> attribute in <code>interface wireless</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/239](https\://github\.com/ansible\-collections/community\.routeros/pull/239)\)\.
* api\_info\, api\_modify \- removed <code>host</code> primary key in <code>tool netwatch</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/248](https\://github\.com/ansible\-collections/community\.routeros/pull/248)\)\.
* api\_modify\, api\_info \- added support for <code>interface wifiwave2</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/226](https\://github\.com/ansible\-collections/community\.routeros/pull/226)\)\.
<a id="v2-11-0"></a>
## v2\.11\.0
<a id="release-summary-20"></a>
### Release Summary
Feature and bugfix release\.
<a id="minor-changes-18"></a>
### Minor Changes
* api\_info\, api\_modify \- add missing DoH parameters <code>doh\-max\-concurrent\-queries</code>\, <code>doh\-max\-server\-connections</code>\, and <code>doh\-timeout</code> to the <code>ip dns</code> path \([https\://github\.com/ansible\-collections/community\.routeros/issues/230](https\://github\.com/ansible\-collections/community\.routeros/issues/230)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/235](https\://github\.com/ansible\-collections/community\.routeros/pull/235)\)
* api\_info\, api\_modify \- add missing parameters <code>address\-list</code>\, <code>address\-list\-timeout</code>\, <code>randomise\-ports</code>\, and <code>realm</code> to subpaths of the <code>ip firewall</code> path \([https\://github\.com/ansible\-collections/community\.routeros/issues/236](https\://github\.com/ansible\-collections/community\.routeros/issues/236)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/237](https\://github\.com/ansible\-collections/community\.routeros/pull/237)\)\.
* api\_info\, api\_modify \- mark the <code>interface wireless</code> parameter <code>running</code> as read\-only \([https\://github\.com/ansible\-collections/community\.routeros/pull/233](https\://github\.com/ansible\-collections/community\.routeros/pull/233)\)\.
* api\_info\, api\_modify \- set the default value to <code>false</code> for the <code>disabled</code> parameter in some more paths where it can be seen in the documentation \([https\://github\.com/ansible\-collections/community\.routeros/pull/237](https\://github\.com/ansible\-collections/community\.routeros/pull/237)\)\.
* api\_modify \- add missing <code>comment</code> attribute to <code>/routing id</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/234](https\://github\.com/ansible\-collections/community\.routeros/pull/234)\)\.
* api\_modify \- add missing attributes to the <code>routing bgp connection</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/234](https\://github\.com/ansible\-collections/community\.routeros/pull/234)\)\.
* api\_modify \- add versioning to the <code>/tool e\-mail</code> path \(RouterOS 7\.12 release\) \([https\://github\.com/ansible\-collections/community\.routeros/pull/234](https\://github\.com/ansible\-collections/community\.routeros/pull/234)\)\.
* api\_modify \- make <code>/ip traffic\-flow target</code> a multiple value attribute \([https\://github\.com/ansible\-collections/community\.routeros/pull/234](https\://github\.com/ansible\-collections/community\.routeros/pull/234)\)\.
<a id="v2-10-0"></a>
## v2\.10\.0
<a id="release-summary-21"></a>
### Release Summary
Bugfix and feature release\.
<a id="minor-changes-19"></a>
### Minor Changes
* api\_info \- add new <code>include\_read\_only</code> option to select behavior for read\-only values\. By default these are not returned \([https\://github\.com/ansible\-collections/community\.routeros/pull/213](https\://github\.com/ansible\-collections/community\.routeros/pull/213)\)\.
* api\_info\, api\_modify \- add support for <code>address\-list</code> and <code>match\-subdomain</code> introduced by RouterOS 7\.7 in the <code>ip dns static</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/197](https\://github\.com/ansible\-collections/community\.routeros/pull/197)\)\.
* api\_info\, api\_modify \- add support for <code>user</code>\, <code>time</code> and <code>gmt\-offset</code> under the <code>system clock</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/210](https\://github\.com/ansible\-collections/community\.routeros/pull/210)\)\.
* api\_info\, api\_modify \- add support for the <code>interface ppp\-client</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/199](https\://github\.com/ansible\-collections/community\.routeros/pull/199)\)\.
* api\_info\, api\_modify \- add support for the <code>interface wireless</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/195](https\://github\.com/ansible\-collections/community\.routeros/pull/195)\)\.
* api\_info\, api\_modify \- add support for the <code>iot modbus</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/205](https\://github\.com/ansible\-collections/community\.routeros/pull/205)\)\.
* api\_info\, api\_modify \- add support for the <code>ip dhcp\-server option</code> and <code>ip dhcp\-server option sets</code> paths \([https\://github\.com/ansible\-collections/community\.routeros/pull/223](https\://github\.com/ansible\-collections/community\.routeros/pull/223)\)\.
* api\_info\, api\_modify \- add support for the <code>ip upnp interfaces</code>\, <code>tool graphing interface</code>\, <code>tool graphing resource</code> paths \([https\://github\.com/ansible\-collections/community\.routeros/pull/227](https\://github\.com/ansible\-collections/community\.routeros/pull/227)\)\.
* api\_info\, api\_modify \- add support for the <code>ipv6 firewall nat</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/204](https\://github\.com/ansible\-collections/community\.routeros/pull/204)\)\.
* api\_info\, api\_modify \- add support for the <code>mode</code> property in <code>ip neighbor discovery\-settings</code> introduced in RouterOS 7\.7 \([https\://github\.com/ansible\-collections/community\.routeros/pull/198](https\://github\.com/ansible\-collections/community\.routeros/pull/198)\)\.
* api\_info\, api\_modify \- add support for the <code>port remote\-access</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/224](https\://github\.com/ansible\-collections/community\.routeros/pull/224)\)\.
* api\_info\, api\_modify \- add support for the <code>routing filter rule</code> and <code>routing filter select\-rule</code> paths \([https\://github\.com/ansible\-collections/community\.routeros/pull/200](https\://github\.com/ansible\-collections/community\.routeros/pull/200)\)\.
* api\_info\, api\_modify \- add support for the <code>routing table</code> path in RouterOS 7 \([https\://github\.com/ansible\-collections/community\.routeros/pull/215](https\://github\.com/ansible\-collections/community\.routeros/pull/215)\)\.
* api\_info\, api\_modify \- add support for the <code>tool netwatch</code> path in RouterOS 7 \([https\://github\.com/ansible\-collections/community\.routeros/pull/216](https\://github\.com/ansible\-collections/community\.routeros/pull/216)\)\.
* api\_info\, api\_modify \- add support for the <code>user settings</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/201](https\://github\.com/ansible\-collections/community\.routeros/pull/201)\)\.
* api\_info\, api\_modify \- add support for the <code>user</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/211](https\://github\.com/ansible\-collections/community\.routeros/pull/211)\)\.
* api\_info\, api\_modify \- finalize fields for the <code>interface wireless security\-profiles</code> path and enable it \([https\://github\.com/ansible\-collections/community\.routeros/pull/203](https\://github\.com/ansible\-collections/community\.routeros/pull/203)\)\.
* api\_info\, api\_modify \- finalize fields for the <code>ppp profile</code> path and enable it \([https\://github\.com/ansible\-collections/community\.routeros/pull/217](https\://github\.com/ansible\-collections/community\.routeros/pull/217)\)\.
* api\_modify \- add new <code>handle\_read\_only</code> and <code>handle\_write\_only</code> options to handle the module\'s behavior for read\-only and write\-only fields \([https\://github\.com/ansible\-collections/community\.routeros/pull/213](https\://github\.com/ansible\-collections/community\.routeros/pull/213)\)\.
* api\_modify\, api\_info \- support API paths <code>routing id</code>\, <code>routing bgp connection</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/220](https\://github\.com/ansible\-collections/community\.routeros/pull/220)\)\.
<a id="bugfixes-6"></a>
### Bugfixes
* api\_info\, api\_modify \- in the <code>snmp</code> path\, ensure that <code>engine\-id\-suffix</code> is only available on RouterOS 7\.10\+\, and that <code>engine\-id</code> is read\-only on RouterOS 7\.10\+ \([https\://github\.com/ansible\-collections/community\.routeros/issues/208](https\://github\.com/ansible\-collections/community\.routeros/issues/208)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/218](https\://github\.com/ansible\-collections/community\.routeros/pull/218)\)\.
<a id="v2-9-0"></a>
## v2\.9\.0
<a id="release-summary-22"></a>
### Release Summary
Bugfix and feature release\.
<a id="minor-changes-20"></a>
### Minor Changes
* api\_info\, api\_modify \- add path <code>caps\-man channel</code> and enable path <code>caps\-man manager interface</code> \([https\://github\.com/ansible\-collections/community\.routeros/issues/193](https\://github\.com/ansible\-collections/community\.routeros/issues/193)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/194](https\://github\.com/ansible\-collections/community\.routeros/pull/194)\)\.
* api\_info\, api\_modify \- add path <code>ip traffic\-flow target</code> \([https\://github\.com/ansible\-collections/community\.routeros/issues/191](https\://github\.com/ansible\-collections/community\.routeros/issues/191)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/192](https\://github\.com/ansible\-collections/community\.routeros/pull/192)\)\.
<a id="bugfixes-7"></a>
### Bugfixes
* api\_modify\, api\_info \- add missing parameter <code>engine\-id\-suffix</code> for the <code>snmp</code> path \([https\://github\.com/ansible\-collections/community\.routeros/issues/189](https\://github\.com/ansible\-collections/community\.routeros/issues/189)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/190](https\://github\.com/ansible\-collections/community\.routeros/pull/190)\)\.
<a id="v2-8-3"></a>
## v2\.8\.3
<a id="release-summary-23"></a>
### Release Summary
Maintenance release with updated documentation\.
From this version on\, community\.routeros is using the new [Ansible semantic markup](https\://docs\.ansible\.com/ansible/devel/dev\_guide/developing\_modules\_documenting\.html\#semantic\-markup\-within\-module\-documentation)
in its documentation\. If you look at documentation with the ansible\-doc CLI tool
from ansible\-core before 2\.15\, please note that it does not render the markup
correctly\. You should be still able to read it in most cases\, but you need
ansible\-core 2\.15 or later to see it as it is intended\. Alternatively you can
look at [the devel docsite](https\://docs\.ansible\.com/ansible/devel/collections/community/routeros/)
for the rendered HTML version of the documentation of the latest release\.
<a id="known-issues"></a>
### Known Issues
* Ansible markup will show up in raw form on ansible\-doc text output for ansible\-core before 2\.15\. If you have trouble deciphering the documentation markup\, please upgrade to ansible\-core 2\.15 \(or newer\)\, or read the HTML documentation on [https\://docs\.ansible\.com/ansible/devel/collections/community/routeros/](https\://docs\.ansible\.com/ansible/devel/collections/community/routeros/)\.
<a id="v2-8-2"></a>
## v2\.8\.2
<a id="release-summary-24"></a>
### Release Summary
Bugfix release\.
<a id="bugfixes-8"></a>
### Bugfixes
* api\_modify\, api\_info \- add missing parameter <code>tls</code> for the <code>tool e\-mail</code> path \([https\://github\.com/ansible\-collections/community\.routeros/issues/179](https\://github\.com/ansible\-collections/community\.routeros/issues/179)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/180](https\://github\.com/ansible\-collections/community\.routeros/pull/180)\)\.
<a id="v2-8-1"></a>
## v2\.8\.1
<a id="release-summary-25"></a>
### Release Summary
Bugfix release\.
<a id="bugfixes-9"></a>
### Bugfixes
* facts \- do not crash in CLI output preprocessing in unexpected situations during line unwrapping \([https\://github\.com/ansible\-collections/community\.routeros/issues/170](https\://github\.com/ansible\-collections/community\.routeros/issues/170)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/177](https\://github\.com/ansible\-collections/community\.routeros/pull/177)\)\.
<a id="v2-8-0"></a>
## v2\.8\.0
<a id="release-summary-26"></a>
### Release Summary
Bugfix and feature release\.
<a id="minor-changes-21"></a>
### Minor Changes
* api\_modify \- adapt data for API paths <code>ip dhcp\-server network</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/156](https\://github\.com/ansible\-collections/community\.routeros/pull/156)\)\.
* api\_modify \- add support for API path <code>snmp community</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/159](https\://github\.com/ansible\-collections/community\.routeros/pull/159)\)\.
* api\_modify \- add support for <code>trap\-interfaces</code> in API path <code>snmp</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/159](https\://github\.com/ansible\-collections/community\.routeros/pull/159)\)\.
* api\_modify \- add support to disable IPv6 in API paths <code>ipv6 settings</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/158](https\://github\.com/ansible\-collections/community\.routeros/pull/158)\)\.
* api\_modify \- support API paths <code>ip firewall layer7\-protocol</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/153](https\://github\.com/ansible\-collections/community\.routeros/pull/153)\)\.
* command \- workaround for extra characters in stdout in RouterOS versions between 6\.49 and 7\.1\.5 \([https\://github\.com/ansible\-collections/community\.routeros/issues/62](https\://github\.com/ansible\-collections/community\.routeros/issues/62)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/161](https\://github\.com/ansible\-collections/community\.routeros/pull/161)\)\.
<a id="bugfixes-10"></a>
### Bugfixes
* api\_info\, api\_modify \- fix default and remove behavior for <code>dhcp\-options</code> in path <code>ip dhcp\-client</code> \([https\://github\.com/ansible\-collections/community\.routeros/issues/148](https\://github\.com/ansible\-collections/community\.routeros/issues/148)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/154](https\://github\.com/ansible\-collections/community\.routeros/pull/154)\)\.
* api\_modify \- fix handling of disabled keys on creation \([https\://github\.com/ansible\-collections/community\.routeros/pull/154](https\://github\.com/ansible\-collections/community\.routeros/pull/154)\)\.
* various plugins and modules \- remove unnecessary imports \([https\://github\.com/ansible\-collections/community\.routeros/pull/149](https\://github\.com/ansible\-collections/community\.routeros/pull/149)\)\.
<a id="v2-7-0"></a>
## v2\.7\.0
<a id="release-summary-27"></a>
### Release Summary
Bugfix and feature release\.
<a id="minor-changes-22"></a>
### Minor Changes
* api\_modify\, api\_info \- support API paths <code>ip arp</code>\, <code>ip firewall raw</code>\, <code>ipv6 firewall raw</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/144](https\://github\.com/ansible\-collections/community\.routeros/pull/144)\)\.
<a id="bugfixes-11"></a>
### Bugfixes
* api\_modify\, api\_info \- defaults corrected for fields in <code>interface wireguard peers</code> API path \([https\://github\.com/ansible\-collections/community\.routeros/pull/144](https\://github\.com/ansible\-collections/community\.routeros/pull/144)\)\.
<a id="v2-6-0"></a>
## v2\.6\.0
<a id="release-summary-28"></a>
### Release Summary
Regular bugfix and feature release\.
<a id="minor-changes-23"></a>
### Minor Changes
* api\_modify\, api\_info \- add field <code>regexp</code> to <code>ip dns static</code> \([https\://github\.com/ansible\-collections/community\.routeros/issues/141](https\://github\.com/ansible\-collections/community\.routeros/issues/141)\)\.
* api\_modify\, api\_info \- support API paths <code>interface wireguard</code>\, <code>interface wireguard peers</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/143](https\://github\.com/ansible\-collections/community\.routeros/pull/143)\)\.
<a id="bugfixes-12"></a>
### Bugfixes
* api\_modify \- do not use <code>name</code> as a unique key in <code>ip dns static</code> \([https\://github\.com/ansible\-collections/community\.routeros/issues/141](https\://github\.com/ansible\-collections/community\.routeros/issues/141)\)\.
* api\_modify\, api\_info \- do not crash if router contains <code>regexp</code> DNS entries in <code>ip dns static</code> \([https\://github\.com/ansible\-collections/community\.routeros/issues/141](https\://github\.com/ansible\-collections/community\.routeros/issues/141)\)\.
<a id="v2-5-0"></a>
## v2\.5\.0
<a id="release-summary-29"></a>
### Release Summary
Feature and bugfix release\.
<a id="minor-changes-24"></a>
### Minor Changes
* api\_info\, api\_modify \- support API paths <code>interface ethernet poe</code>\, <code>interface gre6</code>\, <code>interface vrrp</code> and also support all previously missing fields of entries in <code>ip dhcp\-server</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/137](https\://github\.com/ansible\-collections/community\.routeros/pull/137)\)\.
<a id="bugfixes-13"></a>
### Bugfixes
* api\_modify \- <code>address\-pool</code> field of entries in API path <code>ip dhcp\-server</code> is not required anymore \([https\://github\.com/ansible\-collections/community\.routeros/pull/137](https\://github\.com/ansible\-collections/community\.routeros/pull/137)\)\.
<a id="v2-4-0"></a>
## v2\.4\.0
<a id="release-summary-30"></a>
### Release Summary
Feature release improving the <code>api\*</code> modules\.
<a id="minor-changes-25"></a>
### Minor Changes
* api\* modules \- Add new option <code>force\_no\_cert</code> to connect with ADH ciphers \([https\://github\.com/ansible\-collections/community\.routeros/pull/124](https\://github\.com/ansible\-collections/community\.routeros/pull/124)\)\.
* api\_info \- new parameter <code>include\_builtin</code> which allows to include \"builtin\" entries that are automatically generated by ROS and cannot be modified by the user \([https\://github\.com/ansible\-collections/community\.routeros/pull/130](https\://github\.com/ansible\-collections/community\.routeros/pull/130)\)\.
* api\_modify\, api\_info \- support API paths \- <code>interface bonding</code>\, <code>interface bridge mlag</code>\, <code>ipv6 firewall mangle</code>\, <code>ipv6 nd</code>\, <code>system scheduler</code>\, <code>system script</code>\, <code>system ups</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/133](https\://github\.com/ansible\-collections/community\.routeros/pull/133)\)\.
* api\_modify\, api\_info \- support API paths <code>caps\-man access\-list</code>\, <code>caps\-man configuration</code>\, <code>caps\-man datapath</code>\, <code>caps\-man manager</code>\, <code>caps\-man provisioning</code>\, <code>caps\-man security</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/126](https\://github\.com/ansible\-collections/community\.routeros/pull/126)\)\.
* api\_modify\, api\_info \- support API paths <code>interface list</code> and <code>interface list member</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/120](https\://github\.com/ansible\-collections/community\.routeros/pull/120)\)\.
* api\_modify\, api\_info \- support API paths <code>interface pppoe\-client</code>\, <code>interface vlan</code>\, <code>interface bridge</code>\, <code>interface bridge vlan</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/125](https\://github\.com/ansible\-collections/community\.routeros/pull/125)\)\.
* api\_modify\, api\_info \- support API paths <code>ip ipsec identity</code>\, <code>ip ipsec peer</code>\, <code>ip ipsec policy</code>\, <code>ip ipsec profile</code>\, <code>ip ipsec proposal</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/129](https\://github\.com/ansible\-collections/community\.routeros/pull/129)\)\.
* api\_modify\, api\_info \- support API paths <code>ip route</code> and <code>ip route vrf</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/123](https\://github\.com/ansible\-collections/community\.routeros/pull/123)\)\.
* api\_modify\, api\_info \- support API paths <code>ipv6 address</code>\, <code>ipv6 dhcp\-server</code>\, <code>ipv6 dhcp\-server option</code>\, <code>ipv6 route</code>\, <code>queue tree</code>\, <code>routing ospf area</code>\, <code>routing ospf area range</code>\, <code>routing ospf instance</code>\, <code>routing ospf interface\-template</code>\, <code>routing pimsm instance</code>\, <code>routing pimsm interface\-template</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/131](https\://github\.com/ansible\-collections/community\.routeros/pull/131)\)\.
* api\_modify\, api\_info \- support API paths <code>system logging</code>\, <code>system logging action</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/127](https\://github\.com/ansible\-collections/community\.routeros/pull/127)\)\.
* api\_modify\, api\_info \- support field <code>hw\-offload</code> for path <code>ip firewall filter</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/121](https\://github\.com/ansible\-collections/community\.routeros/pull/121)\)\.
* api\_modify\, api\_info \- support fields <code>address\-list</code>\, <code>address\-list\-timeout</code>\, <code>connection\-bytes</code>\, <code>connection\-limit</code>\, <code>connection\-mark</code>\, <code>connection\-rate</code>\, <code>connection\-type</code>\, <code>content</code>\, <code>disabled</code>\, <code>dscp</code>\, <code>dst\-address\-list</code>\, <code>dst\-address\-type</code>\, <code>dst\-limit</code>\, <code>fragment</code>\, <code>hotspot</code>\, <code>icmp\-options</code>\, <code>in\-bridge\-port</code>\, <code>in\-bridge\-port\-list</code>\, <code>ingress\-priority</code>\, <code>ipsec\-policy</code>\, <code>ipv4\-options</code>\, <code>jump\-target</code>\, <code>layer7\-protocol</code>\, <code>limit</code>\, <code>log</code>\, <code>log\-prefix</code>\, <code>nth</code>\, <code>out\-bridge\-port</code>\, <code>out\-bridge\-port\-list</code>\, <code>packet\-mark</code>\, <code>packet\-size</code>\, <code>per\-connection\-classifier</code>\, <code>port</code>\, <code>priority</code>\, <code>psd</code>\, <code>random</code>\, <code>realm</code>\, <code>routing\-mark</code>\, <code>same\-not\-by\-dst</code>\, <code>src\-address</code>\, <code>src\-address\-list</code>\, <code>src\-address\-type</code>\, <code>src\-mac\-address</code>\, <code>src\-port</code>\, <code>tcp\-mss</code>\, <code>time</code>\, <code>tls\-host</code>\, <code>ttl</code> in <code>ip firewall nat</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/133](https\://github\.com/ansible\-collections/community\.routeros/pull/133)\)\.
* api\_modify\, api\_info \- support fields <code>combo\-mode</code>\, <code>comment</code>\, <code>fec\-mode</code>\, <code>mdix\-enable</code>\, <code>poe\-out</code>\, <code>poe\-priority</code>\, <code>poe\-voltage</code>\, <code>power\-cycle\-interval</code>\, <code>power\-cycle\-ping\-address</code>\, <code>power\-cycle\-ping\-enabled</code>\, <code>power\-cycle\-ping\-timeout</code> for path <code>interface ethernet</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/121](https\://github\.com/ansible\-collections/community\.routeros/pull/121)\)\.
* api\_modify\, api\_info \- support fields <code>jump\-target</code>\, <code>reject\-with</code> in <code>ip firewall filter</code> API path\, field <code>comment</code> in <code>ip firwall address\-list</code> API path\, field <code>jump\-target</code> in <code>ip firewall mangle</code> API path\, field <code>comment</code> in <code>ipv6 firewall address\-list</code> API path\, fields <code>jump\-target</code>\, <code>reject\-with</code> in <code>ipv6 firewall filter</code> API path \([https\://github\.com/ansible\-collections/community\.routeros/pull/133](https\://github\.com/ansible\-collections/community\.routeros/pull/133)\)\.
* api\_modify\, api\_info \- support for API fields that can be disabled and have default value at the same time\, support API paths <code>interface gre</code>\, <code>interface eoip</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/128](https\://github\.com/ansible\-collections/community\.routeros/pull/128)\)\.
* api\_modify\, api\_info \- support for fields <code>blackhole</code>\, <code>pref\-src</code>\, <code>routing\-table</code>\, <code>suppress\-hw\-offload</code>\, <code>type</code>\, <code>vrf\-interface</code> in <code>ip route</code> path \([https\://github\.com/ansible\-collections/community\.routeros/pull/131](https\://github\.com/ansible\-collections/community\.routeros/pull/131)\)\.
* api\_modify\, api\_info \- support paths <code>system ntp client servers</code> and <code>system ntp server</code> available in ROS7\, as well as new fields <code>servers</code>\, <code>mode</code>\, and <code>vrf</code> for <code>system ntp client</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/122](https\://github\.com/ansible\-collections/community\.routeros/pull/122)\)\.
<a id="bugfixes-14"></a>
### Bugfixes
* api\_modify \- <code>ip route</code> entry can be defined without the need of <code>gateway</code> field\, which is correct for unreachable/blackhole type of routes \([https\://github\.com/ansible\-collections/community\.routeros/pull/131](https\://github\.com/ansible\-collections/community\.routeros/pull/131)\)\.
* api\_modify \- <code>queue interface</code> path works now \([https\://github\.com/ansible\-collections/community\.routeros/pull/131](https\://github\.com/ansible\-collections/community\.routeros/pull/131)\)\.
* api\_modify\, api\_info \- removed wrong field <code>dynamic</code> from API path <code>ipv6 firewall address\-list</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/133](https\://github\.com/ansible\-collections/community\.routeros/pull/133)\)\.
* api\_modify\, api\_info \- the default of the field <code>ingress\-filtering</code> in <code>interface bridge port</code> is now <code>true</code>\, which is the default in ROS \([https\://github\.com/ansible\-collections/community\.routeros/pull/125](https\://github\.com/ansible\-collections/community\.routeros/pull/125)\)\.
* command\, facts \- commands do not timeout in safe mode anymore \([https\://github\.com/ansible\-collections/community\.routeros/pull/134](https\://github\.com/ansible\-collections/community\.routeros/pull/134)\)\.
<a id="known-issues-1"></a>
### Known Issues
* api\_modify \- when limits for entries in <code>queue tree</code> are defined as human readable \- for example <code>25M</code> \-\, the configuration will be correctly set in ROS\, but the module will indicate the item is changed on every run even when there was no change done\. This is caused by the ROS API which returns the number in bytes \- for example <code>25000000</code> \(which is inconsistent with the CLI behavior\)\. In order to mitigate that\, the limits have to be defined in bytes \(those will still appear as human readable in the ROS CLI\) \([https\://github\.com/ansible\-collections/community\.routeros/pull/131](https\://github\.com/ansible\-collections/community\.routeros/pull/131)\)\.
* api\_modify\, api\_info \- <code>routing ospf area</code>\, <code>routing ospf area range</code>\, <code>routing ospf instance</code>\, <code>routing ospf interface\-template</code> paths are not fully implemented for ROS6 due to the significant changes between ROS6 and ROS7 \([https\://github\.com/ansible\-collections/community\.routeros/pull/131](https\://github\.com/ansible\-collections/community\.routeros/pull/131)\)\.
<a id="v2-3-1"></a>
## v2\.3\.1
<a id="release-summary-31"></a>
### Release Summary
Maintenance release with improved documentation\.
<a id="known-issues-2"></a>
### Known Issues
* The <code>community\.routeros\.command</code> module claims to support check mode\. Since it cannot judge whether the commands executed modify state or not\, this behavior is incorrect\. Since this potentially breaks existing playbooks\, we will not change this behavior until community\.routeros 3\.0\.0\.
<a id="v2-3-0"></a>
## v2\.3\.0
<a id="release-summary-32"></a>
### Release Summary
Feature and bugfix release\.
<a id="minor-changes-26"></a>
### Minor Changes
* The collection repository conforms to the [REUSE specification](https\://reuse\.software/spec/) except for the changelog fragments \([https\://github\.com/ansible\-collections/community\.routeros/pull/108](https\://github\.com/ansible\-collections/community\.routeros/pull/108)\)\.
* api\* modules \- added <code>timeout</code> parameter \([https\://github\.com/ansible\-collections/community\.routeros/pull/109](https\://github\.com/ansible\-collections/community\.routeros/pull/109)\)\.
* api\_modify\, api\_info \- support API path <code>ip firewall mangle</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/110](https\://github\.com/ansible\-collections/community\.routeros/pull/110)\)\.
<a id="bugfixes-15"></a>
### Bugfixes
* api\_modify\, api\_info \- make API path <code>ip dhcp\-server</code> support <code>script</code>\, and <code>ip firewall nat</code> support <code>in\-interface</code> and <code>in\-interface\-list</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/110](https\://github\.com/ansible\-collections/community\.routeros/pull/110)\)\.
<a id="v2-2-1"></a>
## v2\.2\.1
<a id="release-summary-33"></a>
### Release Summary
Bugfix release\.
<a id="bugfixes-16"></a>
### Bugfixes
* api\_modify\, api\_info \- make API path <code>ip dhcp\-server lease</code> support <code>server\=all</code> \([https\://github\.com/ansible\-collections/community\.routeros/issues/104](https\://github\.com/ansible\-collections/community\.routeros/issues/104)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/107](https\://github\.com/ansible\-collections/community\.routeros/pull/107)\)\.
* api\_modify\, api\_info \- make API path <code>ip dhcp\-server network</code> support missing options <code>boot\-file\-name</code>\, <code>dhcp\-option\-set</code>\, <code>dns\-none</code>\, <code>domain</code>\, and <code>next\-server</code> \([https\://github\.com/ansible\-collections/community\.routeros/issues/104](https\://github\.com/ansible\-collections/community\.routeros/issues/104)\, [https\://github\.com/ansible\-collections/community\.routeros/pull/106](https\://github\.com/ansible\-collections/community\.routeros/pull/106)\)\.
<a id="v2-2-0"></a>
## v2\.2\.0
<a id="release-summary-34"></a>
### Release Summary
New feature release\.
<a id="minor-changes-27"></a>
### Minor Changes
* All software licenses are now in the <code>LICENSES/</code> directory of the collection root\. Moreover\, <code>SPDX\-License\-Identifier\:</code> is used to declare the applicable license for every file that is not automatically generated \([https\://github\.com/ansible\-collections/community\.routeros/pull/101](https\://github\.com/ansible\-collections/community\.routeros/pull/101)\)\.
<a id="bugfixes-17"></a>
### Bugfixes
* Include <code>LICENSES/BSD\-2\-Clause\.txt</code> file for the <code>routeros</code> module utils \([https\://github\.com/ansible\-collections/community\.routeros/pull/101](https\://github\.com/ansible\-collections/community\.routeros/pull/101)\)\.
<a id="new-modules"></a>
### New Modules
* community\.routeros\.api\_info \- Retrieve information from API
* community\.routeros\.api\_modify \- Modify data at paths with API
<a id="v2-1-0"></a>
## v2\.1\.0
<a id="release-summary-35"></a>
### Release Summary
Feature and bugfix release with new modules\.
<a id="minor-changes-28"></a>
### Minor Changes
* Added a <code>community\.routeros\.api</code> module defaults group\. Use with <code>group/community\.routeros\.api</code> to provide options for all API\-based modules \([https\://github\.com/ansible\-collections/community\.routeros/pull/89](https\://github\.com/ansible\-collections/community\.routeros/pull/89)\)\.
* Prepare collection for inclusion in an Execution Environment by declaring its dependencies \([https\://github\.com/ansible\-collections/community\.routeros/pull/83](https\://github\.com/ansible\-collections/community\.routeros/pull/83)\)\.
* api \- add new option <code>extended query</code> more complex queries against RouterOS API \([https\://github\.com/ansible\-collections/community\.routeros/pull/63](https\://github\.com/ansible\-collections/community\.routeros/pull/63)\)\.
* api \- update <code>query</code> to accept symbolic parameters \([https\://github\.com/ansible\-collections/community\.routeros/pull/63](https\://github\.com/ansible\-collections/community\.routeros/pull/63)\)\.
* api\* modules \- allow to set an encoding other than the default ASCII for communicating with the API \([https\://github\.com/ansible\-collections/community\.routeros/pull/95](https\://github\.com/ansible\-collections/community\.routeros/pull/95)\)\.
<a id="bugfixes-18"></a>
### Bugfixes
* query \- fix query function check for <code>\.id</code> vs\. <code>id</code> arguments to not conflict with routeros arguments like <code>identity</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/68](https\://github\.com/ansible\-collections/community\.routeros/pull/68)\, [https\://github\.com/ansible\-collections/community\.routeros/issues/67](https\://github\.com/ansible\-collections/community\.routeros/issues/67)\)\.
* quoting and unquoting filter plugins\, api module \- handle the escape sequence <code>\\\_</code> correctly as escaping a space and not an underscore \([https\://github\.com/ansible\-collections/community\.routeros/pull/89](https\://github\.com/ansible\-collections/community\.routeros/pull/89)\)\.
<a id="new-modules-1"></a>
### New Modules
* community\.routeros\.api\_facts \- Collect facts from remote devices running MikroTik RouterOS using the API
* community\.routeros\.api\_find\_and\_modify \- Find and modify information using the API
<a id="v2-0-0"></a>
## v2\.0\.0
<a id="release-summary-36"></a>
### Release Summary
A new major release with breaking changes in the behavior of <code>community\.routeros\.api</code> and <code>community\.routeros\.command</code>\.
<a id="minor-changes-29"></a>
### Minor Changes
* api \- make validation of <code>WHERE</code> for <code>query</code> more strict \([https\://github\.com/ansible\-collections/community\.routeros/pull/53](https\://github\.com/ansible\-collections/community\.routeros/pull/53)\)\.
* command \- the <code>commands</code> and <code>wait\_for</code> options now convert the list elements to strings \([https\://github\.com/ansible\-collections/community\.routeros/pull/55](https\://github\.com/ansible\-collections/community\.routeros/pull/55)\)\.
* facts \- the <code>gather\_subset</code> option now converts the list elements to strings \([https\://github\.com/ansible\-collections/community\.routeros/pull/55](https\://github\.com/ansible\-collections/community\.routeros/pull/55)\)\.
<a id="breaking-changes--porting-guide-1"></a>
### Breaking Changes / Porting Guide
* api \- due to a programming error\, the module never failed on errors\. This has now been fixed\. If you are relying on the module not failing in case of idempotent commands \(resulting in errors like <code>failure\: already have such address</code>\)\, you need to adjust your roles/playbooks\. We suggest to use <code>failed\_when</code> to accept failure in specific circumstances\, for example <code>failed\_when\: \"\'failure\: already have \' in result\.msg\[0\]\"</code> \([https\://github\.com/ansible\-collections/community\.routeros/pull/39](https\://github\.com/ansible\-collections/community\.routeros/pull/39)\)\.
* api \- splitting commands no longer uses a naive split by whitespace\, but a more RouterOS CLI compatible splitting algorithm \([https\://github\.com/ansible\-collections/community\.routeros/pull/45](https\://github\.com/ansible\-collections/community\.routeros/pull/45)\)\.
* command \- the module now always indicates that a change happens\. If this is not correct\, please use <code>changed\_when</code> to determine the correct changed status for a task \([https\://github\.com/ansible\-collections/community\.routeros/pull/50](https\://github\.com/ansible\-collections/community\.routeros/pull/50)\)\.
<a id="bugfixes-19"></a>
### Bugfixes
* api \- improve splitting of <code>WHERE</code> queries \([https\://github\.com/ansible\-collections/community\.routeros/pull/47](https\://github\.com/ansible\-collections/community\.routeros/pull/47)\)\.
* api \- when converting result lists to dictionaries\, no longer removes second <code>\=</code> and text following that if present \([https\://github\.com/ansible\-collections/community\.routeros/pull/47](https\://github\.com/ansible\-collections/community\.routeros/pull/47)\)\.
* routeros cliconf plugin \- adjust function signature that was modified in Ansible after creation of this plugin \([https\://github\.com/ansible\-collections/community\.routeros/pull/43](https\://github\.com/ansible\-collections/community\.routeros/pull/43)\)\.
<a id="new-plugins"></a>
### New Plugins
<a id="filter"></a>
#### Filter
* community\.routeros\.join \- Join a list of arguments to a command
* community\.routeros\.list\_to\_dict \- Convert a list of arguments to a list of dictionary
* community\.routeros\.quote\_argument \- Quote an argument
* community\.routeros\.quote\_argument\_value \- Quote an argument value
* community\.routeros\.split \- Split a command into arguments
<a id="v1-2-0"></a>
## v1\.2\.0
<a id="release-summary-37"></a>
### Release Summary
Bugfix and feature release\.
<a id="minor-changes-30"></a>
### Minor Changes
* Avoid internal ansible\-core module\_utils in favor of equivalent public API available since at least Ansible 2\.9 \([https\://github\.com/ansible\-collections/community\.routeros/pull/38](https\://github\.com/ansible\-collections/community\.routeros/pull/38)\)\.
* api \- add options <code>validate\_certs</code> \(default value <code>true</code>\)\, <code>validate\_cert\_hostname</code> \(default value <code>false</code>\)\, and <code>ca\_path</code> to control certificate validation \([https\://github\.com/ansible\-collections/community\.routeros/pull/37](https\://github\.com/ansible\-collections/community\.routeros/pull/37)\)\.
* api \- rename option <code>ssl</code> to <code>tls</code>\, and keep the old name as an alias \([https\://github\.com/ansible\-collections/community\.routeros/pull/37](https\://github\.com/ansible\-collections/community\.routeros/pull/37)\)\.
* fact \- add fact <code>ansible\_net\_config\_nonverbose</code> to get idempotent config \(no date\, no verbose\) \([https\://github\.com/ansible\-collections/community\.routeros/pull/23](https\://github\.com/ansible\-collections/community\.routeros/pull/23)\)\.
<a id="bugfixes-20"></a>
### Bugfixes
* api \- when using TLS/SSL\, remove explicit cipher configuration to insecure values\, which also makes it impossible to connect to newer RouterOS versions \([https\://github\.com/ansible\-collections/community\.routeros/pull/34](https\://github\.com/ansible\-collections/community\.routeros/pull/34)\)\.
<a id="v1-1-0"></a>
## v1\.1\.0
<a id="release-summary-38"></a>
### Release Summary
This release allow dashes in usernames for SSH\-based modules\.
<a id="minor-changes-31"></a>
### Minor Changes
* command \- added support for a dash \(<code>\-</code>\) in username \([https\://github\.com/ansible\-collections/community\.routeros/pull/18](https\://github\.com/ansible\-collections/community\.routeros/pull/18)\)\.
* facts \- added support for a dash \(<code>\-</code>\) in username \([https\://github\.com/ansible\-collections/community\.routeros/pull/18](https\://github\.com/ansible\-collections/community\.routeros/pull/18)\)\.
<a id="v1-0-1"></a>
## v1\.0\.1
<a id="release-summary-39"></a>
### Release Summary
Maintenance release with a bugfix for <code>api</code>\.
<a id="bugfixes-21"></a>
### Bugfixes
* api \- remove <code>id to \.id</code> as default requirement which conflicts with RouterOS <code>id</code> configuration parameter \([https\://github\.com/ansible\-collections/community\.routeros/pull/15](https\://github\.com/ansible\-collections/community\.routeros/pull/15)\)\.
<a id="v1-0-0"></a>
## v1\.0\.0
<a id="release-summary-40"></a>
### Release Summary
This is the first production \(non\-prerelease\) release of <code>community\.routeros</code>\.
<a id="bugfixes-22"></a>
### Bugfixes
* routeros terminal plugin \- allow slashes in hostnames for terminal detection\. Without this\, slashes in hostnames will result in connection timeouts \([https\://github\.com/ansible\-collections/community\.network/pull/138](https\://github\.com/ansible\-collections/community\.network/pull/138)\)\.
<a id="v0-1-1"></a>
## v0\.1\.1
<a id="release-summary-41"></a>
### Release Summary
Small improvements and bugfixes over the initial release\.
<a id="bugfixes-23"></a>
### Bugfixes
* api \- fix crash when the <code>ssl</code> parameter is used \([https\://github\.com/ansible\-collections/community\.routeros/pull/3](https\://github\.com/ansible\-collections/community\.routeros/pull/3)\)\.
<a id="v0-1-0"></a>
## v0\.1\.0
<a id="release-summary-42"></a>
### Release Summary
The <code>community\.routeros</code> continues the work on the Ansible RouterOS modules from their state in <code>community\.network</code> 1\.2\.0\. The changes listed here are thus relative to the modules <code>community\.network\.routeros\_\*</code>\.
<a id="minor-changes-32"></a>
### Minor Changes
* facts \- now also collecting data about BGP and OSPF \([https\://github\.com/ansible\-collections/community\.network/pull/101](https\://github\.com/ansible\-collections/community\.network/pull/101)\)\.
* facts \- set configuration export on to verbose\, for full configuration export \([https\://github\.com/ansible\-collections/community\.network/pull/104](https\://github\.com/ansible\-collections/community\.network/pull/104)\)\.

View file

@ -1,3 +0,0 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Ansible Project

View file

@ -4,737 +4,19 @@ Community RouterOS Release Notes
.. contents:: Topics .. contents:: Topics
v3.9.0
====== v2.0.0-a1
=========
Release Summary Release Summary
--------------- ---------------
Bugfix and feature release. First prerelease for a new major release with a breaking change in the behavior of ``community.routeros.api``.
Minor Changes
-------------
- api_info, api modify - add ``remote-log-format``, ``remote-protocol``, and ``event-delimiter`` to ``system logging action`` (https://github.com/ansible-collections/community.routeros/pull/381).
- api_info, api_modify - add ``disable-link-local-address`` and ``stale-neighbor-timeout`` fields to ``ipv6 settings`` (https://github.com/ansible-collections/community.routeros/pull/380).
- api_info, api_modify - adjust neighbor limit fields in ``ipv6 settings`` to match RouterOS 7.18 and newer (https://github.com/ansible-collections/community.routeros/pull/380).
- api_info, api_modify - set ``passthrough`` default in ``ip firewall mangle`` to ``true`` for RouterOS 7.19 and newer (https://github.com/ansible-collections/community.routeros/pull/382).
- api_info, api_modify - since RouterOS 7.17 VRF is supported for OVPN server. It now supports multiple entries, while ``api_modify`` so far only accepted a single entry. The ``interface ovpn-server server`` path now allows multiple entries on RouterOS 7.17 and newer (https://github.com/ansible-collections/community.routeros/pull/383).
Bugfixes
--------
- routeros terminal plugin - fix ``terminal_stdout_re`` pattern to handle long system identities when connecting to RouterOS through SSH (https://github.com/ansible-collections/community.routeros/pull/386).
v3.8.1
======
Release Summary
---------------
Bugfix release.
Bugfixes
--------
- facts and api_facts modules - prevent deprecation warnings when used with ansible-core 2.19 (https://github.com/ansible-collections/community.routeros/pull/384).
v3.8.0
======
Release Summary
---------------
Feature release.
Minor Changes
-------------
- api_info, api_modify - add ``interface ethernet switch port-isolation`` which is supported since RouterOS 6.43 (https://github.com/ansible-collections/community.routeros/pull/375).
- api_info, api_modify - add ``routing bfd configuration``. Officially stabilized BFD support for BGP and OSPF is available since RouterOS 7.11
(https://github.com/ansible-collections/community.routeros/pull/375).
- api_modify, api_info - support API path ``ip ipsec mode-config`` (https://github.com/ansible-collections/community.routeros/pull/376).
v3.7.0
======
Release Summary
---------------
Feature release.
Minor Changes
-------------
- api_find_and_modify - allow to control whether ``dynamic`` and/or ``builtin`` entries are ignored with the new ``ignore_dynamic`` and ``ignore_builtin`` options (https://github.com/ansible-collections/community.routeros/issues/372, https://github.com/ansible-collections/community.routeros/pull/373).
- api_info, api_modify - add ``port-cost-mode`` to ``interface bridge`` which is supported since RouterOS 7.13 (https://github.com/ansible-collections/community.routeros/pull/371).
v3.6.0
======
Release Summary
---------------
Feature release.
Minor Changes
-------------
- api_info, api_modify - add ``mdns-repeat-ifaces`` to ``ip dns`` for RouterOS 7.16 and newer (https://github.com/ansible-collections/community.routeros/pull/358).
- api_info, api_modify - field name change in ``routing bgp connection`` path implemented by RouterOS 7.19 and newer (https://github.com/ansible-collections/community.routeros/pull/360).
- api_info, api_modify - rename ``is-responder`` property in ``interface wireguard peers`` to ``responder`` for RouterOS 7.17 and newer (https://github.com/ansible-collections/community.routeros/pull/364).
v3.5.0
======
Release Summary
---------------
Feature release.
Minor Changes
-------------
- api_info, api_modify - change default for ``/ip/cloud/ddns-enabled`` for RouterOS 7.17 and newer from ``yes`` to ``auto`` (https://github.com/ansible-collections/community.routeros/pull/350).
v3.4.0
======
Release Summary
---------------
Feature and bugfix release.
Minor Changes
-------------
- api_info, api_modify - add support for the ``ip dns forwarders`` path implemented by RouterOS 7.17 and newer (https://github.com/ansible-collections/community.routeros/pull/343).
Bugfixes
--------
- api_info, api_modify - remove the primary key ``action`` from the ``interface wifi provisioning`` path, since RouterOS also allows to create completely duplicate entries (https://github.com/ansible-collections/community.routeros/issues/344, https://github.com/ansible-collections/community.routeros/pull/345).
v3.3.0
======
Release Summary
---------------
Feature release.
Minor Changes
-------------
- api_info, api_modify - add missing attribute ``require-message-auth`` for the ``radius`` path which exists since RouterOS version 7.15 (https://github.com/ansible-collections/community.routeros/issues/338, https://github.com/ansible-collections/community.routeros/pull/339).
- api_info, api_modify - add the ``interface 6to4`` path. Used to manage IPv6 tunnels via tunnel-brokers like HE, where native IPv6 is not provided (https://github.com/ansible-collections/community.routeros/pull/342).
- api_info, api_modify - add the ``interface wireless access-list`` and ``interface wireless connect-list`` paths (https://github.com/ansible-collections/community.routeros/issues/284, https://github.com/ansible-collections/community.routeros/pull/340).
- api_info, api_modify - add the ``use-interface-duid`` option for ``ipv6 dhcp-client`` path. This option prevents issues with Fritzbox modems and routers, when using virtual interfaces (like VLANs) may create duplicated records in hosts config, this breaks original "expose-host" function. Also add the ``script``, ``custom-duid`` and ``validate-server-duid`` as backport from 7.15 version update (https://github.com/ansible-collections/community.routeros/pull/341).
v3.2.0
======
Release Summary
---------------
Feature release.
Minor Changes
-------------
- api_info, api_modify - add support for the ``routing filter community-list`` path implemented by RouterOS 7 and newer (https://github.com/ansible-collections/community.routeros/pull/331).
v3.1.0
======
Release Summary
---------------
Bugfix and feature release.
Minor Changes
-------------
- api_info, api_modify - add missing fields ``comment``, ``next-pool`` to ``ip pool`` path (https://github.com/ansible-collections/community.routeros/pull/327).
Bugfixes
--------
- api_info, api_modify - fields ``log`` and ``log-prefix`` in paths ``ip firewall filter``, ``ip firewall mangle``, ``ip firewall nat``, ``ip firewall raw`` now have the correct default values (https://github.com/ansible-collections/community.routeros/pull/324).
v3.0.0
======
Release Summary
---------------
Major release that drops support for End of Life Python versions and fixes check mode for community.routeros.command.
Breaking Changes / Porting Guide
--------------------------------
- command - the module no longer declares that it supports check mode (https://github.com/ansible-collections/community.routeros/pull/318).
Removed Features (previously deprecated)
----------------------------------------
- The collection no longer supports Ansible 2.9, ansible-base 2.10, ansible-core 2.11, ansible-core 2.12, ansible-core 2.13, and ansible-core 2.14. If you need to continue using End of Life versions of Ansible/ansible-base/ansible-core, please use community.routeros 2.x.y (https://github.com/ansible-collections/community.routeros/pull/318).
v2.20.0
=======
Release Summary
---------------
Feature release.
Minor Changes
-------------
- api_info, api_modify - add new parameters from the RouterOS 7.16 release (https://github.com/ansible-collections/community.routeros/pull/323).
- api_info, api_modify - add support ``interface l2tp-client`` configuration (https://github.com/ansible-collections/community.routeros/pull/322).
- api_info, api_modify - add support for the ``cpu-frequency``, ``memory-frequency``, ``preboot-etherboot`` and ``preboot-etherboot-server`` properties in ``system routerboard settings`` (https://github.com/ansible-collections/community.routeros/pull/320).
- api_info, api_modify - add support for the ``matching-type`` property in ``ip dhcp-server matcher`` introduced by RouterOS 7.16 (https://github.com/ansible-collections/community.routeros/pull/321).
v2.19.0
=======
Release Summary
---------------
Feature release.
Minor Changes
-------------
- api_info, api_modify - add support for the ``ip dns adlist`` path implemented by RouterOS 7.15 and newer (https://github.com/ansible-collections/community.routeros/pull/310).
- api_info, api_modify - add support for the ``mld-version`` and ``multicast-querier`` properties in ``interface bridge`` (https://github.com/ansible-collections/community.routeros/pull/315).
- api_info, api_modify - add support for the ``routing filter num-list`` path implemented by RouterOS 7 and newer (https://github.com/ansible-collections/community.routeros/pull/313).
- api_info, api_modify - add support for the ``routing igmp-proxy`` path (https://github.com/ansible-collections/community.routeros/pull/309).
- api_modify, api_info - add read-only ``default`` field to ``snmp community`` (https://github.com/ansible-collections/community.routeros/pull/311).
v2.18.0
=======
Release Summary
---------------
Feature release.
Minor Changes
-------------
- api_info - allow to restrict the output by limiting fields to specific values with the new ``restrict`` option (https://github.com/ansible-collections/community.routeros/pull/305).
- api_info, api_modify - add support for the ``ip dhcp-server matcher`` path (https://github.com/ansible-collections/community.routeros/pull/300).
- api_info, api_modify - add support for the ``ipv6 nd prefix`` path (https://github.com/ansible-collections/community.routeros/pull/303).
- api_info, api_modify - add support for the ``name`` and ``is-responder`` properties under the ``interface wireguard peers`` path introduced in RouterOS 7.15 (https://github.com/ansible-collections/community.routeros/pull/304).
- api_info, api_modify - add support for the ``routing ospf static-neighbor`` path in RouterOS 7 (https://github.com/ansible-collections/community.routeros/pull/302).
- api_info, api_modify - set default for ``force`` in ``ip dhcp-server option`` to an explicit ``false`` (https://github.com/ansible-collections/community.routeros/pull/300).
- api_modify - allow to restrict what is updated by limiting fields to specific values with the new ``restrict`` option (https://github.com/ansible-collections/community.routeros/pull/305).
Deprecated Features
-------------------
- The collection deprecates support for all Ansible/ansible-base/ansible-core versions that are currently End of Life, `according to the ansible-core support matrix <https://docs.ansible.com/ansible-core/devel/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix>`__. This means that the next major release of the collection will no longer support Ansible 2.9, ansible-base 2.10, ansible-core 2.11, ansible-core 2.12, ansible-core 2.13, and ansible-core 2.14.
Bugfixes
--------
- api_modify, api_info - change the default of ``ingress-filtering`` in paths ``interface bridge`` and ``interface bridge port`` back to ``false`` for RouterOS before version 7 (https://github.com/ansible-collections/community.routeros/pull/305).
v2.17.0
=======
Release Summary
---------------
Feature release.
Minor Changes
-------------
- api_info, api_modify - add ``system health settings`` path (https://github.com/ansible-collections/community.routeros/pull/294).
- api_info, api_modify - add missing path ``/system resource irq rps`` (https://github.com/ansible-collections/community.routeros/pull/295).
- api_info, api_modify - add parameter ``host-key-type`` for ``ip ssh`` path (https://github.com/ansible-collections/community.routeros/issues/280, https://github.com/ansible-collections/community.routeros/pull/297).
v2.16.0
=======
Release Summary
---------------
Feature release.
Minor Changes
-------------
- api_info, api_modify - add missing path ``/ppp secret`` (https://github.com/ansible-collections/community.routeros/pull/286).
- api_info, api_modify - minor changes ``/interface ethernet`` path fields (https://github.com/ansible-collections/community.routeros/pull/288).
v2.15.0
=======
Release Summary
---------------
Feature release.
Minor Changes
-------------
- api_info, api_modify - Add RouterOS 7.x support to ``/mpls ldp`` path (https://github.com/ansible-collections/community.routeros/pull/271).
- api_info, api_modify - add ``/ip route rule`` path for RouterOS 6.x (https://github.com/ansible-collections/community.routeros/pull/278).
- api_info, api_modify - add ``/routing filter`` path for RouterOS 6.x (https://github.com/ansible-collections/community.routeros/pull/279).
- api_info, api_modify - add default value for ``from-pool`` field in ``/ipv6 address`` (https://github.com/ansible-collections/community.routeros/pull/270).
- api_info, api_modify - add missing path ``/interface pppoe-server server`` (https://github.com/ansible-collections/community.routeros/pull/273).
- api_info, api_modify - add missing path ``/ip dhcp-relay`` (https://github.com/ansible-collections/community.routeros/pull/276).
- api_info, api_modify - add missing path ``/queue simple`` (https://github.com/ansible-collections/community.routeros/pull/269).
- api_info, api_modify - add missing path ``/queue type`` (https://github.com/ansible-collections/community.routeros/pull/274).
- api_info, api_modify - add missing paths ``/routing bgp aggregate``, ``/routing bgp network`` and ``/routing bgp peer`` (https://github.com/ansible-collections/community.routeros/pull/277).
- api_info, api_modify - add support for paths ``/mpls interface``, ``/mpls ldp accept-filter``, ``/mpls ldp advertise-filter`` and ``mpls ldp interface`` (https://github.com/ansible-collections/community.routeros/pull/272).
v2.14.0
=======
Release Summary
---------------
Feature release.
Minor Changes
-------------
- api_info, api_modify - add read-only fields ``installed-version``, ``latest-version`` and ``status`` in ``system package update`` (https://github.com/ansible-collections/community.routeros/pull/263).
- api_info, api_modify - added support for ``interface wifi`` and its sub-paths (https://github.com/ansible-collections/community.routeros/pull/266).
- api_info, api_modify - remove default value for read-only ``running`` field in ``interface wireless`` (https://github.com/ansible-collections/community.routeros/pull/264).
v2.13.0
=======
Release Summary
---------------
Bugfix and feature release.
Minor Changes
-------------
- api_info, api_modify - make path ``user group`` modifiable and add ``comment`` attribute (https://github.com/ansible-collections/community.routeros/issues/256, https://github.com/ansible-collections/community.routeros/pull/257).
- api_modify, api_info - add support for the ``ip vrf`` path in RouterOS 7 (https://github.com/ansible-collections/community.routeros/pull/259)
Bugfixes
--------
- facts - fix date not getting removed for idempotent config export (https://github.com/ansible-collections/community.routeros/pull/262).
v2.12.0
=======
Release Summary
---------------
Feature release.
Minor Changes
-------------
- api_info, api_modify - add ``interface ovpn-client`` path (https://github.com/ansible-collections/community.routeros/issues/242, https://github.com/ansible-collections/community.routeros/pull/244).
- api_info, api_modify - add ``radius`` path (https://github.com/ansible-collections/community.routeros/issues/241, https://github.com/ansible-collections/community.routeros/pull/245).
- api_info, api_modify - add ``routing rule`` path (https://github.com/ansible-collections/community.routeros/issues/162, https://github.com/ansible-collections/community.routeros/pull/246).
- api_info, api_modify - add missing path ``routing bgp template`` (https://github.com/ansible-collections/community.routeros/pull/243).
- api_info, api_modify - add support for the ``tx-power`` attribute in ``interface wireless`` (https://github.com/ansible-collections/community.routeros/pull/239).
- api_info, api_modify - removed ``host`` primary key in ``tool netwatch`` path (https://github.com/ansible-collections/community.routeros/pull/248).
- api_modify, api_info - added support for ``interface wifiwave2`` (https://github.com/ansible-collections/community.routeros/pull/226).
v2.11.0
=======
Release Summary
---------------
Feature and bugfix release.
Minor Changes
-------------
- api_info, api_modify - add missing DoH parameters ``doh-max-concurrent-queries``, ``doh-max-server-connections``, and ``doh-timeout`` to the ``ip dns`` path (https://github.com/ansible-collections/community.routeros/issues/230, https://github.com/ansible-collections/community.routeros/pull/235)
- api_info, api_modify - add missing parameters ``address-list``, ``address-list-timeout``, ``randomise-ports``, and ``realm`` to subpaths of the ``ip firewall`` path (https://github.com/ansible-collections/community.routeros/issues/236, https://github.com/ansible-collections/community.routeros/pull/237).
- api_info, api_modify - mark the ``interface wireless`` parameter ``running`` as read-only (https://github.com/ansible-collections/community.routeros/pull/233).
- api_info, api_modify - set the default value to ``false`` for the ``disabled`` parameter in some more paths where it can be seen in the documentation (https://github.com/ansible-collections/community.routeros/pull/237).
- api_modify - add missing ``comment`` attribute to ``/routing id`` (https://github.com/ansible-collections/community.routeros/pull/234).
- api_modify - add missing attributes to the ``routing bgp connection`` path (https://github.com/ansible-collections/community.routeros/pull/234).
- api_modify - add versioning to the ``/tool e-mail`` path (RouterOS 7.12 release) (https://github.com/ansible-collections/community.routeros/pull/234).
- api_modify - make ``/ip traffic-flow target`` a multiple value attribute (https://github.com/ansible-collections/community.routeros/pull/234).
v2.10.0
=======
Release Summary
---------------
Bugfix and feature release.
Minor Changes
-------------
- api_info - add new ``include_read_only`` option to select behavior for read-only values. By default these are not returned (https://github.com/ansible-collections/community.routeros/pull/213).
- api_info, api_modify - add support for ``address-list`` and ``match-subdomain`` introduced by RouterOS 7.7 in the ``ip dns static`` path (https://github.com/ansible-collections/community.routeros/pull/197).
- api_info, api_modify - add support for ``user``, ``time`` and ``gmt-offset`` under the ``system clock`` path (https://github.com/ansible-collections/community.routeros/pull/210).
- api_info, api_modify - add support for the ``interface ppp-client`` path (https://github.com/ansible-collections/community.routeros/pull/199).
- api_info, api_modify - add support for the ``interface wireless`` path (https://github.com/ansible-collections/community.routeros/pull/195).
- api_info, api_modify - add support for the ``iot modbus`` path (https://github.com/ansible-collections/community.routeros/pull/205).
- api_info, api_modify - add support for the ``ip dhcp-server option`` and ``ip dhcp-server option sets`` paths (https://github.com/ansible-collections/community.routeros/pull/223).
- api_info, api_modify - add support for the ``ip upnp interfaces``, ``tool graphing interface``, ``tool graphing resource`` paths (https://github.com/ansible-collections/community.routeros/pull/227).
- api_info, api_modify - add support for the ``ipv6 firewall nat`` path (https://github.com/ansible-collections/community.routeros/pull/204).
- api_info, api_modify - add support for the ``mode`` property in ``ip neighbor discovery-settings`` introduced in RouterOS 7.7 (https://github.com/ansible-collections/community.routeros/pull/198).
- api_info, api_modify - add support for the ``port remote-access`` path (https://github.com/ansible-collections/community.routeros/pull/224).
- api_info, api_modify - add support for the ``routing filter rule`` and ``routing filter select-rule`` paths (https://github.com/ansible-collections/community.routeros/pull/200).
- api_info, api_modify - add support for the ``routing table`` path in RouterOS 7 (https://github.com/ansible-collections/community.routeros/pull/215).
- api_info, api_modify - add support for the ``tool netwatch`` path in RouterOS 7 (https://github.com/ansible-collections/community.routeros/pull/216).
- api_info, api_modify - add support for the ``user settings`` path (https://github.com/ansible-collections/community.routeros/pull/201).
- api_info, api_modify - add support for the ``user`` path (https://github.com/ansible-collections/community.routeros/pull/211).
- api_info, api_modify - finalize fields for the ``interface wireless security-profiles`` path and enable it (https://github.com/ansible-collections/community.routeros/pull/203).
- api_info, api_modify - finalize fields for the ``ppp profile`` path and enable it (https://github.com/ansible-collections/community.routeros/pull/217).
- api_modify - add new ``handle_read_only`` and ``handle_write_only`` options to handle the module's behavior for read-only and write-only fields (https://github.com/ansible-collections/community.routeros/pull/213).
- api_modify, api_info - support API paths ``routing id``, ``routing bgp connection`` (https://github.com/ansible-collections/community.routeros/pull/220).
Bugfixes
--------
- api_info, api_modify - in the ``snmp`` path, ensure that ``engine-id-suffix`` is only available on RouterOS 7.10+, and that ``engine-id`` is read-only on RouterOS 7.10+ (https://github.com/ansible-collections/community.routeros/issues/208, https://github.com/ansible-collections/community.routeros/pull/218).
v2.9.0
======
Release Summary
---------------
Bugfix and feature release.
Minor Changes
-------------
- api_info, api_modify - add path ``caps-man channel`` and enable path ``caps-man manager interface`` (https://github.com/ansible-collections/community.routeros/issues/193, https://github.com/ansible-collections/community.routeros/pull/194).
- api_info, api_modify - add path ``ip traffic-flow target`` (https://github.com/ansible-collections/community.routeros/issues/191, https://github.com/ansible-collections/community.routeros/pull/192).
Bugfixes
--------
- api_modify, api_info - add missing parameter ``engine-id-suffix`` for the ``snmp`` path (https://github.com/ansible-collections/community.routeros/issues/189, https://github.com/ansible-collections/community.routeros/pull/190).
v2.8.3
======
Release Summary
---------------
Maintenance release with updated documentation.
From this version on, community.routeros is using the new `Ansible semantic markup
<https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_documenting.html#semantic-markup-within-module-documentation>`__
in its documentation. If you look at documentation with the ansible-doc CLI tool
from ansible-core before 2.15, please note that it does not render the markup
correctly. You should be still able to read it in most cases, but you need
ansible-core 2.15 or later to see it as it is intended. Alternatively you can
look at `the devel docsite <https://docs.ansible.com/ansible/devel/collections/community/routeros/>`__
for the rendered HTML version of the documentation of the latest release.
Known Issues
------------
- Ansible markup will show up in raw form on ansible-doc text output for ansible-core before 2.15. If you have trouble deciphering the documentation markup, please upgrade to ansible-core 2.15 (or newer), or read the HTML documentation on https://docs.ansible.com/ansible/devel/collections/community/routeros/.
v2.8.2
======
Release Summary
---------------
Bugfix release.
Bugfixes
--------
- api_modify, api_info - add missing parameter ``tls`` for the ``tool e-mail`` path (https://github.com/ansible-collections/community.routeros/issues/179, https://github.com/ansible-collections/community.routeros/pull/180).
v2.8.1
======
Release Summary
---------------
Bugfix release.
Bugfixes
--------
- facts - do not crash in CLI output preprocessing in unexpected situations during line unwrapping (https://github.com/ansible-collections/community.routeros/issues/170, https://github.com/ansible-collections/community.routeros/pull/177).
v2.8.0
======
Release Summary
---------------
Bugfix and feature release.
Minor Changes
-------------
- api_modify - adapt data for API paths ``ip dhcp-server network`` (https://github.com/ansible-collections/community.routeros/pull/156).
- api_modify - add support for API path ``snmp community`` (https://github.com/ansible-collections/community.routeros/pull/159).
- api_modify - add support for ``trap-interfaces`` in API path ``snmp`` (https://github.com/ansible-collections/community.routeros/pull/159).
- api_modify - add support to disable IPv6 in API paths ``ipv6 settings`` (https://github.com/ansible-collections/community.routeros/pull/158).
- api_modify - support API paths ``ip firewall layer7-protocol`` (https://github.com/ansible-collections/community.routeros/pull/153).
- command - workaround for extra characters in stdout in RouterOS versions between 6.49 and 7.1.5 (https://github.com/ansible-collections/community.routeros/issues/62, https://github.com/ansible-collections/community.routeros/pull/161).
Bugfixes
--------
- api_info, api_modify - fix default and remove behavior for ``dhcp-options`` in path ``ip dhcp-client`` (https://github.com/ansible-collections/community.routeros/issues/148, https://github.com/ansible-collections/community.routeros/pull/154).
- api_modify - fix handling of disabled keys on creation (https://github.com/ansible-collections/community.routeros/pull/154).
- various plugins and modules - remove unnecessary imports (https://github.com/ansible-collections/community.routeros/pull/149).
v2.7.0
======
Release Summary
---------------
Bugfix and feature release.
Minor Changes
-------------
- api_modify, api_info - support API paths ``ip arp``, ``ip firewall raw``, ``ipv6 firewall raw`` (https://github.com/ansible-collections/community.routeros/pull/144).
Bugfixes
--------
- api_modify, api_info - defaults corrected for fields in ``interface wireguard peers`` API path (https://github.com/ansible-collections/community.routeros/pull/144).
v2.6.0
======
Release Summary
---------------
Regular bugfix and feature release.
Minor Changes
-------------
- api_modify, api_info - add field ``regexp`` to ``ip dns static`` (https://github.com/ansible-collections/community.routeros/issues/141).
- api_modify, api_info - support API paths ``interface wireguard``, ``interface wireguard peers`` (https://github.com/ansible-collections/community.routeros/pull/143).
Bugfixes
--------
- api_modify - do not use ``name`` as a unique key in ``ip dns static`` (https://github.com/ansible-collections/community.routeros/issues/141).
- api_modify, api_info - do not crash if router contains ``regexp`` DNS entries in ``ip dns static`` (https://github.com/ansible-collections/community.routeros/issues/141).
v2.5.0
======
Release Summary
---------------
Feature and bugfix release.
Minor Changes
-------------
- api_info, api_modify - support API paths ``interface ethernet poe``, ``interface gre6``, ``interface vrrp`` and also support all previously missing fields of entries in ``ip dhcp-server`` (https://github.com/ansible-collections/community.routeros/pull/137).
Bugfixes
--------
- api_modify - ``address-pool`` field of entries in API path ``ip dhcp-server`` is not required anymore (https://github.com/ansible-collections/community.routeros/pull/137).
v2.4.0
======
Release Summary
---------------
Feature release improving the ``api*`` modules.
Minor Changes
-------------
- api* modules - Add new option ``force_no_cert`` to connect with ADH ciphers (https://github.com/ansible-collections/community.routeros/pull/124).
- api_info - new parameter ``include_builtin`` which allows to include "builtin" entries that are automatically generated by ROS and cannot be modified by the user (https://github.com/ansible-collections/community.routeros/pull/130).
- api_modify, api_info - support API paths - ``interface bonding``, ``interface bridge mlag``, ``ipv6 firewall mangle``, ``ipv6 nd``, ``system scheduler``, ``system script``, ``system ups`` (https://github.com/ansible-collections/community.routeros/pull/133).
- api_modify, api_info - support API paths ``caps-man access-list``, ``caps-man configuration``, ``caps-man datapath``, ``caps-man manager``, ``caps-man provisioning``, ``caps-man security`` (https://github.com/ansible-collections/community.routeros/pull/126).
- api_modify, api_info - support API paths ``interface list`` and ``interface list member`` (https://github.com/ansible-collections/community.routeros/pull/120).
- api_modify, api_info - support API paths ``interface pppoe-client``, ``interface vlan``, ``interface bridge``, ``interface bridge vlan`` (https://github.com/ansible-collections/community.routeros/pull/125).
- api_modify, api_info - support API paths ``ip ipsec identity``, ``ip ipsec peer``, ``ip ipsec policy``, ``ip ipsec profile``, ``ip ipsec proposal`` (https://github.com/ansible-collections/community.routeros/pull/129).
- api_modify, api_info - support API paths ``ip route`` and ``ip route vrf`` (https://github.com/ansible-collections/community.routeros/pull/123).
- api_modify, api_info - support API paths ``ipv6 address``, ``ipv6 dhcp-server``, ``ipv6 dhcp-server option``, ``ipv6 route``, ``queue tree``, ``routing ospf area``, ``routing ospf area range``, ``routing ospf instance``, ``routing ospf interface-template``, ``routing pimsm instance``, ``routing pimsm interface-template`` (https://github.com/ansible-collections/community.routeros/pull/131).
- api_modify, api_info - support API paths ``system logging``, ``system logging action`` (https://github.com/ansible-collections/community.routeros/pull/127).
- api_modify, api_info - support field ``hw-offload`` for path ``ip firewall filter`` (https://github.com/ansible-collections/community.routeros/pull/121).
- api_modify, api_info - support fields ``address-list``, ``address-list-timeout``, ``connection-bytes``, ``connection-limit``, ``connection-mark``, ``connection-rate``, ``connection-type``, ``content``, ``disabled``, ``dscp``, ``dst-address-list``, ``dst-address-type``, ``dst-limit``, ``fragment``, ``hotspot``, ``icmp-options``, ``in-bridge-port``, ``in-bridge-port-list``, ``ingress-priority``, ``ipsec-policy``, ``ipv4-options``, ``jump-target``, ``layer7-protocol``, ``limit``, ``log``, ``log-prefix``, ``nth``, ``out-bridge-port``, ``out-bridge-port-list``, ``packet-mark``, ``packet-size``, ``per-connection-classifier``, ``port``, ``priority``, ``psd``, ``random``, ``realm``, ``routing-mark``, ``same-not-by-dst``, ``src-address``, ``src-address-list``, ``src-address-type``, ``src-mac-address``, ``src-port``, ``tcp-mss``, ``time``, ``tls-host``, ``ttl`` in ``ip firewall nat`` path (https://github.com/ansible-collections/community.routeros/pull/133).
- api_modify, api_info - support fields ``combo-mode``, ``comment``, ``fec-mode``, ``mdix-enable``, ``poe-out``, ``poe-priority``, ``poe-voltage``, ``power-cycle-interval``, ``power-cycle-ping-address``, ``power-cycle-ping-enabled``, ``power-cycle-ping-timeout`` for path ``interface ethernet`` (https://github.com/ansible-collections/community.routeros/pull/121).
- api_modify, api_info - support fields ``jump-target``, ``reject-with`` in ``ip firewall filter`` API path, field ``comment`` in ``ip firwall address-list`` API path, field ``jump-target`` in ``ip firewall mangle`` API path, field ``comment`` in ``ipv6 firewall address-list`` API path, fields ``jump-target``, ``reject-with`` in ``ipv6 firewall filter`` API path (https://github.com/ansible-collections/community.routeros/pull/133).
- api_modify, api_info - support for API fields that can be disabled and have default value at the same time, support API paths ``interface gre``, ``interface eoip`` (https://github.com/ansible-collections/community.routeros/pull/128).
- api_modify, api_info - support for fields ``blackhole``, ``pref-src``, ``routing-table``, ``suppress-hw-offload``, ``type``, ``vrf-interface`` in ``ip route`` path (https://github.com/ansible-collections/community.routeros/pull/131).
- api_modify, api_info - support paths ``system ntp client servers`` and ``system ntp server`` available in ROS7, as well as new fields ``servers``, ``mode``, and ``vrf`` for ``system ntp client`` (https://github.com/ansible-collections/community.routeros/pull/122).
Bugfixes
--------
- api_modify - ``ip route`` entry can be defined without the need of ``gateway`` field, which is correct for unreachable/blackhole type of routes (https://github.com/ansible-collections/community.routeros/pull/131).
- api_modify - ``queue interface`` path works now (https://github.com/ansible-collections/community.routeros/pull/131).
- api_modify, api_info - removed wrong field ``dynamic`` from API path ``ipv6 firewall address-list`` (https://github.com/ansible-collections/community.routeros/pull/133).
- api_modify, api_info - the default of the field ``ingress-filtering`` in ``interface bridge port`` is now ``true``, which is the default in ROS (https://github.com/ansible-collections/community.routeros/pull/125).
- command, facts - commands do not timeout in safe mode anymore (https://github.com/ansible-collections/community.routeros/pull/134).
Known Issues
------------
- api_modify - when limits for entries in ``queue tree`` are defined as human readable - for example ``25M`` -, the configuration will be correctly set in ROS, but the module will indicate the item is changed on every run even when there was no change done. This is caused by the ROS API which returns the number in bytes - for example ``25000000`` (which is inconsistent with the CLI behavior). In order to mitigate that, the limits have to be defined in bytes (those will still appear as human readable in the ROS CLI) (https://github.com/ansible-collections/community.routeros/pull/131).
- api_modify, api_info - ``routing ospf area``, ``routing ospf area range``, ``routing ospf instance``, ``routing ospf interface-template`` paths are not fully implemented for ROS6 due to the significant changes between ROS6 and ROS7 (https://github.com/ansible-collections/community.routeros/pull/131).
v2.3.1
======
Release Summary
---------------
Maintenance release with improved documentation.
Known Issues
------------
- The ``community.routeros.command`` module claims to support check mode. Since it cannot judge whether the commands executed modify state or not, this behavior is incorrect. Since this potentially breaks existing playbooks, we will not change this behavior until community.routeros 3.0.0.
v2.3.0
======
Release Summary
---------------
Feature and bugfix release.
Minor Changes
-------------
- The collection repository conforms to the `REUSE specification <https://reuse.software/spec/>`__ except for the changelog fragments (https://github.com/ansible-collections/community.routeros/pull/108).
- api* modules - added ``timeout`` parameter (https://github.com/ansible-collections/community.routeros/pull/109).
- api_modify, api_info - support API path ``ip firewall mangle`` (https://github.com/ansible-collections/community.routeros/pull/110).
Bugfixes
--------
- api_modify, api_info - make API path ``ip dhcp-server`` support ``script``, and ``ip firewall nat`` support ``in-interface`` and ``in-interface-list`` (https://github.com/ansible-collections/community.routeros/pull/110).
v2.2.1
======
Release Summary
---------------
Bugfix release.
Bugfixes
--------
- api_modify, api_info - make API path ``ip dhcp-server lease`` support ``server=all`` (https://github.com/ansible-collections/community.routeros/issues/104, https://github.com/ansible-collections/community.routeros/pull/107).
- api_modify, api_info - make API path ``ip dhcp-server network`` support missing options ``boot-file-name``, ``dhcp-option-set``, ``dns-none``, ``domain``, and ``next-server`` (https://github.com/ansible-collections/community.routeros/issues/104, https://github.com/ansible-collections/community.routeros/pull/106).
v2.2.0
======
Release Summary
---------------
New feature release.
Minor Changes
-------------
- All software licenses are now in the ``LICENSES/`` directory of the collection root. Moreover, ``SPDX-License-Identifier:`` is used to declare the applicable license for every file that is not automatically generated (https://github.com/ansible-collections/community.routeros/pull/101).
Bugfixes
--------
- Include ``LICENSES/BSD-2-Clause.txt`` file for the ``routeros`` module utils (https://github.com/ansible-collections/community.routeros/pull/101).
New Modules
-----------
- community.routeros.api_info - Retrieve information from API
- community.routeros.api_modify - Modify data at paths with API
v2.1.0
======
Release Summary
---------------
Feature and bugfix release with new modules.
Minor Changes
-------------
- Added a ``community.routeros.api`` module defaults group. Use with ``group/community.routeros.api`` to provide options for all API-based modules (https://github.com/ansible-collections/community.routeros/pull/89).
- Prepare collection for inclusion in an Execution Environment by declaring its dependencies (https://github.com/ansible-collections/community.routeros/pull/83).
- api - add new option ``extended query`` more complex queries against RouterOS API (https://github.com/ansible-collections/community.routeros/pull/63).
- api - update ``query`` to accept symbolic parameters (https://github.com/ansible-collections/community.routeros/pull/63).
- api* modules - allow to set an encoding other than the default ASCII for communicating with the API (https://github.com/ansible-collections/community.routeros/pull/95).
Bugfixes
--------
- query - fix query function check for ``.id`` vs. ``id`` arguments to not conflict with routeros arguments like ``identity`` (https://github.com/ansible-collections/community.routeros/pull/68, https://github.com/ansible-collections/community.routeros/issues/67).
- quoting and unquoting filter plugins, api module - handle the escape sequence ``\_`` correctly as escaping a space and not an underscore (https://github.com/ansible-collections/community.routeros/pull/89).
New Modules
-----------
- community.routeros.api_facts - Collect facts from remote devices running MikroTik RouterOS using the API
- community.routeros.api_find_and_modify - Find and modify information using the API
v2.0.0
======
Release Summary
---------------
A new major release with breaking changes in the behavior of ``community.routeros.api`` and ``community.routeros.command``.
Minor Changes
-------------
- api - make validation of ``WHERE`` for ``query`` more strict (https://github.com/ansible-collections/community.routeros/pull/53).
- command - the ``commands`` and ``wait_for`` options now convert the list elements to strings (https://github.com/ansible-collections/community.routeros/pull/55).
- facts - the ``gather_subset`` option now converts the list elements to strings (https://github.com/ansible-collections/community.routeros/pull/55).
Breaking Changes / Porting Guide Breaking Changes / Porting Guide
-------------------------------- --------------------------------
- api - due to a programming error, the module never failed on errors. This has now been fixed. If you are relying on the module not failing in case of idempotent commands (resulting in errors like ``failure: already have such address``), you need to adjust your roles/playbooks. We suggest to use ``failed_when`` to accept failure in specific circumstances, for example ``failed_when: "'failure: already have ' in result.msg[0]"`` (https://github.com/ansible-collections/community.routeros/pull/39). - api - due to a programming error, the module never failed on errors. This has now been fixed. If you are relying on the module not failing in case of idempotent commands (resulting in errors like ``failure: already have such address``), you need to adjust your roles/playbooks. We suggest to use ``failed_when`` to accept failure in specific circumstances, for example ``failed_when: "'failure: already have ' in result.msg[0]"`` (https://github.com/ansible-collections/community.routeros/pull/39).
- api - splitting commands no longer uses a naive split by whitespace, but a more RouterOS CLI compatible splitting algorithm (https://github.com/ansible-collections/community.routeros/pull/45).
- command - the module now always indicates that a change happens. If this is not correct, please use ``changed_when`` to determine the correct changed status for a task (https://github.com/ansible-collections/community.routeros/pull/50).
Bugfixes
--------
- api - improve splitting of ``WHERE`` queries (https://github.com/ansible-collections/community.routeros/pull/47).
- api - when converting result lists to dictionaries, no longer removes second ``=`` and text following that if present (https://github.com/ansible-collections/community.routeros/pull/47).
- routeros cliconf plugin - adjust function signature that was modified in Ansible after creation of this plugin (https://github.com/ansible-collections/community.routeros/pull/43).
New Plugins
-----------
Filter
~~~~~~
- community.routeros.join - Join a list of arguments to a command
- community.routeros.list_to_dict - Convert a list of arguments to a list of dictionary
- community.routeros.quote_argument - Quote an argument
- community.routeros.quote_argument_value - Quote an argument value
- community.routeros.split - Split a command into arguments
v1.2.0 v1.2.0
====== ======
@ -792,6 +74,7 @@ Release Summary
This is the first production (non-prerelease) release of ``community.routeros``. This is the first production (non-prerelease) release of ``community.routeros``.
Bugfixes Bugfixes
-------- --------
@ -818,6 +101,7 @@ Release Summary
The ``community.routeros`` continues the work on the Ansible RouterOS modules from their state in ``community.network`` 1.2.0. The changes listed here are thus relative to the modules ``community.network.routeros_*``. The ``community.routeros`` continues the work on the Ansible RouterOS modules from their state in ``community.network`` 1.2.0. The changes listed here are thus relative to the modules ``community.network.routeros_*``.
Minor Changes Minor Changes
------------- -------------

View file

@ -1,3 +0,0 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Ansible Project

View file

@ -1,8 +0,0 @@
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -1 +0,0 @@
../COPYING

120
README.md
View file

@ -1,44 +1,17 @@
<!--
Copyright (c) Ansible Project
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
-->
# Community RouterOS Collection # Community RouterOS Collection
[![Documentation](https://img.shields.io/badge/docs-brightgreen.svg)](https://docs.ansible.com/ansible/devel/collections/community/routeros/) [![CI](https://github.com/ansible-collections/community.routeros/workflows/CI/badge.svg?event=push)](https://github.com/ansible-collections/community.routeros/actions) [![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/community.routeros)](https://codecov.io/gh/ansible-collections/community.routeros)
[![CI](https://github.com/ansible-collections/community.routeros/actions/workflows/nox.yml/badge.svg?branch=main)](https://github.com/ansible-collections/community.routeros/actions)
[![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/community.routeros)](https://codecov.io/gh/ansible-collections/community.routeros)
[![REUSE status](https://api.reuse.software/badge/github.com/ansible-collections/community.routeros)](https://api.reuse.software/info/github.com/ansible-collections/community.routeros)
Provides modules for [Ansible](https://www.ansible.com/community) to manage [MikroTik RouterOS](https://mikrotik.com/software) instances. Provides modules for [Ansible](https://www.ansible.com/community) to manage [MikroTik RouterOS](http://www.mikrotik-routeros.net/routeros.aspx) instances.
You can find [documentation for the modules and plugins in this collection here](https://docs.ansible.com/ansible/devel/collections/community/routeros/). You can find [documentation for the modules and plugins in this collection here](https://docs.ansible.com/ansible/devel/collections/community/routeros/).
## Code of Conduct
We follow [Ansible Code of Conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html) in all our interactions within this project.
If you encounter abusive behavior violating the [Ansible Code of Conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html), please refer to the [policy violations](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html#policy-violations) section of the Code of Conduct for information on how to raise a complaint.
## Communication
* Join the Ansible forum:
* [Get Help](https://forum.ansible.com/c/help/6): get help or help others.Please add appropriate tags if you start new discussions, for example the `routeros` tag.
* [Posts tagged with 'routeros'](https://forum.ansible.com/tag/routeros): subscribe to participate in RouterOS related conversations.
* [Social Spaces](https://forum.ansible.com/c/chat/4): gather and interact with fellow enthusiasts.
* [News & Announcements](https://forum.ansible.com/c/news/5): track project-wide announcements including social events.
* The Ansible [Bullhorn newsletter](https://docs.ansible.com/ansible/devel/community/communication.html#the-bullhorn): used to announce releases and important changes.
For more information about communication, see the [Ansible communication guide](https://docs.ansible.com/ansible/devel/community/communication.html).
## Tested with Ansible ## Tested with Ansible
Tested with the current ansible-core 2.15, ansible-core 2.16, ansible-core 2.17, ansible-core 2.18, and ansible-core 2.19 releases and the current development version of ansible-core. Ansible 2.9, ansible-base 2.10, and ansible-core versions before 2.15.0 are not supported. Tested with the current Ansible 2.9, ansible-base 2.10 and ansible-core 2.11 releases and the current development version of ansible-core. Ansible versions before 2.9.10 are not supported.
## External requirements ## External requirements
The exact requirements for every module are listed in the module documentation. The exact requirements for every module are listed in the module documentation.
### Supported connections ### Supported connections
@ -48,23 +21,9 @@ The collection supports the `network_cli` connection.
Please note that `community.routeros.api` module does **not** support Windows jump hosts! Please note that `community.routeros.api` module does **not** support Windows jump hosts!
## Collection Documentation
Browsing the [**latest** collection documentation](https://docs.ansible.com/ansible/latest/collections/community/routeros) will show docs for the _latest version released in the Ansible package_, not the latest version of the collection released on Galaxy.
Browsing the [**devel** collection documentation](https://docs.ansible.com/ansible/devel/collections/community/routeros) shows docs for the _latest version released on Galaxy_.
We also separately publish [**latest commit** collection documentation](https://ansible-collections.github.io/community.routeros/branch/main/) which shows docs for the _latest commit in the `main` branch_.
If you use the Ansible package and do not update collections independently, use **latest**. If you install or update this collection directly from Galaxy, use **devel**. If you are looking to contribute, use **latest commit**.
## Included content ## Included content
- `community.routeros.api` - `community.routeros.api`
- `community.routeros.api_facts`
- `community.routeros.api_find_and_modify`
- `community.routeros.api_info`
- `community.routeros.api_modify`
- `community.routeros.command` - `community.routeros.command`
- `community.routeros.facts` - `community.routeros.facts`
@ -110,19 +69,19 @@ Example playbook:
hosts: routers hosts: routers
gather_facts: false gather_facts: false
tasks: tasks:
- name: Run a command
community.routeros.command:
commands:
- /system resource print
register: system_resource_print
- name: Print its output
ansible.builtin.debug:
var: system_resource_print.stdout_lines
- name: Retrieve facts # Run a command and print its output
community.routeros.facts: - community.routeros.command:
- ansible.builtin.debug: commands:
msg: "First IP address: {{ ansible_net_all_ipv4_addresses[0] }}" - /system resource print
register: system_resource_print
- debug:
var: system_resource_print.stdout_lines
# Retrieve facts
- community.routeros.facts:
- debug:
msg: "First IP address: {{ ansible_net_all_ipv4_addresses[0] }}"
``` ```
### Connecting with HTTP/HTTPS API ### Connecting with HTTP/HTTPS API
@ -133,42 +92,23 @@ Example playbook:
--- ---
- name: RouterOS test with API - name: RouterOS test with API
hosts: localhost hosts: localhost
gather_facts: false gather_facts: no
vars: vars:
hostname: 192.168.1.1 hostname: 192.168.1.1
username: admin username: admin
password: test1234 password: test1234
module_defaults:
group/community.routeros.api:
hostname: "{{ hostname }}"
password: "{{ password }}"
username: "{{ username }}"
tls: true
force_no_cert: false
validate_certs: true
validate_cert_hostname: true
ca_path: /path/to/ca-certificate.pem
tasks: tasks:
- name: Get "ip address print" - name: Get "ip address print"
community.routeros.api: community.routeros.api:
path: ip address hostname: "{{ hostname }}"
password: "{{ password }}"
username: "{{ username }}"
path: "ip address"
tls: true
validate_certs: true
validate_cert_hostname: true
ca_path: /path/to/ca-certificate.pem
register: print_path register: print_path
- name: Print the result
ansible.builtin.debug:
var: print_path.msg
- name: Change IP address to 192.168.1.1 for interface bridge
community.routeros.api_find_and_modify:
path: ip address
find:
interface: bridge
values:
address: "192.168.1.1/24"
- name: Retrieve facts
community.routeros.api_facts:
- ansible.builtin.debug:
msg: "First IP address: {{ ansible_net_all_ipv4_addresses[0] }}"
``` ```
## Contributing to this collection ## Contributing to this collection
@ -184,7 +124,7 @@ See [Ansible's dev guide](https://docs.ansible.com/ansible/devel/dev_guide/devel
## Release notes ## Release notes
See the [collection's changelog](https://github.com/ansible-collections/community.routeros/blob/main/CHANGELOG.md). See the [changelog](https://github.com/ansible-collections/community.routeros/blob/main/CHANGELOG.rst).
## Roadmap ## Roadmap
@ -202,10 +142,6 @@ We plan to regularly release minor and patch versions, whenever new features are
## Licensing ## Licensing
This collection is primarily licensed and distributed as a whole under the GNU General Public License v3.0 or later. GNU General Public License v3.0 or later.
See [LICENSES/GPL-3.0-or-later.txt](https://github.com/ansible-collections/community.routeros/blob/main/COPYING) for the full text. See [COPYING](https://www.gnu.org/licenses/gpl-3.0.txt) to see the full text.
Parts of the collection are licensed under the [BSD 2-Clause license](https://github.com/ansible-collections/community.routeros/blob/main/LICENSES/BSD-2-Clause.txt).
All files have a machine readable `SDPX-License-Identifier:` comment denoting its respective license(s) or an equivalent entry in an accompanying `.license` file. Only changelog fragments (which will not be part of a release) are covered by a blanket statement in `REUSE.toml`. This conforms to the [REUSE specification](https://reuse.software/spec/).

View file

@ -1,11 +0,0 @@
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
version = 1
[[annotations]]
path = "changelogs/fragments/**"
precedence = "aggregate"
SPDX-FileCopyrightText = "Ansible Project"
SPDX-License-Identifier = "GPL-3.0-or-later"

View file

@ -1,97 +0,0 @@
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
[collection_sources]
"community.internal_test_tools" = "git+https://github.com/ansible-collections/community.internal_test_tools.git,main"
"community.netcommon" = "git+https://github.com/ansible-collections/ansible.netcommon.git,main"
"community.utils" = "git+https://github.com/ansible-collections/ansible.utils.git,main"
[sessions]
[sessions.lint]
run_isort = false
run_black = false
run_flake8 = false
run_pylint = false
run_yamllint = true
yamllint_config = ".yamllint"
yamllint_config_plugins = ".yamllint-docs"
yamllint_config_plugins_examples = ".yamllint-examples"
yamllint_config_extra_docs = ".yamllint-extra-docs"
run_mypy = false
[sessions.docs_check]
validate_collection_refs="all"
codeblocks_restrict_types = [
"ansible-output",
"ini",
"yaml",
"yaml+jinja",
]
codeblocks_restrict_type_exact_case = true
codeblocks_allow_without_type = false
codeblocks_allow_literal_blocks = false
[sessions.license_check]
[sessions.extra_checks]
run_no_unwanted_files = true
no_unwanted_files_module_extensions = [".py"]
no_unwanted_files_yaml_extensions = [".yml"]
run_action_groups = true
run_no_trailing_whitespace = true
no_trailing_whitespace_skip_directories = [
"tests/unit/plugins/modules/fixtures/",
]
run_avoid_characters = true
[[sessions.extra_checks.action_groups_config]]
name = "api"
pattern = "^api.*$"
exclusions = []
doc_fragment = "community.routeros.attributes.actiongroup_api"
[[sessions.extra_checks.avoid_character_group]]
name = "tab"
regex = "\\x09"
[sessions.build_import_check]
run_galaxy_importer = true
[sessions.ansible_test_sanity]
include_devel = true
[sessions.ansible_test_units]
include_devel = true
[sessions.ansible_test_integration_w_default_container]
include_devel = true
controller_python_versions_only = true
[sessions.ansible_test_integration_w_default_container.core_python_versions]
"2.15" = ["2.7", "3.6", "3.7"]
"2.16" = ["3.10"]
"2.17" = ["3.8"]
"2.18" = ["3.9"]
"2.19" = ["3.11"]
[[sessions.ee_check.execution_environments]]
name = "devel-ubi-9"
description = "ansible-core devel @ RHEL UBI 9"
test_playbooks = ["tests/ee/all.yml"]
config.images.base_image.name = "docker.io/redhat/ubi9:latest"
config.dependencies.ansible_core.package_pip = "https://github.com/ansible/ansible/archive/devel.tar.gz"
config.dependencies.ansible_runner.package_pip = "ansible-runner"
config.dependencies.python_interpreter.package_system = "python3.12 python3.12-pip python3.12-wheel python3.12-cryptography"
config.dependencies.python_interpreter.python_path = "/usr/bin/python3.12"
runtime_environment = {"ANSIBLE_PRIVATE_ROLE_VARS" = "true"}
[[sessions.ee_check.execution_environments]]
name = "2.15-rocky-9"
description = "ansible-core 2.15 @ Rocky Linux 9"
test_playbooks = ["tests/ee/all.yml"]
config.images.base_image.name = "quay.io/rockylinux/rockylinux:9"
config.dependencies.ansible_core.package_pip = "https://github.com/ansible/ansible/archive/stable-2.15.tar.gz"
config.dependencies.ansible_runner.package_pip = "ansible-runner"
runtime_environment = {"ANSIBLE_PRIVATE_ROLE_VARS" = "true"}

File diff suppressed because it is too large Load diff

View file

@ -1,3 +0,0 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Ansible Project

View file

@ -1,43 +1,29 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
changelog_filename_template: ../CHANGELOG.rst changelog_filename_template: ../CHANGELOG.rst
changelog_filename_version_depth: 0 changelog_filename_version_depth: 0
changes_file: changelog.yaml changes_file: changelog.yaml
changes_format: combined changes_format: combined
ignore_other_fragment_extensions: true
keep_fragments: false keep_fragments: false
mention_ancestor: true mention_ancestor: true
flatmap: true
new_plugins_after_name: removed_features new_plugins_after_name: removed_features
notesdir: fragments notesdir: fragments
output_formats:
- rst
- md
prelude_section_name: release_summary prelude_section_name: release_summary
prelude_section_title: Release Summary prelude_section_title: Release Summary
sections: sections:
- - major_changes - - major_changes
- Major Changes - Major Changes
- - minor_changes - - minor_changes
- Minor Changes - Minor Changes
- - breaking_changes - - breaking_changes
- Breaking Changes / Porting Guide - Breaking Changes / Porting Guide
- - deprecated_features - - deprecated_features
- Deprecated Features - Deprecated Features
- - removed_features - - removed_features
- Removed Features (previously deprecated) - Removed Features (previously deprecated)
- - security_fixes - - security_fixes
- Security Fixes - Security Fixes
- - bugfixes - - bugfixes
- Bugfixes - Bugfixes
- - known_issues - - known_issues
- Known Issues - Known Issues
title: Community RouterOS title: Community RouterOS
trivial_section_name: trivial
use_fqcn: true
add_plugin_period: true
changelog_nice_yaml: true
changelog_sort: version
vcs: auto

View file

@ -1,12 +0,0 @@
---
bugfixes:
- |
api_facts - also report interfaces that are inferred only by reference by IP addresses.
RouterOS's APIs have IPv4 and IPv6 addresses point at interfaces by their name, which can
change over time and in-between API calls, such that interfaces may have been enumerated
under another name, or not at all (for example when removed). Such interfaces are now reported
under their new or temporary name and with a synthetic ``type`` property set to differentiate
the more likely and positively confirmed removal case (with ``type: "ansible:unknown"``) from
the unlikely and probably transient naming mismatch (with ``type: "ansible:mismatch"``).
Previously, the api_facts module would have crashed with a ``KeyError`` exception
(https://github.com/ansible-collections/community.routeros/pull/391).

View file

@ -1,2 +0,0 @@
minor_changes:
- api_info, api_modify - add ``show-at-cli-login`` property in ``system note`` (https://github.com/ansible-collections/community.routeros/pull/392).

View file

@ -1,2 +0,0 @@
minor_changes:
- api_info, api_modify - set default value for ``include`` and ``exclude`` properties in ``system note`` to an empty string (https://github.com/ansible-collections/community.routeros/pull/394).

View file

@ -1,7 +1,2 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
fixes: fixes:
- "ansible_collections/community/routeros/::" - "ansible_collections/community/routeros/::"

View file

@ -1,7 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
changelog:
write_changelog: true

View file

@ -1,11 +1,6 @@
--- ---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
sections: sections:
- title: Guides - title: Guides
toctree: toctree:
- api-guide - api-guide
- ssh-guide - ssh-guide
- quoting

View file

@ -1,33 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
edit_on_github:
repository: ansible-collections/community.routeros
branch: main
path_prefix: ''
extra_links:
- description: Ask for help (RouterOS)
url: https://forum.ansible.com/tags/c/help/6/none/routeros
- description: Submit a bug report
url: https://github.com/ansible-collections/community.routeros/issues/new?assignees=&labels=&template=bug_report.md
- description: Request a feature
url: https://github.com/ansible-collections/community.routeros/issues/new?assignees=&labels=&template=feature_request.md
communication:
matrix_rooms:
- topic: General usage and support questions
room: '#users:ansible.im'
irc_channels:
- topic: General usage and support questions
network: Libera
channel: '#ansible'
forums:
- topic: "Ansible Forum: General usage and support questions"
# The following URL directly points to the "Get Help" section
url: https://forum.ansible.com/c/help/6/none
- topic: "Ansible Forum: Discussions about RouterOS"
# The following URL directly points to the "routeros" tag
url: https://forum.ansible.com/tag/routeros

View file

@ -1,14 +1,9 @@
..
Copyright (c) Ansible Project
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
.. _ansible_collections.community.routeros.docsite.api-guide: .. _ansible_collections.community.routeros.docsite.api-guide:
How to connect to RouterOS devices with the RouterOS API How to connect to RouterOS devices with the RouterOS API
======================================================== ========================================================
You can use the :ansplugin:`community.routeros.api module <community.routeros.api#module>` to connect to a RouterOS device with the RouterOS API. More specific module to modify certain entries are the :ansplugin:`community.routeros.api_modify <community.routeros.api_modify#module>` and :ansplugin:`community.routeros.api_find_and_modify <community.routeros.api_find_and_modify#module>` modules. The :ansplugin:`community.routeros.api_info module <community.routeros.api_info#module>` allows to retrieve information on specific predefined paths that can be used as input for the :ansplugin:`community.routeros.api_modify <community.routeros.api_modify#module>` module, and the :ansplugin:`community.routeros.api_facts module <community.routeros.api_facts#module>` allows to retrieve Ansible facts using the RouterOS API. You can use the :ref:`community.routeros.api module <ansible_collections.community.routeros.api_module>` to connect to a RouterOS device with the RouterOS API.
No special setup is needed; the module needs to be run on a host that can connect to the device's API. The most common case is that the module is run on ``localhost``, either by using ``hosts: localhost`` in the playbook, or by using ``delegate_to: localhost`` for the task. The following example shows how to run the equivalent of ``/ip address print``: No special setup is needed; the module needs to be run on a host that can connect to the device's API. The most common case is that the module is run on ``localhost``, either by using ``hosts: localhost`` in the playbook, or by using ``delegate_to: localhost`` for the task. The following example shows how to run the equivalent of ``/ip address print``:
@ -17,7 +12,7 @@ No special setup is needed; the module needs to be run on a host that can connec
--- ---
- name: RouterOS test with API - name: RouterOS test with API
hosts: localhost hosts: localhost
gather_facts: false gather_facts: no
vars: vars:
hostname: 192.168.1.1 hostname: 192.168.1.1
username: admin username: admin
@ -38,9 +33,9 @@ No special setup is needed; the module needs to be run on a host that can connec
# ca_path: /path/to/ca-certificate.pem # ca_path: /path/to/ca-certificate.pem
register: print_path register: print_path
- name: Show IP address of first interface - name: Show IP address of first interface
ansible.builtin.debug: debug:
msg: "{{ print_path.msg[0].address }}" msg: "{{ print_path.msg[0].address }}"
This results in the following output: This results in the following output:
@ -57,60 +52,18 @@ This results in the following output:
} }
PLAY RECAP ******************************************************************************************************* PLAY RECAP *******************************************************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 localhost : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Check out the documentation of the :ansplugin:`community.routeros.api module <community.routeros.api#module>` for details on the options. Check out the documenation of the :ref:`community.routeros.api module <ansible_collections.community.routeros.api_module>` for details on the options.
Using the ``community.routeros.api`` module defaults group
----------------------------------------------------------
To avoid having to specify common parameters for all the API based modules in every task, you can use the ``community.routeros.api`` :ref:`module defaults group <module_defaults_groups>`:
.. code-block:: yaml+jinja
---
- name: RouterOS test with API
hosts: localhost
gather_facts: false
module_defaults:
group/community.routeros.api:
hostname: 192.168.1.1
password: admin
username: test1234
# The following options configure TLS/SSL.
# Depending on your setup, these options need different values:
tls: true
validate_certs: true
validate_cert_hostname: true
# If you are using your own PKI, specify the path to your CA certificate here:
# ca_path: /path/to/ca-certificate.pem
tasks:
- name: Gather facts
community.routeros.api_facts:
- name: Get "ip address print"
community.routeros.api:
path: "ip address"
- name: Change IP address to 192.168.1.1 for interface bridge
community.routeros.api_find_and_modify:
path: ip address
find:
interface: bridge
values:
address: "192.168.1.1/24"
Here all three tasks will use the options set for the module defaults group.
Setting up encryption Setting up encryption
--------------------- ---------------------
It is recommended to always use :ansopt:`tls=true` when connecting with the API, even if you are only connecting to the device through a trusted network. The following options control how TLS/SSL is used: It is recommended to always use ``tls: true`` when connecting with the API, even if you are only connecting to the device through a trusted network. The following options control how TLS/SSL is used:
:force_no_cert: Setting to :ansval:`true` connects to the device without a certificate. **This is discouraged to use in production and is susceptible to Man-in-the-Middle attacks**, but might be useful when setting the device up. The default value is :ansval:`false`. :validate_certs: Setting to ``false`` disables any certificate validation. **This is discouraged to use in production**, but is needed when setting the device up. The default value is ``true``.
:validate_certs: Setting to :ansval:`false` disables any certificate validation. **This is discouraged to use in production**, but is needed when setting the device up. The default value is :ansval:`true`. :validate_cert_hostname: Setting to ``false`` (default) disables hostname verification during certificate validation. This is needed if the hostnames specified in the certificate do not match the hostname used for connecting (usually the device's IP). It is recommended to set up the certificate correctly and set this to ``true``; the default ``false`` is chosen for backwards compatibility to an older version of the module.
:validate_cert_hostname: Setting to :ansval:`false` (default) disables hostname verification during certificate validation. This is needed if the hostnames specified in the certificate do not match the hostname used for connecting (usually the device's IP). It is recommended to set up the certificate correctly and set this to :ansval:`true`; the default :ansval:`false` is chosen for backwards compatibility to an older version of the module. :ca_path: If you are not using a commerically trusted CA certificate to sign your device's certificate, or have not included your CA certificate in Python's truststore, you need to point this option to the CA certificate.
:ca_path: If you are not using a commercially trusted CA certificate to sign your device's certificate, or have not included your CA certificate in Python's truststore, you need to point this option to the CA certificate.
We recommend to create a CA certificate that is used to sign the certificates for your RouterOS devices, and have the certificates include the correct hostname(s), including the IP of the device. That way, you can fully enable TLS and be sure that you always talk to the correct device. We recommend to create a CA certificate that is used to sign the certificates for your RouterOS devices, and have the certificates include the correct hostname(s), including the IP of the device. That way, you can fully enable TLS and be sure that you always talk to the correct device.
@ -124,7 +77,7 @@ Installing a certificate on a MikroTik router
Installing the certificate is best done with the SSH connection. (See the :ref:`ansible_collections.community.routeros.docsite.ssh-guide` guide for more information.) Once the certificate has been installed, and the HTTPS API enabled, it's easier to work with the API, since it has a quite a few less problems, and returns data as JSON objects instead of text you first have to parse. Installing the certificate is best done with the SSH connection. (See the :ref:`ansible_collections.community.routeros.docsite.ssh-guide` guide for more information.) Once the certificate has been installed, and the HTTPS API enabled, it's easier to work with the API, since it has a quite a few less problems, and returns data as JSON objects instead of text you first have to parse.
First you have to convert the certificate and its private key to a `PKCS #12 bundle <https://en.wikipedia.org/wiki/PKCS_12>`_. This can be done with the :ansplugin:`community.crypto.openssl_pkcs12 <community.crypto.openssl_pkcs12#module>`. The following playbook assumes that the certificate is available as ``keys/{{ inventory_hostname }}.pem``, and its private key is available as ``keys/{{ inventory_hostname }}.key``. It generates a random passphrase to protect the PKCS#12 file. First you have to convert the certificate and its private key to a `PKCS #12 bundle <https://en.wikipedia.org/wiki/PKCS_12>`_. This can be done with the :ref:`community.crypto.openssl_pkcs12 <ansible_collections.community.crypto.openssl_pkcs12_module>`. The following playbook assumes that the certificate is available as ``keys/{{ inventory_hostname }}.pem``, and its private key is available as ``keys/{{ inventory_hostname }}.key``. It generates a random passphrase to protect the PKCS#12 file.
.. code-block:: yaml+jinja .. code-block:: yaml+jinja
@ -186,12 +139,12 @@ First you have to convert the certificate and its private key to a `PKCS #12 bun
The playbook also assumes that ``admin_network`` describes the network from which the HTTPS and API interface can be accessed. This can be for example ``192.168.1.0/24``. The playbook also assumes that ``admin_network`` describes the network from which the HTTPS and API interface can be accessed. This can be for example ``192.168.1.0/24``.
When this playbook completed successfully, you should be able to use the HTTPS admin interface (reachable in a browser from ``https://192.168.1.1/``, with the correct IP inserted), as well as the :ansplugin:`community.routeros.api module <community.routeros.api#module>` module with TLS and certificate validation enabled: When this playbook completed successfully, you should be able to use the HTTPS admin interface (reachable in a browser from ``https://192.168.1.1/``, with the correct IP inserted), as well as the :ref:`community.routeros.api module <ansible_collections.community.routeros.api_module>` module with TLS and certificate validation enabled:
.. code-block:: yaml+jinja .. code-block:: yaml+jinja
- community.routeros.api: - community.routeros.api:
# ... ...
tls: true tls: true
validate_certs: true validate_certs: true
validate_cert_hostname: true validate_cert_hostname: true

View file

@ -1,19 +0,0 @@
..
Copyright (c) Ansible Project
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
.. _ansible_collections.community.routeros.docsite.quoting:
How to quote and unquote commands and arguments
===============================================
When using the :ansplugin:`community.routeros.command module <community.routeros.command#module>` or the :ansplugin:`community.routeros.api module <community.routeros.api#module>` modules, you need to pass text data in quoted form. While in some cases quoting is not needed (when passing IP addresses or names without spaces, for example), in other cases it is required, like when passing a comment which contains a space.
The community.routeros collection provides a set of Jinja2 filter plugins which helps you with these tasks:
- The :ansplugin:`community.routeros.quote_argument_value filter <community.routeros.quote_argument_value#filter>` quotes an argument value: ``'this is a "comment"' | community.routeros.quote_argument_value == '"this is a \\"comment\\""'``.
- The :ansplugin:`community.routeros.quote_argument filter <community.routeros.quote_argument#filter>` quotes an argument with or without a value: ``'comment=this is a "comment"' | community.routeros.quote_argument == 'comment="this is a \\"comment\\""'``.
- The :ansplugin:`community.routeros.join filter <community.routeros.join#filter>` quotes a list of arguments and joins them to one string: ``['foo=bar', 'comment=foo is bar'] | community.routeros.join == 'foo=bar comment="foo is bar"'``.
- The :ansplugin:`community.routeros.split filter <community.routeros.split#filter>` splits a command into a list of arguments (with or without values): ``'foo=bar comment="foo is bar"' | community.routeros.split == ['foo=bar', 'comment=foo is bar']``
- The :ansplugin:`community.routeros.list_to_dict filter <community.routeros.list_to_dict#filter>` splits a list of arguments with values into a dictionary: ``['foo=bar', 'comment=foo is bar'] | community.routeros.list_to_dict == {'foo': 'bar', 'comment': 'foo is bar'}``. It has two optional arguments: :ansopt:`community.routeros.list_to_dict#filter:require_assignment` (default value :ansval:`true`) allows to accept arguments without values when set to :ansval:`false`; and :ansopt:`community.routeros.list_to_dict#filter:skip_empty_values` (default value :ansval:`false`) allows to skip arguments whose value is empty.

View file

@ -1,8 +1,3 @@
..
Copyright (c) Ansible Project
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
.. _ansible_collections.community.routeros.docsite.ssh-guide: .. _ansible_collections.community.routeros.docsite.ssh-guide:
How to connect to RouterOS devices with SSH How to connect to RouterOS devices with SSH
@ -10,17 +5,17 @@ How to connect to RouterOS devices with SSH
The collection offers two modules to connect to RouterOS devies with SSH: The collection offers two modules to connect to RouterOS devies with SSH:
- The :ansplugin:`community.routeros.facts module <community.routeros.facts#module>` gathers facts about a RouterOS device; - The :ref:`community.routeros.facts module <ansible_collections.community.routeros.facts_module>` gathers facts about a RouterOS device;
- The :ansplugin:`community.routeros.command module <community.routeros.command#module>` executes commands on a RouterOS device. - The :ref:`community.routeros.command module <ansible_collections.community.routeros.command_module>` executes commands on a RouterOS device.
The modules need the :ansplugin:`ansible.netcommon.network_cli connection plugin <ansible.netcommon.network_cli#connection>` for this. The modules need the :ref:`ansible.netcommon.network_cli connection plugin <ansible_collections.ansible.netcommon.network_cli_connection>` for this.
Important notes Important notes
--------------- ---------------
1. The SSH-based modules do not support arbitrary symbols in the router's identity. If you are having trouble connecting to your device, please make sure that your MikroTik's identity contains only alphanumeric characters and dashes. Also make sure that the identity string is not longer than 19 characters (`see issue for details <https://github.com/ansible-collections/community.routeros/issues/31>`__). Similar problems can happen for unsupported characters in your username. 1. The SSH-based modules do not support arbitrary symbols in the router's identity. If you are having trouble connecting to your device, please make sure that your MikroTik's identity contains only alphanumeric characters and dashes. Also make sure that the identity string is not longer than 19 characters (`see issue for details <https://github.com/ansible-collections/community.routeros/issues/31>`__). Similar problems can happen for unsupported characters in your username.
2. The :ansplugin:`community.routeros.command module <community.routeros.command#module>` does not support nesting commands and expects every command to start with a forward slash (``/``). Running the following command will produce an error: 2. The :ref:`community.routeros.command module <ansible_collections.community.routeros.command_module>` does not support nesting commands and expects every command to start with a forward slash (``/``). Running the following command will produce an error:
.. code-block:: yaml+jinja .. code-block:: yaml+jinja
@ -29,11 +24,9 @@ Important notes
- /ip - /ip
- print - print
3. When using the :ansplugin:`community.routeros.command module <community.routeros.command#module>` module, make sure to not specify too long commands. Alternatively, add something like ``+cet512w`` to the username (replace ``admin`` with ``admin+cet512w``) to tell RouterOS to not wrap before 512 characters in a line (`see issue for details <https://github.com/ansible-collections/community.routeros/issues/6>`__). 3. When using the :ref:`community.routeros.command module <ansible_collections.community.routeros.command_module>` module, make sure to not specify too long commands. Alternatively, add something like ``+cet512w`` to the username (replace ``admin`` with ``admin+cet512w``) to tell RouterOS to not wrap before 512 characters in a line (`see issue for details <https://github.com/ansible-collections/community.routeros/issues/6>`__).
4. The :ansplugin:`ansible.netcommon.network_cli connection plugin <ansible.netcommon.network_cli#connection>` uses `paramiko <https://pypi.org/project/paramiko/>`_ by default to connect to devices with SSH. You can set its :ansopt:`ansible.netcommon.network_cli#connection:ssh_type` option to :ansval:`libssh` to use `ansible-pylibssh <https://pypi.org/project/ansible-pylibssh/>`_ instead, which offers Python bindings to libssh. See its documentation for details. 4. Finally, the :ref:`ansible.netcommon.network_cli connection plugin <ansible_collections.ansible.netcommon.network_cli_connection>` uses `paramiko <https://pypi.org/project/paramiko/>`_ by default to connect to devices with SSH. You can set its ``ssh_type`` option to ``libssh`` to use `ansible-pylibssh <https://pypi.org/project/ansible-pylibssh/>`_ instead, which offers Python bindings to libssh. See its documentation for details.
5. User is **not allowed** to login via SSH by password to modern Mikrotik if SSH key for the user is added!
Setting up an inventory Setting up an inventory
----------------------- -----------------------
@ -51,7 +44,7 @@ An example inventory ``hosts`` file for a RouterOS device is as follows:
ansible_user=admin ansible_user=admin
ansible_ssh_pass=test1234 ansible_ssh_pass=test1234
This tells Ansible that you have a RouterOS device called ``router`` with IP ``192.168.2.1``. Ansible should use the :ansplugin:`ansible.netcommon.network_cli connection plugin <ansible.netcommon.network_cli#connection>` together with the the :ansplugin:`community.routeros.routeros cliconf plugin <community.routeros.routeros#cliconf>`. The credentials are stored as ``ansible_user`` and ``ansible_ssh_pass`` in the inventory. This tells Ansible that you have a RouterOS device called ``router`` with IP ``192.168.2.1``. Ansible should use the :ref:`ansible.netcommon.network_cli connection plugin <ansible_collections.ansible.netcommon.network_cli_connection>` together with the the :ref:`community.routeros.routeros cliconf plugin <ansible_collections.community.routeros.routeros_cliconf>`. The credentials are stored as ``ansible_user`` and ``ansible_ssh_pass`` in the inventory.
Connecting to the device Connecting to the device
------------------------ ------------------------
@ -66,22 +59,22 @@ With the above inventory, you can use the following playbook to execute ``/syste
gather_facts: false gather_facts: false
tasks: tasks:
- name: Gather system resources - name: Gather system resources
community.routeros.command: community.routeros.command:
commands: commands:
- /system resource print - /system resource print
register: system_resource_print register: system_resource_print
- name: Show system resources - name: Show system resources
debug: debug:
var: system_resource_print.stdout_lines var: system_resource_print.stdout_lines
- name: Gather facts - name: Gather facts
community.routeros.facts: community.routeros.facts:
- name: Show a fact - name: Show a fact
debug: debug:
msg: "First IP address: {{ ansible_net_all_ipv4_addresses[0] }}" msg: "First IP address: {{ ansible_net_all_ipv4_addresses[0] }}"
This results in the following output: This results in the following output:
@ -126,4 +119,4 @@ This results in the following output:
} }
PLAY RECAP ******************************************************************************************************* PLAY RECAP *******************************************************************************************************
router : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 router : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

View file

@ -1,22 +1,14 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# See https://docs.ansible.com/ansible/latest/dev_guide/collections_galaxy_meta.html # See https://docs.ansible.com/ansible/latest/dev_guide/collections_galaxy_meta.html
namespace: community namespace: community
name: routeros name: routeros
version: 3.9.0 version: 2.0.0-a1
readme: README.md readme: README.md
authors: authors:
- Egor Zaitsev (github.com/heuels) - Egor Zaitsev (github.com/heuels)
- Nikolay Dachev (github.com/NikolayDachev) - Nikolay Dachev (github.com/NikolayDachev)
- Felix Fontein (github.com/felixfontein) description: Modules for MikroTik RouterOS
description: Modules and plugins for MikroTik RouterOS license_file: COPYING
license:
- GPL-3.0-or-later
# license_file: COPYING
tags: tags:
- network - network
- mikrotik - mikrotik

View file

@ -1,5 +0,0 @@
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
librouteros

View file

@ -1,8 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
version: 1
dependencies:
python: meta/ee-requirements.txt

View file

@ -1,13 +1,2 @@
--- ---
# Copyright (c) Ansible Project requires_ansible: '>=2.9.10'
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
requires_ansible: '>=2.15.0'
action_groups:
api:
- api
- api_facts
- api_find_and_modify
- api_info
- api_modify

View file

@ -1,53 +0,0 @@
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# The following metadata allows Python runners and nox to install the required
# dependencies for running this Python script:
#
# /// script
# dependencies = ["nox>=2025.02.09", "antsibull-nox"]
# ///
import os
import sys
import nox
# We try to import antsibull-nox, and if that doesn't work, provide a more useful
# error message to the user.
try:
import antsibull_nox
except ImportError:
print("You need to install antsibull-nox in the same Python environment as nox.")
sys.exit(1)
IN_CI = os.environ.get("CI") == "true"
antsibull_nox.load_antsibull_nox_toml()
@nox.session(name="update-docs", default=True)
def update_docs_fragments(session: nox.Session) -> None:
"""
Update/check auto-generated parts of docs fragments.
"""
session.install("ansible-core")
prepare = antsibull_nox.sessions.prepare_collections(
session, install_in_site_packages=True
)
if not prepare:
return
data = ["python", "tests/update-docs.py"]
if IN_CI:
data.append("--lint")
session.run(*data)
# Allow to run the noxfile with `python noxfile.py`, `pipx run noxfile.py`, or similar.
# Requires nox >= 2025.02.09
if __name__ == "__main__":
nox.main()

View file

@ -1,24 +1,42 @@
# Copyright (c) 2017 Red Hat Inc. #
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # (c) 2017 Red Hat Inc.
# SPDX-License-Identifier: GPL-3.0-or-later #
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r""" DOCUMENTATION = '''
---
author: "Egor Zaitsev (@heuels)" author: "Egor Zaitsev (@heuels)"
name: routeros name: routeros
short_description: Use routeros cliconf to run command on MikroTik RouterOS platform short_description: Use routeros cliconf to run command on MikroTik RouterOS platform
description: description:
- This routeros plugin provides low level abstraction APIs for sending and receiving CLI commands from MikroTik RouterOS - This routeros plugin provides low level abstraction apis for
network devices. sending and receiving CLI commands from MikroTik RouterOS network devices.
""" '''
import re import re
import json import json
from ansible.module_utils.common.text.converters import to_text from itertools import chain
from ansible.plugins.cliconf import CliconfBase
from ansible.module_utils.common.text.converters import to_bytes, to_text
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list
from ansible.plugins.cliconf import CliconfBase, enable_mode
class Cliconf(CliconfBase): class Cliconf(CliconfBase):
@ -47,7 +65,7 @@ class Cliconf(CliconfBase):
return device_info return device_info
def get_config(self, source='running', flags=None, format=None): def get_config(self, source='running', format='text', flags=None):
return return
def edit_config(self, command): def edit_config(self, command):

View file

@ -1,133 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020, Nikolay Dachev <nikolay@dachev.info>
# GNU General Public License v3.0+ https://www.gnu.org/licenses/gpl-3.0.txt
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
class ModuleDocFragment(object):
DOCUMENTATION = r"""
options:
hostname:
description:
- RouterOS hostname API.
required: true
type: str
username:
description:
- RouterOS login user.
required: true
type: str
password:
description:
- RouterOS user password.
required: true
type: str
timeout:
description:
- Timeout for the request.
type: int
default: 10
version_added: 2.3.0
tls:
description:
- If is set TLS will be used for RouterOS API connection.
required: false
type: bool
default: false
aliases:
- ssl
port:
description:
- RouterOS API port. If O(tls) is set, port will apply to TLS/SSL connection.
- Defaults are V(8728) for the HTTP API, and V(8729) for the HTTPS API.
type: int
force_no_cert:
description:
- Set to V(true) to connect without a certificate when O(tls=true).
- See also O(validate_certs).
- B(Note:) this forces the use of anonymous Diffie-Hellman (ADH) ciphers. The protocol is susceptible to Man-in-the-Middle
attacks, because the keys used in the exchange are not authenticated. Instead of simply connecting without a certificate
to "make things work" have a look at O(validate_certs) and O(ca_path).
type: bool
default: false
version_added: 2.4.0
validate_certs:
description:
- Set to V(false) to skip validation of TLS certificates.
- See also O(validate_cert_hostname). Only used when O(tls=true).
- B(Note:) instead of simply deactivating certificate validations to "make things work", please consider creating your
own CA certificate and using it to sign certificates used for your router. You can tell the module about your CA certificate
with the O(ca_path) option.
type: bool
default: true
version_added: 1.2.0
validate_cert_hostname:
description:
- Set to V(true) to validate hostnames in certificates.
- See also O(validate_certs). Only used when O(tls=true) and O(validate_certs=true).
type: bool
default: false
version_added: 1.2.0
ca_path:
description:
- PEM formatted file that contains a CA certificate to be used for certificate validation.
- See also O(validate_cert_hostname). Only used when O(tls=true) and O(validate_certs=true).
type: path
version_added: 1.2.0
encoding:
description:
- Use the specified encoding when communicating with the RouterOS device.
- Default is V(ASCII). Note that V(UTF-8) requires librouteros 3.2.1 or newer.
type: str
default: ASCII
version_added: 2.1.0
requirements:
- librouteros
- Python >= 3.6 (for librouteros)
seealso:
- ref: ansible_collections.community.routeros.docsite.api-guide
description: How to connect to RouterOS devices with the RouterOS API.
"""
RESTRICT = r"""
options:
restrict:
type: list
elements: dict
suboptions:
field:
description:
- The field whose values to restrict.
required: true
type: str
match_disabled:
description:
- Whether disabled or not provided values should match.
type: bool
default: false
values:
description:
- The values of the field to limit to.
- 'Note that the types of the values are important. If you provide a string V("0"), and librouteros converts the
value returned by the API to the integer V(0), then this will not match. If you are not sure, better include both
variants: both the string and the integer.'
type: list
elements: raw
regex:
description:
- A regular expression matching values of the field to limit to.
- Note that all values will be converted to strings before matching.
- It is not possible to match disabled values with regular expressions. Set O(restrict[].match_disabled=true) if
you also want to match disabled values.
type: str
invert:
description:
- Invert the condition. This affects O(restrict[].match_disabled), O(restrict[].values), and O(restrict[].regex).
type: bool
default: false
"""

View file

@ -1,112 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
class ModuleDocFragment(object):
# Standard documentation fragment
DOCUMENTATION = r"""
options: {}
attributes:
check_mode:
description: Can run in C(check_mode) and return changed status prediction without modifying target.
diff_mode:
description: Will return details on what has changed (or possibly needs changing in C(check_mode)), when in diff mode.
platform:
description: Target OS/families that can be operated against.
support: N/A
idempotent:
description:
- When run twice in a row outside check mode, with the same arguments, the second invocation indicates no change.
- This assumes that the system controlled/queried by the module has not changed in a relevant way.
"""
# Should be used together with the standard fragment
IDEMPOTENT_NOT_MODIFY_STATE = r"""
options: {}
attributes:
idempotent:
support: full
details:
- This action does not modify state.
"""
# Should be used together with the standard fragment
INFO_MODULE = r'''
options: {}
attributes:
check_mode:
support: full
details:
- This action does not modify state.
diff_mode:
support: N/A
details:
- This action does not modify state.
'''
ACTIONGROUP_API = r'''
options: {}
attributes:
action_group:
description: Use C(group/community.routeros.api) in C(module_defaults) to set defaults for this module.
support: full
membership:
- community.routeros.api
'''
CONN = r"""
options: {}
attributes:
become:
description: Is usable alongside C(become) keywords.
connection:
description: Uses the target's configured connection information to execute code on it.
delegation:
description: Can be used in conjunction with C(delegate_to) and related keywords.
"""
FACTS = r"""
options: {}
attributes:
facts:
description: Action returns an C(ansible_facts) dictionary that will update existing host facts.
"""
# Should be used together with the standard fragment and the FACTS fragment
FACTS_MODULE = r'''
options: {}
attributes:
check_mode:
support: full
details:
- This action does not modify state.
diff_mode:
support: N/A
details:
- This action does not modify state.
facts:
support: full
'''
FILES = r"""
options: {}
attributes:
safe_file_operations:
description: Uses Ansible's strict file operation functions to ensure proper permissions and avoid data corruption.
"""
FLOW = r"""
options: {}
attributes:
action:
description: Indicates this has a corresponding action plugin so some parts of the options can be executed on the controller.
async:
description: Supports being used with the C(async) keyword.
"""

View file

@ -1,32 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
DOCUMENTATION:
name: join
short_description: Join a list of arguments to a command
version_added: 2.0.0
description:
- Join and quotes a list of arguments to a command.
options:
_input:
description:
- A list of arguments to quote and join.
type: list
elements: string
required: true
author:
- Felix Fontein (@felixfontein)
EXAMPLES: |
---
- name: Join arguments for a RouterOS CLI command
ansible.builtin.set_fact:
arguments: "{{ ['foo=bar', 'comment=foo is bar'] | community.routeros.join }}"
# Should result in 'foo=bar comment="foo is bar"'
RETURN:
_value:
description: The joined and quoted result.
type: string

View file

@ -1,42 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
DOCUMENTATION:
name: list_to_dict
short_description: Convert a list of arguments to a dictionary
version_added: 2.0.0
description:
- Convert a list of arguments to a dictionary.
options:
_input:
description:
- A list of assignments. Can be the result of the P(community.routeros.split#filter) filter.
type: list
elements: string
required: true
require_assignment:
description:
- Allows to accept arguments without values when set to V(false).
type: boolean
default: true
skip_empty_values:
description:
- Allows to skip arguments whose value is empty when set to V(true).
type: boolean
default: false
author:
- Felix Fontein (@felixfontein)
EXAMPLES: |
---
- name: Convert a list to a dictionary
ansible.builtin.set_fact:
dictionary: "{{ ['foo=bar', 'comment=foo is bar'] | community.routeros.list_to_dict }}"
# dictionary == {'foo': 'bar', 'comment': 'foo is bar'}
RETURN:
_value:
description: A dictionary representation of the input data.
type: dictionary

View file

@ -1,32 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
DOCUMENTATION:
name: quote_argument
short_description: Quote an argument
version_added: 2.0.0
description:
- Quote an argument.
options:
_input:
description:
- An argument to quote.
type: string
required: true
author:
- Felix Fontein (@felixfontein)
EXAMPLES: |
---
- name: Quote a RouterOS CLI command argument
ansible.builtin.set_fact:
quoted: >-
{{ 'comment=this is a "comment"' | community.routeros.quote_argument }}
# Should result in 'comment="this is a \"comment\""'
RETURN:
_value:
description: The quoted argument.
type: string

View file

@ -1,32 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
DOCUMENTATION:
name: quote_argument_value
short_description: Quote an argument value
version_added: 2.0.0
description:
- Quote an argument value.
options:
_input:
description:
- An argument value to quote.
type: string
required: true
author:
- Felix Fontein (@felixfontein)
EXAMPLES: |
---
- name: Quote a RouterOS CLI command argument's value
ansible.builtin.set_fact:
quoted: >-
{{ 'this is a "comment"' | community.routeros.quote_argument_value }}
# Should result in '"this is a \"comment\""'
RETURN:
_value:
description: The quoted argument value.
type: string

View file

@ -1,114 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Felix Fontein <felix@fontein.de>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import absolute_import, division, print_function
__metaclass__ = type
from ansible.errors import AnsibleFilterError
from ansible.module_utils.common.text.converters import to_text
from ansible_collections.community.routeros.plugins.module_utils.quoting import (
ParseError,
convert_list_to_dictionary,
join_routeros_command,
quote_routeros_argument,
quote_routeros_argument_value,
split_routeros_command,
)
def wrap_exception(fn, *args, **kwargs):
try:
return fn(*args, **kwargs)
except ParseError as e:
raise AnsibleFilterError(to_text(e))
def split(line):
'''
Split a command into arguments.
Example:
'add name=wrap comment="with space"'
is converted to:
['add', 'name=wrap', 'comment=with space']
'''
return wrap_exception(split_routeros_command, line)
def quote_argument_value(argument):
'''
Quote an argument value.
Example:
'with "space"'
is converted to:
r'"with \"space\""'
'''
return wrap_exception(quote_routeros_argument_value, argument)
def quote_argument(argument):
'''
Quote an argument.
Example:
'comment=with "space"'
is converted to:
r'comment="with \"space\""'
'''
return wrap_exception(quote_routeros_argument, argument)
def join(arguments):
'''
Join a list of arguments to a command.
Example:
['add', 'name=wrap', 'comment=with space']
is converted to:
'add name=wrap comment="with space"'
'''
return wrap_exception(join_routeros_command, arguments)
def list_to_dict(string_list, require_assignment=True, skip_empty_values=False):
'''
Convert a list of arguments to a list of dictionary.
Example:
['foo=bar', 'comment=with space', 'additional=']
is converted to:
{'foo': 'bar', 'comment': 'with space', 'additional': ''}
If require_assignment is True (default), arguments without assignments are
rejected. (Example: in ['add', 'name=foo'], 'add' is an argument without
assignment.) If it is False, these are given value None.
If skip_empty_values is True, arguments with empty value are removed from
the result. (Example: in ['name='], 'name' has an empty value.)
If it is False (default), these are kept.
'''
return wrap_exception(
convert_list_to_dictionary,
string_list,
require_assignment=require_assignment,
skip_empty_values=skip_empty_values,
)
class FilterModule(object):
'''Ansible jinja2 filters for RouterOS command quoting and unquoting'''
def filters(self):
return {
'split': split,
'quote_argument': quote_argument,
'quote_argument_value': quote_argument_value,
'join': join,
'list_to_dict': list_to_dict,
}

View file

@ -1,33 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
DOCUMENTATION:
name: split
short_description: Split a command into arguments
version_added: 2.0.0
description:
- Split a command into arguments.
options:
_input:
description:
- A command.
type: string
required: true
author:
- Felix Fontein (@felixfontein)
EXAMPLES: |
---
- name: Split command into list of arguments
ansible.builtin.set_fact:
argument_list: >-
{{ 'foo=bar comment="foo is bar" baz' | community.routeros.split }}
# Should result in ['foo=bar', 'comment=foo is bar', 'baz']
RETURN:
_value:
description: The list of arguments.
type: list
elements: string

View file

File diff suppressed because it is too large Load diff

View file

@ -1,102 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2022, Felix Fontein (@felixfontein) <felix@fontein.de>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# The data inside here is private to this collection. If you use this from outside the collection,
# you are on your own. There can be random changes to its format even in bugfix releases!
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import re
from ansible.module_utils.common.text.converters import to_text
def validate_and_prepare_restrict(module, path_info):
restrict = module.params['restrict']
if restrict is None:
return None
restrict_data = []
for rule in restrict:
field = rule['field']
if field.startswith('!'):
module.fail_json(msg='restrict: the field name "{0}" must not start with "!"'.format(field))
f = path_info.fields.get(field)
if f is None:
module.fail_json(msg='restrict: the field "{0}" does not exist for this path'.format(field))
new_rule = dict(
field=field,
match_disabled=rule['match_disabled'],
invert=rule['invert'],
)
if rule['values'] is not None:
new_rule['values'] = rule['values']
if rule['regex'] is not None:
regex = rule['regex']
try:
new_rule['regex'] = re.compile(regex)
new_rule['regex_source'] = regex
except Exception as exc:
module.fail_json(msg='restrict: invalid regular expression "{0}": {1}'.format(regex, exc))
restrict_data.append(new_rule)
return restrict_data
def _value_to_str(value):
if value is None:
return None
value_str = to_text(value)
if isinstance(value, bool):
value_str = value_str.lower()
return value_str
def _test_rule_except_invert(value, rule):
if value is None and rule['match_disabled']:
return True
if 'values' in rule and value in rule['values']:
return True
if 'regex' in rule and value is not None and rule['regex'].match(_value_to_str(value)):
return True
return False
def restrict_entry_accepted(entry, path_info, restrict_data):
if restrict_data is None:
return True
for rule in restrict_data:
# Obtain field and value
field = rule['field']
field_info = path_info.fields[field]
value = entry.get(field)
if value is None:
value = field_info.default
if field not in entry and field_info.absent_value:
value = field_info.absent_value
# Check
matches_rule = _test_rule_except_invert(value, rule)
if rule['invert']:
matches_rule = not matches_rule
if not matches_rule:
return False
return True
def restrict_argument_spec():
return dict(
restrict=dict(
type='list',
elements='dict',
options=dict(
field=dict(type='str', required=True),
match_disabled=dict(type='bool', default=False),
values=dict(type='list', elements='raw'),
regex=dict(type='str'),
invert=dict(type='bool', default=False),
),
),
)

View file

@ -1,120 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2022, Felix Fontein (@felixfontein) <felix@fontein.de>
# Copyright (c) 2020, Nikolay Dachev <nikolay@dachev.info>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import absolute_import, division, print_function
__metaclass__ = type
from ansible.module_utils.basic import missing_required_lib
from ansible.module_utils.common.text.converters import to_native
import ssl
import traceback
LIB_IMP_ERR = None
try:
from librouteros import connect
from librouteros.exceptions import LibRouterosError # noqa: F401, pylint: disable=unused-import
HAS_LIB = True
except Exception as e:
HAS_LIB = False
LIB_IMP_ERR = traceback.format_exc()
def check_has_library(module):
if not HAS_LIB:
module.fail_json(
msg=missing_required_lib('librouteros'),
exception=LIB_IMP_ERR,
)
def api_argument_spec():
return dict(
username=dict(type='str', required=True),
password=dict(type='str', required=True, no_log=True),
hostname=dict(type='str', required=True),
port=dict(type='int'),
tls=dict(type='bool', default=False, aliases=['ssl']),
force_no_cert=dict(type='bool', default=False),
validate_certs=dict(type='bool', default=True),
validate_cert_hostname=dict(type='bool', default=False),
ca_path=dict(type='path'),
encoding=dict(type='str', default='ASCII'),
timeout=dict(type='int', default=10),
)
def _ros_api_connect(module, username, password, host, port, use_tls, force_no_cert, validate_certs, validate_cert_hostname, ca_path, encoding, timeout):
'''Connect to RouterOS API.'''
if not port:
if use_tls:
port = 8729
else:
port = 8728
try:
params = dict(
username=username,
password=password,
host=host,
port=port,
encoding=encoding,
timeout=timeout,
)
if use_tls:
ctx = ssl.create_default_context(cafile=ca_path)
wrap_context = ctx.wrap_socket
if force_no_cert:
ctx.check_hostname = False
ctx.set_ciphers("ADH:@SECLEVEL=0")
elif not validate_certs:
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
elif not validate_cert_hostname:
ctx.check_hostname = False
else:
# Since librouteros does not pass server_hostname,
# we have to do this ourselves:
def wrap_context(*args, **kwargs):
kwargs.pop('server_hostname', None)
return ctx.wrap_socket(*args, server_hostname=host, **kwargs)
params['ssl_wrapper'] = wrap_context
api = connect(**params)
except Exception as e:
connection = {
'username': username,
'hostname': host,
'port': port,
'ssl': use_tls,
'status': 'Error while connecting: %s' % to_native(e),
}
module.fail_json(msg=connection['status'], connection=connection)
return api
def create_api(module):
"""Create an API object."""
return _ros_api_connect(
module,
module.params['username'],
module.params['password'],
module.params['hostname'],
module.params['port'],
module.params['tls'],
module.params['force_no_cert'],
module.params['validate_certs'],
module.params['validate_cert_hostname'],
module.params['ca_path'],
module.params['encoding'],
module.params['timeout'],
)
def get_api_version(api):
"""Given an API object, query the system's version."""
system_info = list(api.path().join('system', 'resource'))[0]
return system_info['version'].split(' ', 1)[0]

View file

@ -1,207 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Felix Fontein (@felixfontein) <felix@fontein.de>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import sys
from ansible.module_utils.common.text.converters import to_native, to_bytes
class ParseError(Exception):
pass
ESCAPE_SEQUENCES = {
b'"': b'"',
b'\\': b'\\',
b'?': b'?',
b'$': b'$',
b'_': b' ',
b'a': b'\a',
b'b': b'\b',
b'f': b'\xFF',
b'n': b'\n',
b'r': b'\r',
b't': b'\t',
b'v': b'\v',
}
ESCAPE_SEQUENCE_REVERSED = dict([(v, k) for k, v in ESCAPE_SEQUENCES.items()])
ESCAPE_DIGITS = b'0123456789ABCDEF'
if sys.version_info[0] < 3:
_int_to_byte = chr
else:
def _int_to_byte(value):
return bytes((value, ))
def parse_argument_value(line, start_index=0, must_match_everything=True):
'''
Parse an argument value (quoted or not quoted) from ``line``.
Will start at offset ``start_index``. Returns pair ``(parsed_value,
end_index)``, where ``end_index`` is the first character after the
attribute.
If ``must_match_everything`` is ``True`` (default), will fail if
``end_index < len(line)``.
'''
line = to_bytes(line)
length = len(line)
index = start_index
if index == length:
raise ParseError('Expected value, but found end of string')
quoted = False
if line[index:index + 1] == b'"':
quoted = True
index += 1
current = []
while index < length:
ch = line[index:index + 1]
index += 1
if not quoted and ch == b' ':
index -= 1
break
elif ch == b'"':
if quoted:
quoted = False
if line[index:index + 1] not in (b'', b' '):
raise ParseError('Ending \'"\' must be followed by space or end of string')
break
raise ParseError('\'"\' must not appear in an unquoted value')
elif ch == b'\\':
if not quoted:
raise ParseError('Escape sequences can only be used inside double quotes')
if index == length:
raise ParseError('\'\\\' must not be at the end of the line')
ch = line[index:index + 1]
index += 1
if ch in ESCAPE_SEQUENCES:
current.append(ESCAPE_SEQUENCES[ch])
else:
d1 = ESCAPE_DIGITS.find(ch)
if d1 < 0:
raise ParseError('Invalid escape sequence \'\\{0}\''.format(to_native(ch)))
if index == length:
raise ParseError('Hex escape sequence cut off at end of line')
ch2 = line[index:index + 1]
d2 = ESCAPE_DIGITS.find(ch2)
index += 1
if d2 < 0:
raise ParseError('Invalid hex escape sequence \'\\{0}\''.format(to_native(ch + ch2)))
current.append(_int_to_byte(d1 * 16 + d2))
else:
if not quoted and ch in (b"'", b'=', b'(', b')', b'$', b'[', b'{', b'`'):
raise ParseError('"{0}" can only be used inside double quotes'.format(to_native(ch)))
if ch == b'?':
raise ParseError('"{0}" can only be used in escaped form'.format(to_native(ch)))
current.append(ch)
if quoted:
raise ParseError('Unexpected end of string during escaped parameter')
if must_match_everything and index < length:
raise ParseError('Unexpected data at end of value')
return to_native(b''.join(current)), index
def split_routeros_command(line):
line = to_bytes(line)
result = []
current = []
index = 0
length = len(line)
parsing_attribute_name = False
while index < length:
ch = line[index:index + 1]
index += 1
if ch == b' ':
if parsing_attribute_name:
parsing_attribute_name = False
result.append(b''.join(current))
current = []
elif ch == b'=' and parsing_attribute_name:
current.append(ch)
value, index = parse_argument_value(line, start_index=index, must_match_everything=False)
current.append(to_bytes(value))
parsing_attribute_name = False
result.append(b''.join(current))
current = []
elif ch in (b'"', b'\\', b"'", b'=', b'(', b')', b'$', b'[', b'{', b'`', b'?'):
raise ParseError('Found unexpected "{0}"'.format(to_native(ch)))
else:
current.append(ch)
parsing_attribute_name = True
if parsing_attribute_name and current:
result.append(b''.join(current))
return [to_native(part) for part in result]
def quote_routeros_argument_value(argument):
argument = to_bytes(argument)
result = []
quote = False
length = len(argument)
index = 0
while index < length:
letter = argument[index:index + 1]
index += 1
if letter in ESCAPE_SEQUENCE_REVERSED:
result.append(b'\\%s' % ESCAPE_SEQUENCE_REVERSED[letter])
quote = True
continue
elif ord(letter) < 32:
v = ord(letter)
v1 = v % 16
v2 = v // 16
result.append(b'\\%s%s' % (ESCAPE_DIGITS[v2:v2 + 1], ESCAPE_DIGITS[v1:v1 + 1]))
quote = True
continue
elif letter in (b' ', b'=', b';', b"'"):
quote = True
result.append(letter)
argument = to_native(b''.join(result))
if quote or not argument:
argument = '"%s"' % argument
return argument
def quote_routeros_argument(argument):
def check_attribute(attribute):
if ' ' in attribute:
raise ParseError('Attribute names must not contain spaces')
return attribute
if '=' not in argument:
check_attribute(argument)
return argument
attribute, value = argument.split('=', 1)
check_attribute(attribute)
value = quote_routeros_argument_value(value)
return '%s=%s' % (attribute, value)
def join_routeros_command(arguments):
return ' '.join([quote_routeros_argument(argument) for argument in arguments])
def convert_list_to_dictionary(string_list, require_assignment=True, skip_empty_values=False):
dictionary = {}
for p in string_list:
if '=' not in p:
if require_assignment:
raise ParseError("missing '=' after '%s'" % p)
dictionary[p] = None
continue
p = p.split('=', 1)
if not skip_empty_values or p[1]:
dictionary[p[0]] = p[1]
return dictionary

View file

@ -1,6 +1,30 @@
# Copyright (c) 2016 Red Hat Inc. # This code is part of Ansible, but is an independent component.
# Simplified BSD License (see LICENSES/BSD-2-Clause.txt or https://opensource.org/licenses/BSD-2-Clause) # This particular file snippet, and this file snippet only, is BSD licensed.
# SPDX-License-Identifier: BSD-2-Clause # Modules you write using this snippet, which is embedded dynamically by Ansible
# still belong to the author of the module, and may assign their own license
# to the complete work.
#
# (c) 2016 Red Hat Inc.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
@ -9,7 +33,6 @@ import json
from ansible.module_utils.common.text.converters import to_native from ansible.module_utils.common.text.converters import to_native
from ansible.module_utils.basic import env_fallback from ansible.module_utils.basic import env_fallback
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list, ComplexList from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import to_list, ComplexList
from ansible_collections.community.routeros.plugins.module_utils.version import LooseVersion
from ansible.module_utils.connection import Connection, ConnectionError from ansible.module_utils.connection import Connection, ConnectionError
_DEVICE_CONFIGS = {} _DEVICE_CONFIGS = {}
@ -104,16 +127,6 @@ def to_commands(module, commands):
return transform(commands) return transform(commands)
def should_add_leading_space(module):
"""Determines whether adding a leading space to the command is needed
to workaround prompt bug in 6.49 <= ROS < 7.2"""
capabilities = get_capabilities(module)
network_os_version = capabilities.get('device_info', {}).get('network_os_version')
if network_os_version is None:
return False
return LooseVersion('6.49') <= LooseVersion(network_os_version) < LooseVersion('7.2')
def run_commands(module, commands, check_rc=True): def run_commands(module, commands, check_rc=True):
responses = list() responses = list()
connection = get_connection(module) connection = get_connection(module)
@ -128,9 +141,6 @@ def run_commands(module, commands, check_rc=True):
prompt = None prompt = None
answer = None answer = None
if should_add_leading_space(module):
command = " " + command
try: try:
out = connection.get(command, prompt, answer) out = connection.get(command, prompt, answer)
except ConnectionError as exc: except ConnectionError as exc:

View file

@ -1,13 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Felix Fontein <felix@fontein.de>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
"""Provide version object to compare version numbers."""
from __future__ import absolute_import, division, print_function
__metaclass__ = type
from ansible.module_utils.compat.version import LooseVersion # pylint: disable=unused-import

View file

@ -1,347 +1,318 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (c) 2020, Nikolay Dachev <nikolay@dachev.info> # Copyright: (c) 2020, Nikolay Dachev <nikolay@dachev.info>
# GNU General Public License v3.0+ https://www.gnu.org/licenses/gpl-3.0.txt # GNU General Public License v3.0+ https://www.gnu.org/licenses/gpl-3.0.txt
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r""" DOCUMENTATION = '''
---
module: api module: api
author: "Nikolay Dachev (@NikolayDachev)" author: "Nikolay Dachev (@NikolayDachev)"
short_description: Ansible module for RouterOS API short_description: Ansible module for RouterOS API
description: description:
- Ansible module for RouterOS API with the Python C(librouteros) library. - Ansible module for RouterOS API with python librouteros.
- This module can add, remove, update, query, and execute arbitrary command in RouterOS through the API. - This module can add, remove, update, query and execute arbitrary command in routeros via API.
notes: notes:
- O(add), O(remove), O(update), O(cmd), and O(query) are mutually exclusive. - I(add), I(remove), I(update), I(cmd) and I(query) are mutually exclusive.
- Use the M(community.routeros.api_modify) and M(community.routeros.api_find_and_modify) modules for more specific modifications, - I(check_mode) is not supported.
and the M(community.routeros.api_info) module for a more controlled way of returning all entries for a path. requirements:
extends_documentation_fragment: - librouteros
- community.routeros.api - Python >= 3.6 (for librouteros)
- community.routeros.attributes
- community.routeros.attributes.actiongroup_api
attributes:
check_mode:
support: none
diff_mode:
support: none
platform:
support: full
platforms: RouterOS
action_group:
version_added: 2.1.0
idempotent:
support: N/A
details:
- Whether the executed command is idempotent depends on the operation performed.
options: options:
hostname:
description:
- RouterOS hostname API.
required: true
type: str
username:
description:
- RouterOS login user.
required: true
type: str
password:
description:
- RouterOS user password.
required: true
type: str
tls:
description:
- If is set TLS will be used for RouterOS API connection.
required: false
type: bool
default: false
aliases:
- ssl
port:
description:
- RouterOS api port. If I(tls) is set, port will apply to TLS/SSL connection.
- Defaults are C(8728) for the HTTP API, and C(8729) for the HTTPS API.
type: int
path: path:
description: description:
- Main path for all other arguments. - Main path for all other arguments.
- If other arguments are not set, the module will return all items in selected path. - If other arguments are not set, api will return all items in selected path.
- Example V(ip address). Equivalent of RouterOS CLI C(/ip address print). - Example C(ip address). Equivalent of RouterOS CLI C(/ip address print).
required: true required: true
type: str type: str
add: add:
description: description:
- Will add selected arguments in selected path to RouterOS config. - Will add selected arguments in selected path to RouterOS config.
- Example V(address=1.1.1.1/32 interface=ether1). - Example C(address=1.1.1.1/32 interface=ether1).
- Equivalent in RouterOS CLI C(/ip address add address=1.1.1.1/32 interface=ether1). - Equivalent in RouterOS CLI C(/ip address add address=1.1.1.1/32 interface=ether1).
type: str type: str
remove: remove:
description: description:
- Remove config/value from RouterOS by '.id'. - Remove config/value from RouterOS by '.id'.
- Example V(*03) will remove config/value with C(id=*03) in selected path. - Example C(*03) will remove config/value with C(id=*03) in selected path.
- Equivalent in RouterOS CLI C(/ip address remove numbers=1). - Equivalent in RouterOS CLI C(/ip address remove numbers=1).
- Note C(number) in RouterOS CLI is different from C(.id). - Note C(number) in RouterOS CLI is different from C(.id).
type: str type: str
update: update:
description: description:
- Update config/value in RouterOS by '.id' in selected path. - Update config/value in RouterOS by '.id' in selected path.
- Example V(.id=*03 address=1.1.1.3/32) and path V(ip address) will replace the existing IP address with C(.id=*03). - Example C(.id=*03 address=1.1.1.3/32) and path C(ip address) will replace existing ip address with C(.id=*03).
- Equivalent in RouterOS CLI C(/ip address set address=1.1.1.3/32 numbers=1). - Equivalent in RouterOS CLI C(/ip address set address=1.1.1.3/32 numbers=1).
- Note C(number) in RouterOS CLI is different from C(.id). - Note C(number) in RouterOS CLI is different from C(.id).
type: str type: str
query: query:
description: description:
- Query given path for selected query attributes from RouterOS API. - Query given path for selected query attributes from RouterOS aip and return '.id'.
- WHERE is key word which extend query. WHERE format is key operator value - with spaces. - WHERE is key word which extend query. WHERE format is key operator value - with spaces.
- WHERE valid operators are V(==) or V(eq), V(!=) or V(not), V(>) or V(more), V(<) or V(less). - WHERE valid operators are C(==), C(!=), C(>), C(<).
- Example path V(ip address) and query V(.id address) will return only C(.id) and C(address) for all items in V(ip address) - Example path C(ip address) and query C(.id address) will return only C(.id) and C(address) for all items in C(ip address) path.
path. - Example path C(ip address) and query C(.id address WHERE address == 1.1.1.3/32).
- Example path V(ip address) and query V(.id address WHERE address == 1.1.1.3/32). will return only C(.id) and C(address) will return only C(.id) and C(address) for items in C(ip address) path, where address is eq to 1.1.1.3/32.
for items in V(ip address) path, where address is eq to 1.1.1.3/32. - Example path C(interface) and query C(mtu name WHERE mut > 1400) will
- Example path V(interface) and query V(mtu name WHERE mut > 1400) will return only interfaces C(mtu,name) where mtu return only interfaces C(mtu,name) where mtu is bigger than 1400.
is bigger than 1400.
- Equivalent in RouterOS CLI C(/interface print where mtu > 1400). - Equivalent in RouterOS CLI C(/interface print where mtu > 1400).
type: str type: str
extended_query:
description:
- Extended query given path for selected query attributes from RouterOS API.
- Extended query allow conjunctive input. If there is no matching entry, an empty list will be returned.
type: dict
suboptions:
attributes:
description:
- The list of attributes to return.
- Every attribute used in a O(extended_query.where[]) clause need to be listed here.
type: list
elements: str
required: true
where:
description:
- Allows to restrict the objects returned.
- The conditions here must all match. An O(extended_query.where[].or) condition needs at least one of its conditions
to match.
type: list
elements: dict
suboptions:
attribute:
description:
- The attribute to match. Must be part of O(extended_query.attributes).
- Either O(extended_query.where[].or) or all of O(extended_query.where[].attribute), O(extended_query.where[].is),
and O(extended_query.where[].value) have to be specified.
type: str
is:
description:
- The operator to use for matching.
- For equality use V(==) or V(eq). For less use V(<) or V(less). For more use V(>) or V(more).
- Use V(in) to check whether the value is part of a list. In that case, O(extended_query.where[].value) must
be a list.
- Either O(extended_query.where[].or) or all of O(extended_query.where[].attribute), O(extended_query.where[].is),
and O(extended_query.where[].value) have to be specified.
type: str
choices: ["==", "!=", ">", "<", "in", "eq", "not", "more", "less"]
value:
description:
- The value to compare to. Must be a list for O(extended_query.where[].is=in).
- Either O(extended_query.where[].or) or all of O(extended_query.where[].attribute), O(extended_query.where[].is),
and O(extended_query.where[].value) have to be specified.
type: raw
or:
description:
- A list of conditions so that at least one of them has to match.
- Either O(extended_query.where[].or) or all of O(extended_query.where[].attribute), O(extended_query.where[].is),
and O(extended_query.where[].value) have to be specified.
type: list
elements: dict
suboptions:
attribute:
description:
- The attribute to match. Must be part of O(extended_query.attributes).
type: str
required: true
is:
description:
- The operator to use for matching.
- For equality use V(==) or V(eq). For less use V(<) or V(less). For more use V(>) or V(more).
- Use V(in) to check whether the value is part of a list. In that case, O(extended_query.where[].or[].value)
must be a list.
type: str
choices: ["==", "!=", ">", "<", "in", "eq", "not", "more", "less"]
required: true
value:
description:
- The value to compare to. Must be a list for O(extended_query.where[].or[].is=in).
type: raw
required: true
cmd: cmd:
description: description:
- Execute any/arbitrary command in selected path, after the command we can add C(.id). - Execute any/arbitrary command in selected path, after the command we can add C(.id).
- Example path V(system script) and cmd V(run .id=*03) is equivalent in RouterOS CLI C(/system script run number=0). - Example path C(system script) and cmd C(run .id=*03) is equivalent in RouterOS CLI C(/system script run number=0).
- Example path V(ip address) and cmd V(print) is equivalent in RouterOS CLI C(/ip address print). - Example path C(ip address) and cmd C(print) is equivalent in RouterOS CLI C(/ip address print).
type: str type: str
seealso: validate_certs:
- ref: ansible_collections.community.routeros.docsite.quoting description:
description: How to quote and unquote commands and arguments. - Set to C(false) to skip validation of TLS certificates.
- module: community.routeros.api_facts - See also I(validate_cert_hostname). Only used when I(tls=true).
- module: community.routeros.api_find_and_modify - B(Note:) instead of simply deactivating certificate validations to "make things work",
- module: community.routeros.api_info please consider creating your own CA certificate and using it to sign certificates used
- module: community.routeros.api_modify for your router. You can tell the module about your CA certificate with the I(ca_path)
""" option.
type: bool
default: true
version_added: 1.2.0
validate_cert_hostname:
description:
- Set to C(true) to validate hostnames in certificates.
- See also I(validate_certs). Only used when I(tls=true) and I(validate_certs=true).
type: bool
default: false
version_added: 1.2.0
ca_path:
description:
- PEM formatted file that contains a CA certificate to be used for certificate validation.
- See also I(validate_cert_hostname). Only used when I(tls=true) and I(validate_certs=true).
type: path
version_added: 1.2.0
'''
EXAMPLES = r""" EXAMPLES = '''
--- ---
- name: Get example - ip address print - name: Use RouterOS API
community.routeros.api: hosts: localhost
hostname: "{{ hostname }}" gather_facts: no
password: "{{ password }}" vars:
username: "{{ username }}" hostname: "ros_api_hostname/ip"
username: "admin"
password: "secret_password"
path: "ip address" path: "ip address"
register: ipaddrd_printout
- name: Dump "Get example" output nic: "ether2"
ansible.builtin.debug: ip1: "1.1.1.1/32"
msg: '{{ ipaddrd_printout }}' ip2: "2.2.2.2/32"
ip3: "3.3.3.3/32"
- name: Add example - ip address tasks:
community.routeros.api: - name: Get "{{ path }} print"
hostname: "{{ hostname }}" community.routeros.api:
password: "{{ password }}" hostname: "{{ hostname }}"
username: "{{ username }}" password: "{{ password }}"
path: "ip address" username: "{{ username }}"
add: "address=192.168.255.10/24 interface=ether2" path: "{{ path }}"
register: print_path
- name: Query example - ".id, address" in "ip address WHERE address == 192.168.255.10/24" - name: Dump "{{ path }} print" output
community.routeros.api: ansible.builtin.debug:
hostname: "{{ hostname }}" msg: '{{ print_path }}'
password: "{{ password }}"
username: "{{ username }}"
path: "ip address"
query: ".id address WHERE address == {{ ip2 }}"
register: queryout
- name: Dump "Query example" output - name: Add ip address "{{ ip1 }}" and "{{ ip2 }}"
ansible.builtin.debug: community.routeros.api:
msg: '{{ queryout }}' hostname: "{{ hostname }}"
password: "{{ password }}"
username: "{{ username }}"
path: "{{ path }}"
add: "{{ item }}"
loop:
- "address={{ ip1 }} interface={{ nic }}"
- "address={{ ip2 }} interface={{ nic }}"
register: addout
- name: Extended query example - ".id,address,network" where address is not 192.168.255.10/24 or is 10.20.36.20/24 - name: Dump "Add ip address" output - ".id" for new added items
community.routeros.api: ansible.builtin.debug:
hostname: "{{ hostname }}" msg: '{{ addout }}'
password: "{{ password }}"
username: "{{ username }}"
path: "ip address"
extended_query:
attributes:
- network
- address
- .id
where:
- attribute: "network"
is: "=="
value: "192.168.255.0"
- or:
- attribute: "address"
is: "!="
value: "192.168.255.10/24"
- attribute: "address"
is: "eq"
value: "10.20.36.20/24"
- attribute: "network"
is: "in"
value:
- "10.20.36.0"
- "192.168.255.0"
register: extended_queryout
- name: Dump "Extended query example" output - name: Query for ".id" in "{{ path }} WHERE address == {{ ip2 }}"
ansible.builtin.debug: community.routeros.api:
msg: '{{ extended_queryout }}' hostname: "{{ hostname }}"
password: "{{ password }}"
username: "{{ username }}"
path: "{{ path }}"
query: ".id address WHERE address == {{ ip2 }}"
register: queryout
- name: Update example - ether2 ip address with ".id = *14" - name: Dump "Query for" output and set fact with ".id" for "{{ ip2 }}"
community.routeros.api: ansible.builtin.debug:
hostname: "{{ hostname }}" msg: '{{ queryout }}'
password: "{{ password }}"
username: "{{ username }}"
path: "ip address"
update: >-
.id=*14
address=192.168.255.20/24
comment={{ 'Update 192.168.255.10/24 to 192.168.255.20/24 on ether2' | community.routeros.quote_argument_value }}
- name: Remove example - ether2 ip 192.168.255.20/24 with ".id = *14" - name: Store query_id for later usage
community.routeros.api: ansible.builtin.set_fact:
hostname: "{{ hostname }}" query_id: "{{ queryout['msg'][0]['.id'] }}"
password: "{{ password }}"
username: "{{ username }}"
path: "ip address"
remove: "*14"
- name: Arbitrary command example "/system identity print" - name: Update ".id = {{ query_id }}" taken with custom fact "fquery_id"
community.routeros.api: community.routeros.api:
hostname: "{{ hostname }}" hostname: "{{ hostname }}"
password: "{{ password }}" password: "{{ password }}"
username: "{{ username }}" username: "{{ username }}"
path: "system identity" path: "{{ path }}"
cmd: "print" update: ".id={{ query_id }} address={{ ip3 }}"
register: arbitraryout register: updateout
- name: Dump "Arbitrary command example" output - name: Dump "Update" output
ansible.builtin.debug: ansible.builtin.debug:
msg: '{{ arbitraryout }}' msg: '{{ updateout }}'
"""
RETURN = r""" - name: Remove ips - stage 1 - query ".id" for "{{ ip2 }}" and "{{ ip3 }}"
community.routeros.api:
hostname: "{{ hostname }}"
password: "{{ password }}"
username: "{{ username }}"
path: "{{ path }}"
query: ".id address WHERE address == {{ item }}"
register: id_to_remove
loop:
- "{{ ip2 }}"
- "{{ ip3 }}"
- name: Set fact for ".id" from "Remove ips - stage 1 - query"
ansible.builtin.set_fact:
to_be_remove: "{{ to_be_remove |default([]) + [item['msg'][0]['.id']] }}"
loop: "{{ id_to_remove.results }}"
- name: Dump "Remove ips - stage 1 - query" output
ansible.builtin.debug:
msg: '{{ to_be_remove }}'
# Remove "{{ rmips }}" with ".id" by "to_be_remove" from query
- name: Remove ips - stage 2 - remove "{{ ip2 }}" and "{{ ip3 }}" by '.id'
community.routeros.api:
hostname: "{{ hostname }}"
password: "{{ password }}"
username: "{{ username }}"
path: "{{ path }}"
remove: "{{ item }}"
register: remove
loop: "{{ to_be_remove }}"
- name: Dump "Remove ips - stage 2 - remove" output
ansible.builtin.debug:
msg: '{{ remove }}'
- name: Arbitrary command example "/system identity print"
community.routeros.api:
hostname: "{{ hostname }}"
password: "{{ password }}"
username: "{{ username }}"
path: "system identity"
cmd: "print"
register: cmdout
- name: Dump "Arbitrary command example" output
ansible.builtin.debug:
msg: "{{ cmdout }}"
'''
RETURN = '''
---
message: message:
description: All outputs are in list with dictionary elements returned from RouterOS API. description: All outputs are in list with dictionary elements returned from RouterOS api.
sample: sample: C([{...},{...}])
- address: 1.2.3.4 type: list
- address: 2.3.4.5 returned: always
type: list '''
returned: always
"""
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import missing_required_lib
from ansible.module_utils.common.text.converters import to_native from ansible.module_utils.common.text.converters import to_native
from ansible_collections.community.routeros.plugins.module_utils.quoting import ( import ssl
ParseError, import traceback
convert_list_to_dictionary,
parse_argument_value,
split_routeros_command,
)
from ansible_collections.community.routeros.plugins.module_utils.api import (
api_argument_spec,
check_has_library,
create_api,
)
import re
LIB_IMP_ERR = None
try: try:
from librouteros import connect
from librouteros.exceptions import LibRouterosError from librouteros.exceptions import LibRouterosError
from librouteros.query import Key, Or from librouteros.query import Key
except Exception: HAS_LIB = True
# Handled in api module_utils except Exception as e:
pass HAS_LIB = False
LIB_IMP_ERR = traceback.format_exc()
class ROS_api_module: class ROS_api_module:
def __init__(self): def __init__(self):
module_args = dict( module_args = dict(
username=dict(type='str', required=True),
password=dict(type='str', required=True, no_log=True),
hostname=dict(type='str', required=True),
port=dict(type='int'),
tls=dict(type='bool', default=False, aliases=['ssl']),
path=dict(type='str', required=True), path=dict(type='str', required=True),
add=dict(type='str'), add=dict(type='str'),
remove=dict(type='str'), remove=dict(type='str'),
update=dict(type='str'), update=dict(type='str'),
cmd=dict(type='str'), cmd=dict(type='str'),
query=dict(type='str'), query=dict(type='str'),
extended_query=dict(type='dict', options=dict( validate_certs=dict(type='bool', default=True),
attributes=dict(type='list', elements='str', required=True), validate_cert_hostname=dict(type='bool', default=False),
where=dict( ca_path=dict(type='path'),
type='list',
elements='dict',
options={
'attribute': dict(type='str'),
'is': dict(type='str', choices=["==", "!=", ">", "<", "in", "eq", "not", "more", "less"]),
'value': dict(type='raw'),
'or': dict(type='list', elements='dict', options={
'attribute': dict(type='str', required=True),
'is': dict(type='str', choices=["==", "!=", ">", "<", "in", "eq", "not", "more", "less"], required=True),
'value': dict(type='raw', required=True),
}),
},
required_together=[('attribute', 'is', 'value')],
mutually_exclusive=[('attribute', 'or')],
required_one_of=[('attribute', 'or')],
),
)),
) )
module_args.update(api_argument_spec())
self.module = AnsibleModule(argument_spec=module_args, self.module = AnsibleModule(argument_spec=module_args,
supports_check_mode=False, supports_check_mode=False,
mutually_exclusive=(('add', 'remove', 'update', mutually_exclusive=(('add', 'remove', 'update',
'cmd', 'query', 'extended_query'),),) 'cmd', 'query'),),)
check_has_library(self.module) if not HAS_LIB:
self.module.fail_json(msg=missing_required_lib("librouteros"),
exception=LIB_IMP_ERR)
self.api = create_api(self.module) self.api = self.ros_api_connect(self.module.params['username'],
self.module.params['password'],
self.module.params['hostname'],
self.module.params['port'],
self.module.params['tls'],
self.module.params['validate_certs'],
self.module.params['validate_cert_hostname'],
self.module.params['ca_path'],
)
self.path = self.module.params['path'].split() self.path = self.list_remove_empty(self.module.params['path'].split(' '))
self.add = self.module.params['add'] self.add = self.module.params['add']
self.remove = self.module.params['remove'] self.remove = self.module.params['remove']
self.update = self.module.params['update'] self.update = self.module.params['update']
@ -349,7 +320,13 @@ class ROS_api_module:
self.where = None self.where = None
self.query = self.module.params['query'] self.query = self.module.params['query']
self.extended_query = self.module.params['extended_query'] if self.query:
if 'WHERE' in self.query:
split = self.query.split('WHERE')
self.query = self.list_remove_empty(split[0].split(' '))
self.where = self.list_remove_empty(split[1].split(' '))
else:
self.query = self.list_remove_empty(self.module.params['query'].split(' '))
self.result = dict( self.result = dict(
message=[]) message=[])
@ -357,79 +334,34 @@ class ROS_api_module:
# create api base path # create api base path
self.api_path = self.api_add_path(self.api, self.path) self.api_path = self.api_add_path(self.api, self.path)
# api calls # api call's
try: if self.add:
if self.add: self.api_add()
self.api_add() elif self.remove:
elif self.remove: self.api_remove()
self.api_remove() elif self.update:
elif self.update: self.api_update()
self.api_update() elif self.query:
elif self.query: self.api_query()
self.check_query() elif self.arbitrary:
self.api_query() self.api_arbitrary()
elif self.extended_query:
self.check_extended_query()
self.api_extended_query()
elif self.arbitrary:
self.api_arbitrary()
else:
self.api_get_all()
except UnicodeEncodeError as exc:
self.module.fail_json(msg='Error while encoding text: {error}'.format(error=exc))
def check_query(self):
where_index = self.query.find(' WHERE ')
if where_index < 0:
self.query = self.split_params(self.query)
else: else:
where = self.query[where_index + len(' WHERE '):] self.api_get_all()
self.query = self.split_params(self.query[:where_index])
# where must be of the format '<attribute> <operator> <value>'
m = re.match(r'^\s*([^ ]+)\s+([^ ]+)\s+(.*)$', where)
if not m:
self.errors("invalid syntax for 'WHERE %s'" % where)
try:
self.where = [
m.group(1), # attribute
m.group(2), # operator
parse_argument_value(m.group(3).rstrip())[0], # value
]
except ParseError as exc:
self.errors("invalid syntax for 'WHERE %s': %s" % (where, exc))
try:
idx = self.query.index('WHERE')
self.where = self.query[idx + 1:]
self.query = self.query[:idx]
except ValueError:
# Raised when WHERE has not been found
pass
def check_extended_query_syntax(self, test_atr, or_msg=''): def list_remove_empty(self, check_list):
if test_atr['is'] == "in" and not isinstance(test_atr['value'], list): while("" in check_list):
self.errors("invalid syntax 'extended_query':'where':%s%s 'value' must be a type list" % (or_msg, test_atr)) check_list.remove("")
return check_list
def check_extended_query(self):
if self.extended_query["where"]:
for i in self.extended_query['where']:
if i["or"] is not None:
if len(i['or']) < 2:
self.errors("invalid syntax 'extended_query':'where':'or':%s 'or' requires minimum two items" % i["or"])
for orv in i['or']:
self.check_extended_query_syntax(orv, ":'or':")
else:
self.check_extended_query_syntax(i)
def list_to_dic(self, ldict): def list_to_dic(self, ldict):
return convert_list_to_dictionary(ldict, skip_empty_values=True, require_assignment=True) dict = {}
for p in ldict:
def split_params(self, params): if '=' not in p:
if not isinstance(params, str): self.errors("missing '=' after '%s'" % p)
raise AssertionError('Parameters can only be a string, received %s' % type(params)) p = p.split('=')
try: if p[1]:
return split_routeros_command(params) dict[p[0]] = p[1]
except ParseError as e: return dict
self.module.fail_json(msg=to_native(e))
def api_add_path(self, api, path): def api_add_path(self, api, path):
api_path = api.path() api_path = api.path()
@ -446,7 +378,7 @@ class ROS_api_module:
self.errors(e) self.errors(e)
def api_add(self): def api_add(self):
param = self.list_to_dic(self.split_params(self.add)) param = self.list_to_dic(self.add.split(' '))
try: try:
self.result['message'].append("added: .id= %s" self.result['message'].append("added: .id= %s"
% self.api_path.add(**param)) % self.api_path.add(**param))
@ -463,7 +395,7 @@ class ROS_api_module:
self.errors(e) self.errors(e)
def api_update(self): def api_update(self):
param = self.list_to_dic(self.split_params(self.update)) param = self.list_to_dic(self.update.split(' '))
if '.id' not in param.keys(): if '.id' not in param.keys():
self.errors("missing '.id' for %s" % param) self.errors("missing '.id' for %s" % param)
try: try:
@ -481,21 +413,27 @@ class ROS_api_module:
keys[k] = Key(k) keys[k] = Key(k)
try: try:
if self.where: if self.where:
if self.where[1] in ('==', 'eq'): if len(self.where) < 3:
self.errors("invalid syntax for 'WHERE %s'"
% ' '.join(self.where))
where = []
if self.where[1] == '==':
select = self.api_path.select(*keys).where(keys[self.where[0]] == self.where[2]) select = self.api_path.select(*keys).where(keys[self.where[0]] == self.where[2])
elif self.where[1] in ('!=', 'not'): elif self.where[1] == '!=':
select = self.api_path.select(*keys).where(keys[self.where[0]] != self.where[2]) select = self.api_path.select(*keys).where(keys[self.where[0]] != self.where[2])
elif self.where[1] in ('>', 'more'): elif self.where[1] == '>':
select = self.api_path.select(*keys).where(keys[self.where[0]] > self.where[2]) select = self.api_path.select(*keys).where(keys[self.where[0]] > self.where[2])
elif self.where[1] in ('<', 'less'): elif self.where[1] == '<':
select = self.api_path.select(*keys).where(keys[self.where[0]] < self.where[2]) select = self.api_path.select(*keys).where(keys[self.where[0]] < self.where[2])
else: else:
self.errors("'%s' is not operator for 'where'" self.errors("'%s' is not operator for 'where'"
% self.where[1]) % self.where[1])
for row in select:
self.result['message'].append(row)
else: else:
select = self.api_path.select(*keys) for row in self.api_path.select(*keys):
for row in select: self.result['message'].append(row)
self.result['message'].append(row)
if len(self.result['message']) < 1: if len(self.result['message']) < 1:
msg = "no results for '%s 'query' %s" % (' '.join(self.path), msg = "no results for '%s 'query' %s" % (' '.join(self.path),
' '.join(self.query)) ' '.join(self.query))
@ -506,52 +444,9 @@ class ROS_api_module:
except LibRouterosError as e: except LibRouterosError as e:
self.errors(e) self.errors(e)
def build_api_extended_query(self, item):
if item['attribute'] not in self.extended_query['attributes']:
self.errors("'%s' attribute is not in attributes: %s"
% (item, self.extended_query['attributes']))
if item['is'] in ('eq', '=='):
return self.query_keys[item['attribute']] == item['value']
elif item['is'] in ('not', '!='):
return self.query_keys[item['attribute']] != item['value']
elif item['is'] in ('less', '<'):
return self.query_keys[item['attribute']] < item['value']
elif item['is'] in ('more', '>'):
return self.query_keys[item['attribute']] > item['value']
elif item['is'] == 'in':
return self.query_keys[item['attribute']].In(*item['value'])
else:
self.errors("'%s' is not operator for 'is'" % item['is'])
def api_extended_query(self):
self.query_keys = {}
for k in self.extended_query['attributes']:
if k == 'id':
self.errors("'extended_query':'attributes':'%s' must be '.id'" % k)
self.query_keys[k] = Key(k)
try:
if self.extended_query['where']:
where_args = []
for i in self.extended_query['where']:
if i['or']:
where_or_args = []
for ior in i['or']:
where_or_args.append(self.build_api_extended_query(ior))
where_args.append(Or(*where_or_args))
else:
where_args.append(self.build_api_extended_query(i))
select = self.api_path.select(*self.query_keys).where(*where_args)
else:
select = self.api_path.select(*self.extended_query['attributes'])
for row in select:
self.result['message'].append(row)
self.return_result(False)
except LibRouterosError as e:
self.errors(e)
def api_arbitrary(self): def api_arbitrary(self):
param = {} param = {}
self.arbitrary = self.split_params(self.arbitrary) self.arbitrary = self.arbitrary.split(' ')
arb_cmd = self.arbitrary[0] arb_cmd = self.arbitrary[0]
if len(self.arbitrary) > 1: if len(self.arbitrary) > 1:
param = self.list_to_dic(self.arbitrary[1:]) param = self.list_to_dic(self.arbitrary[1:])
@ -577,6 +472,49 @@ class ROS_api_module:
self.result['message'].append("%s" % e) self.result['message'].append("%s" % e)
self.return_result(False, False) self.return_result(False, False)
def ros_api_connect(self, username, password, host, port, use_tls, validate_certs, validate_cert_hostname, ca_path):
# connect to routeros api
conn_status = {"connection": {"username": username,
"hostname": host,
"port": port,
"ssl": use_tls,
"status": "Connected"}}
try:
if use_tls:
if not port:
port = 8729
conn_status["connection"]["port"] = port
ctx = ssl.create_default_context(cafile=ca_path)
wrap_context = ctx.wrap_socket
if not validate_certs:
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
elif not validate_cert_hostname:
ctx.check_hostname = False
else:
# Since librouteros doesn't pass server_hostname,
# we have to do this ourselves:
def wrap_context(*args, **kwargs):
kwargs.pop('server_hostname', None)
return ctx.wrap_socket(*args, server_hostname=host, **kwargs)
api = connect(username=username,
password=password,
host=host,
ssl_wrapper=wrap_context,
port=port)
else:
if not port:
port = 8728
conn_status["connection"]["port"] = port
api = connect(username=username,
password=password,
host=host,
port=port)
except Exception as e:
conn_status["connection"]["status"] = "error: %s" % e
self.module.fail_json(msg=to_native([conn_status]))
return api
def main(): def main():

View file

@ -1,492 +0,0 @@
#!/usr/bin/python
# Copyright (c) 2022, Felix Fontein <felix@fontein.de>
# Copyright (c) 2020, Nikolay Dachev <nikolay@dachev.info>
# Copyright (c) 2018, Egor Zaitsev (@heuels)
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = r"""
module: api_facts
author:
- "Egor Zaitsev (@heuels)"
- "Nikolay Dachev (@NikolayDachev)"
- "Felix Fontein (@felixfontein)"
version_added: 2.1.0
short_description: Collect facts from remote devices running MikroTik RouterOS using the API
description:
- Collects a base set of device facts from a remote device that is running RouterOS. This module prepends all of the base
network fact keys with C(ansible_net_<fact>). The facts module will always collect a base set of facts from the device
and can enable or disable collection of additional facts.
- As opposed to the M(community.routeros.facts) module, it uses the RouterOS API, similar to the M(community.routeros.api)
module.
extends_documentation_fragment:
- community.routeros.api
- community.routeros.attributes
- community.routeros.attributes.actiongroup_api
- community.routeros.attributes.facts
- community.routeros.attributes.facts_module
- community.routeros.attributes.idempotent_not_modify_state
attributes:
platform:
support: full
platforms: RouterOS
options:
gather_subset:
description:
- When supplied, this argument will restrict the facts collected to a given subset. Possible values for this argument
include V(all), V(hardware), V(interfaces), and V(routing).
- Can specify a list of values to include a larger subset. Values can also be used with an initial V(!) to specify that
a specific subset should not be collected.
required: false
default:
- all
type: list
elements: str
seealso:
- module: community.routeros.facts
- module: community.routeros.api
- module: community.routeros.api_find_and_modify
- module: community.routeros.api_info
- module: community.routeros.api_modify
"""
EXAMPLES = r"""
---
- name: Collect all facts from the device
community.routeros.api_facts:
hostname: 192.168.88.1
username: admin
password: password
gather_subset: all
- name: Do not collect hardware facts
community.routeros.api_facts:
hostname: 192.168.88.1
username: admin
password: password
gather_subset:
- "!hardware"
"""
RETURN = r"""
ansible_facts:
description: "Dictionary of IP geolocation facts for a host's IP address."
returned: always
type: dict
contains:
ansible_net_gather_subset:
description: The list of fact subsets collected from the device.
returned: always
type: list
# default
ansible_net_model:
description: The model name returned from the device.
returned: O(gather_subset) contains V(default)
type: str
ansible_net_serialnum:
description: The serial number of the remote device.
returned: O(gather_subset) contains V(default)
type: str
ansible_net_version:
description: The operating system version running on the remote device.
returned: O(gather_subset) contains V(default)
type: str
ansible_net_hostname:
description: The configured hostname of the device.
returned: O(gather_subset) contains V(default)
type: str
ansible_net_arch:
description: The CPU architecture of the device.
returned: O(gather_subset) contains V(default)
type: str
ansible_net_uptime:
description: The uptime of the device.
returned: O(gather_subset) contains V(default)
type: str
ansible_net_cpu_load:
description: Current CPU load.
returned: O(gather_subset) contains V(default)
type: str
# hardware
ansible_net_spacefree_mb:
description: The available disk space on the remote device in MiB.
returned: O(gather_subset) contains V(hardware)
type: dict
ansible_net_spacetotal_mb:
description: The total disk space on the remote device in MiB.
returned: O(gather_subset) contains V(hardware)
type: dict
ansible_net_memfree_mb:
description: The available free memory on the remote device in MiB.
returned: O(gather_subset) contains V(hardware)
type: int
ansible_net_memtotal_mb:
description: The total memory on the remote device in MiB.
returned: O(gather_subset) contains V(hardware)
type: int
# interfaces
ansible_net_all_ipv4_addresses:
description: All IPv4 addresses configured on the device.
returned: O(gather_subset) contains V(interfaces)
type: list
ansible_net_all_ipv6_addresses:
description: All IPv6 addresses configured on the device.
returned: O(gather_subset) contains V(interfaces)
type: list
ansible_net_interfaces:
description: A hash of all interfaces running on the system.
returned: O(gather_subset) contains V(interfaces)
type: dict
ansible_net_neighbors:
description: The list of neighbors from the remote device.
returned: O(gather_subset) contains V(interfaces)
type: dict
# routing
ansible_net_bgp_peer:
description: A dictionary with BGP peer information.
returned: O(gather_subset) contains V(routing)
type: dict
ansible_net_bgp_vpnv4_route:
description: A dictionary with BGP vpnv4 route information.
returned: O(gather_subset) contains V(routing)
type: dict
ansible_net_bgp_instance:
description: A dictionary with BGP instance information.
returned: O(gather_subset) contains V(routing)
type: dict
ansible_net_route:
description: A dictionary for routes in all routing tables.
returned: O(gather_subset) contains V(routing)
type: dict
ansible_net_ospf_instance:
description: A dictionary with OSPF instances.
returned: O(gather_subset) contains V(routing)
type: dict
ansible_net_ospf_neighbor:
description: A dictionary with OSPF neighbors.
returned: O(gather_subset) contains V(routing)
type: dict
"""
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ansible.module_utils.common.text.converters import to_native
from ansible_collections.community.routeros.plugins.module_utils.api import (
api_argument_spec,
check_has_library,
create_api,
)
try:
from librouteros.exceptions import LibRouterosError
except Exception:
# Handled in api module_utils
pass
class FactsBase(object):
COMMANDS = []
def __init__(self, module, api):
self.module = module
self.api = api
self.facts = {}
self.responses = None
def populate(self):
self.responses = []
for path in self.COMMANDS:
self.responses.append(self.query_path(path))
def query_path(self, path):
api_path = self.api.path()
for part in path:
api_path = api_path.join(part)
try:
return list(api_path)
except LibRouterosError as e:
self.module.warn('Error while querying path {path}: {error}'.format(
path=' '.join(path),
error=to_native(e),
))
return []
class Default(FactsBase):
COMMANDS = [
['system', 'identity'],
['system', 'resource'],
['system', 'routerboard'],
]
def populate(self):
super(Default, self).populate()
data = self.responses[0]
if data:
self.facts['hostname'] = data[0].get('name')
data = self.responses[1]
if data:
self.facts['version'] = data[0].get('version')
self.facts['arch'] = data[0].get('architecture-name')
self.facts['uptime'] = data[0].get('uptime')
self.facts['cpu_load'] = data[0].get('cpu-load')
data = self.responses[2]
if data:
self.facts['model'] = data[0].get('model')
self.facts['serialnum'] = data[0].get('serial-number')
class Hardware(FactsBase):
COMMANDS = [
['system', 'resource'],
]
def populate(self):
super(Hardware, self).populate()
data = self.responses[0]
if data:
self.parse_filesystem_info(data[0])
self.parse_memory_info(data[0])
def parse_filesystem_info(self, data):
self.facts['spacefree_mb'] = self.to_megabytes(data.get('free-hdd-space'))
self.facts['spacetotal_mb'] = self.to_megabytes(data.get('total-hdd-space'))
def parse_memory_info(self, data):
self.facts['memfree_mb'] = self.to_megabytes(data.get('free-memory'))
self.facts['memtotal_mb'] = self.to_megabytes(data.get('total-memory'))
def to_megabytes(self, value):
if value is None:
return None
return float(value) / 1024 / 1024
class Interfaces(FactsBase):
COMMANDS = [
['interface'],
['ip', 'address'],
['ipv6', 'address'],
['ip', 'neighbor'],
]
def populate(self):
super(Interfaces, self).populate()
self.facts['interfaces'] = {}
self.facts['all_ipv4_addresses'] = []
self.facts['all_ipv6_addresses'] = []
self.facts['neighbors'] = []
data = self.responses[0]
if data:
interfaces = self.parse_interfaces(data)
self.populate_interfaces(interfaces)
data = self.responses[1]
if data:
data = self.parse_detail(data)
self.populate_addresses(data, 'ipv4')
data = self.responses[2]
if data:
data = self.parse_detail(data)
self.populate_addresses(data, 'ipv6')
data = self.responses[3]
if data:
self.facts['neighbors'] = list(self.parse_detail(data))
def populate_interfaces(self, data):
for key, value in iteritems(data):
self.facts['interfaces'][key] = value
def populate_addresses(self, data, family):
for value in data:
key = value['interface']
iface = self.facts['interfaces'].setdefault(key, (
{"type": "ansible:unknown"} if key.startswith('*') else
{"type": "ansible:mismatch"}))
iface_addrs = iface.setdefault(family, [])
addr, subnet = value['address'].split('/')
subnet = subnet.strip()
# Try to convert subnet to an integer
try:
subnet = int(subnet)
except Exception:
pass
ip = dict(address=addr.strip(), subnet=subnet)
self.add_ip_address(addr.strip(), family)
iface_addrs.append(ip)
def add_ip_address(self, address, family):
if family == 'ipv4':
self.facts['all_ipv4_addresses'].append(address)
else:
self.facts['all_ipv6_addresses'].append(address)
def parse_interfaces(self, data):
facts = {}
for entry in data:
if 'name' not in entry:
continue
entry.pop('.id', None)
facts[entry['name']] = entry
return facts
def parse_detail(self, data):
for entry in data:
if 'interface' not in entry:
continue
entry.pop('.id', None)
yield entry
class Routing(FactsBase):
COMMANDS = [
['routing', 'bgp', 'peer'],
['routing', 'bgp', 'vpnv4-route'],
['routing', 'bgp', 'instance'],
['ip', 'route'],
['routing', 'ospf', 'instance'],
['routing', 'ospf', 'neighbor'],
]
def populate(self):
super(Routing, self).populate()
self.facts['bgp_peer'] = {}
self.facts['bgp_vpnv4_route'] = {}
self.facts['bgp_instance'] = {}
self.facts['route'] = {}
self.facts['ospf_instance'] = {}
self.facts['ospf_neighbor'] = {}
data = self.responses[0]
if data:
peer = self.parse(data, 'name')
self.populate_result('bgp_peer', peer)
data = self.responses[1]
if data:
vpnv4 = self.parse(data, 'interface')
self.populate_result('bgp_vpnv4_route', vpnv4)
data = self.responses[2]
if data:
instance = self.parse(data, 'name')
self.populate_result('bgp_instance', instance)
data = self.responses[3]
if data:
route = self.parse(data, 'routing-mark', fallback='main')
self.populate_result('route', route)
data = self.responses[4]
if data:
instance = self.parse(data, 'name')
self.populate_result('ospf_instance', instance)
data = self.responses[5]
if data:
instance = self.parse(data, 'instance')
self.populate_result('ospf_neighbor', instance)
def parse(self, data, key, fallback=None):
facts = {}
for line in data:
name = line.get(key) or fallback
line.pop('.id', None)
facts[name] = line
return facts
def populate_result(self, name, data):
for key, value in iteritems(data):
self.facts[name][key] = value
FACT_SUBSETS = dict(
default=Default,
hardware=Hardware,
interfaces=Interfaces,
routing=Routing,
)
VALID_SUBSETS = frozenset(FACT_SUBSETS.keys())
def main():
argument_spec = dict(
gather_subset=dict(
default=['all'],
type='list',
elements='str',
)
)
argument_spec.update(api_argument_spec())
module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
check_has_library(module)
api = create_api(module)
gather_subset = module.params['gather_subset']
runable_subsets = set()
exclude_subsets = set()
for subset in gather_subset:
if subset == 'all':
runable_subsets.update(VALID_SUBSETS)
continue
if subset.startswith('!'):
subset = subset[1:]
if subset == 'all':
exclude_subsets.update(VALID_SUBSETS)
continue
exclude = True
else:
exclude = False
if subset not in VALID_SUBSETS:
module.fail_json(msg='Bad subset: %s' % subset)
if exclude:
exclude_subsets.add(subset)
else:
runable_subsets.add(subset)
if not runable_subsets:
runable_subsets.update(VALID_SUBSETS)
runable_subsets.difference_update(exclude_subsets)
runable_subsets.add('default')
facts = {}
facts['gather_subset'] = sorted(runable_subsets)
instances = []
for key in runable_subsets:
instances.append(FACT_SUBSETS[key](module, api))
for inst in instances:
inst.populate()
facts.update(inst.facts)
ansible_facts = {}
for key, value in iteritems(facts):
key = 'ansible_net_%s' % key
ansible_facts[key] = value
module.exit_json(ansible_facts=ansible_facts)
if __name__ == '__main__':
main()

View file

@ -1,367 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (c) 2022, Felix Fontein <felix@fontein.de>
# GNU General Public License v3.0+ https://www.gnu.org/licenses/gpl-3.0.txt
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = r"""
module: api_find_and_modify
author:
- "Felix Fontein (@felixfontein)"
short_description: Find and modify information using the API
version_added: 2.1.0
description:
- Allows to find entries for a path by conditions and modify the values of these entries.
- Use the M(community.routeros.api_find_and_modify) module to set all entries of a path to specific values, or change multiple
entries in different ways in one step.
notes:
- "If you want to change values based on their old values (like change all comments 'foo' to 'bar') and make sure that there
are at least N such values, you can use O(require_matches_min=N) together with O(allow_no_matches=true). This will make
the module fail if there are less than N such entries, but not if there is no match. The latter case is needed for idempotency
of the task: once the values have been changed, there should be no further match."
extends_documentation_fragment:
- community.routeros.api
- community.routeros.attributes
- community.routeros.attributes.actiongroup_api
attributes:
check_mode:
support: full
diff_mode:
support: full
platform:
support: full
platforms: RouterOS
idempotent:
support: full
options:
path:
description:
- Path to query.
- An example value is V(ip address). This is equivalent to running C(/ip address) in the RouterOS CLI.
required: true
type: str
find:
description:
- Fields to search for.
- The module will only consider entries in the given O(path) that match all fields provided here.
- Use YAML V(~), or prepend keys with V(!), to specify an unset value.
- Note that if the dictionary specified here is empty, every entry in the path will be matched.
required: true
type: dict
values:
description:
- On all entries matching the conditions in O(find), set the keys of this option to the values specified here.
- Use YAML V(~), or prepend keys with V(!), to specify to unset a value.
required: true
type: dict
require_matches_min:
description:
- Make sure that there are no less matches than this number.
- If there are less matches, fail instead of modifying anything.
type: int
default: 0
require_matches_max:
description:
- Make sure that there are no more matches than this number.
- If there are more matches, fail instead of modifying anything.
- If not specified, there is no upper limit.
type: int
allow_no_matches:
description:
- Whether to allow that no match is found.
- If not specified, this value is induced from whether O(require_matches_min) is 0 or larger.
type: bool
ignore_dynamic:
description:
- Whether to ignore dynamic entries.
- By default, they are considered. If set to V(true), they are not considered.
- It is generally recommended to set this to V(true) unless when you really need to modify dynamic entries.
type: bool
default: false
version_added: 3.7.0
ignore_builtin:
description:
- Whether to ignore builtin entries.
- By default, they are considered. If set to V(true), they are not considered.
- It is generally recommended to set this to V(true) unless when you really need to modify builtin entries.
type: bool
default: false
version_added: 3.7.0
seealso:
- module: community.routeros.api
- module: community.routeros.api_facts
- module: community.routeros.api_modify
- module: community.routeros.api_info
"""
EXAMPLES = r"""
---
- name: Rename bridge from 'bridge' to 'my-bridge'
community.routeros.api_find_and_modify:
hostname: "{{ hostname }}"
password: "{{ password }}"
username: "{{ username }}"
path: interface bridge
find:
name: bridge
values:
name: my-bridge
# Always ignore dynamic and builtin entries
# (not relevant for this path, but generally recommended)
ignore_dynamic: true
ignore_builtin: true
- name: Change IP address to 192.168.1.1 for interface bridge - assuming there is only one
community.routeros.api_find_and_modify:
hostname: "{{ hostname }}"
password: "{{ password }}"
username: "{{ username }}"
path: ip address
find:
interface: bridge
values:
address: "192.168.1.1/24"
# If there are zero entries, or more than one: fail! We expected that
# exactly one is configured.
require_matches_min: 1
require_matches_max: 1
# Always ignore dynamic and builtin entries
# (not relevant for this path, but generally recommended)
ignore_dynamic: true
ignore_builtin: true
"""
RETURN = r"""
old_data:
description:
- A list of all elements for the current path before a change was made.
sample:
- '.id': '*1'
actual-interface: bridge
address: "192.168.88.1/24"
comment: defconf
disabled: false
dynamic: false
interface: bridge
invalid: false
network: 192.168.88.0
type: list
elements: dict
returned: success
new_data:
description:
- A list of all elements for the current path after a change was made.
sample:
- '.id': '*1'
actual-interface: bridge
address: "192.168.1.1/24"
comment: awesome
disabled: false
dynamic: false
interface: bridge
invalid: false
network: 192.168.1.0
type: list
elements: dict
returned: success
match_count:
description:
- The number of entries that matched the criteria in O(find).
sample: 1
type: int
returned: success
modify__count:
description:
- The number of entries that were modified.
sample: 1
type: int
returned: success
"""
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.text.converters import to_native
from ansible_collections.community.routeros.plugins.module_utils.api import (
api_argument_spec,
check_has_library,
create_api,
)
from ansible_collections.community.routeros.plugins.module_utils._api_data import (
split_path,
)
try:
from librouteros.exceptions import LibRouterosError
except Exception:
# Handled in api module_utils
pass
def compose_api_path(api, path):
api_path = api.path()
for p in path:
api_path = api_path.join(p)
return api_path
def filter_entries(entries, ignore_dynamic=False, ignore_builtin=False):
result = []
for entry in entries:
if ignore_dynamic and entry.get('dynamic', False):
continue
if ignore_builtin and entry.get('builtin', False):
continue
result.append(entry)
return result
DISABLED_MEANS_EMPTY_STRING = ('comment', )
def main():
module_args = dict(
path=dict(type='str', required=True),
find=dict(type='dict', required=True),
values=dict(type='dict', required=True),
require_matches_min=dict(type='int', default=0),
require_matches_max=dict(type='int'),
allow_no_matches=dict(type='bool'),
ignore_dynamic=dict(type='bool', default=False),
ignore_builtin=dict(type='bool', default=False),
)
module_args.update(api_argument_spec())
module = AnsibleModule(
argument_spec=module_args,
supports_check_mode=True,
)
if module.params['allow_no_matches'] is None:
module.params['allow_no_matches'] = module.params['require_matches_min'] <= 0
find = module.params['find']
for key, value in sorted(find.items()):
if key.startswith('!'):
key = key[1:]
if value not in (None, ''):
module.fail_json(msg='The value for "!{key}" in `find` must not be non-trivial!'.format(key=key))
if key in find:
module.fail_json(msg='`find` must not contain both "{key}" and "!{key}"!'.format(key=key))
values = module.params['values']
for key, value in sorted(values.items()):
if key.startswith('!'):
key = key[1:]
if value not in (None, ''):
module.fail_json(msg='The value for "!{key}" in `values` must not be non-trivial!'.format(key=key))
if key in values:
module.fail_json(msg='`values` must not contain both "{key}" and "!{key}"!'.format(key=key))
ignore_dynamic = module.params['ignore_dynamic']
ignore_builtin = module.params['ignore_builtin']
check_has_library(module)
api = create_api(module)
path = split_path(module.params['path'])
api_path = compose_api_path(api, path)
old_data = filter_entries(list(api_path), ignore_dynamic=ignore_dynamic, ignore_builtin=ignore_builtin)
new_data = [entry.copy() for entry in old_data]
# Find matching entries
matching_entries = []
for index, entry in enumerate(new_data):
matches = True
for key, value in find.items():
if key.startswith('!'):
# Allow to specify keys that should not be present by prepending '!'
key = key[1:]
value = None
current_value = entry.get(key)
if key in DISABLED_MEANS_EMPTY_STRING and value == '' and current_value is None:
current_value = value
if current_value != value:
matches = False
break
if matches:
matching_entries.append((index, entry))
# Check whether the correct amount of entries was found
if matching_entries:
if len(matching_entries) < module.params['require_matches_min']:
module.fail_json(msg='Found %d entries, but expected at least %d' % (len(matching_entries), module.params['require_matches_min']))
if module.params['require_matches_max'] is not None and len(matching_entries) > module.params['require_matches_max']:
module.fail_json(msg='Found %d entries, but expected at most %d' % (len(matching_entries), module.params['require_matches_max']))
elif not module.params['allow_no_matches']:
module.fail_json(msg='Found no entries, but allow_no_matches=false')
# Identify entries to update
modifications = []
for index, entry in matching_entries:
modification = {}
for key, value in values.items():
if key.startswith('!'):
# Allow to specify keys to remove by prepending '!'
key = key[1:]
value = None
current_value = entry.get(key)
if key in DISABLED_MEANS_EMPTY_STRING and value == '' and current_value is None:
current_value = value
if current_value != value:
if value is None:
disable_key = '!%s' % key
if key in DISABLED_MEANS_EMPTY_STRING:
disable_key = key
modification[disable_key] = ''
entry.pop(key, None)
else:
modification[key] = value
entry[key] = value
if modification:
if '.id' in entry:
modification['.id'] = entry['.id']
modifications.append(modification)
# Apply changes
if not module.check_mode and modifications:
for modification in modifications:
try:
api_path.update(**modification)
except (LibRouterosError, UnicodeEncodeError) as e:
module.fail_json(
msg='Error while modifying for .id={id}: {error}'.format(
id=modification['.id'],
error=to_native(e),
)
)
new_data = filter_entries(list(api_path), ignore_dynamic=ignore_dynamic, ignore_builtin=ignore_builtin)
# Produce return value
more = {}
if module._diff:
# Only include the matching values
more['diff'] = {
'before': {
'values': [old_data[index] for index, entry in matching_entries],
},
'after': {
'values': [entry for index, entry in matching_entries],
},
}
module.exit_json(
changed=bool(modifications),
old_data=old_data,
new_data=new_data,
match_count=len(matching_entries),
modify_count=len(modifications),
**more
)
if __name__ == '__main__':
main()

View file

@ -1,500 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (c) 2022, Felix Fontein (@felixfontein) <felix@fontein.de>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = r"""
module: api_info
author:
- "Felix Fontein (@felixfontein)"
short_description: Retrieve information from API
version_added: 2.2.0
description:
- Allows to retrieve information for a path using the API.
- This can be used to backup a path to restore it with the M(community.routeros.api_modify) module.
- Entries are normalized, dynamic and builtin entries are not returned. Use the O(handle_disabled) and O(hide_defaults)
options to control normalization, the O(include_dynamic) and O(include_builtin) options to also return dynamic resp. builtin
entries, and use O(unfiltered) to return all fields including counters.
- B(Note) that this module is still heavily in development, and only supports B(some) paths. If you want to support new
paths, or think you found problems with existing paths, please first L(create an issue in the community.routeros Issue
Tracker,https://github.com/ansible-collections/community.routeros/issues/).
extends_documentation_fragment:
- community.routeros.api
- community.routeros.api.restrict
- community.routeros.attributes
- community.routeros.attributes.actiongroup_api
- community.routeros.attributes.idempotent_not_modify_state
- community.routeros.attributes.info_module
attributes:
platform:
support: full
platforms: RouterOS
options:
path:
description:
- Path to query.
- An example value is V(ip address). This is equivalent to running C(/ip address print) in the RouterOS CLI.
required: true
type: str
choices:
# BEGIN PATH LIST
- caps-man aaa
- caps-man access-list
- caps-man channel
- caps-man configuration
- caps-man datapath
- caps-man manager
- caps-man manager interface
- caps-man provisioning
- caps-man security
- certificate settings
- interface 6to4
- interface bonding
- interface bridge
- interface bridge mlag
- interface bridge port
- interface bridge port-controller
- interface bridge port-extender
- interface bridge settings
- interface bridge vlan
- interface detect-internet
- interface eoip
- interface ethernet
- interface ethernet poe
- interface ethernet switch
- interface ethernet switch port
- interface ethernet switch port-isolation
- interface gre
- interface gre6
- interface l2tp-client
- interface l2tp-server server
- interface list
- interface list member
- interface ovpn-client
- interface ovpn-server server
- interface ppp-client
- interface pppoe-client
- interface pppoe-server server
- interface pptp-server server
- interface sstp-server server
- interface vlan
- interface vrrp
- interface wifi
- interface wifi aaa
- interface wifi access-list
- interface wifi cap
- interface wifi capsman
- interface wifi channel
- interface wifi configuration
- interface wifi datapath
- interface wifi interworking
- interface wifi provisioning
- interface wifi security
- interface wifi steering
- interface wifiwave2
- interface wifiwave2 aaa
- interface wifiwave2 access-list
- interface wifiwave2 cap
- interface wifiwave2 capsman
- interface wifiwave2 channel
- interface wifiwave2 configuration
- interface wifiwave2 datapath
- interface wifiwave2 interworking
- interface wifiwave2 provisioning
- interface wifiwave2 security
- interface wifiwave2 steering
- interface wireguard
- interface wireguard peers
- interface wireless
- interface wireless access-list
- interface wireless align
- interface wireless cap
- interface wireless connect-list
- interface wireless security-profiles
- interface wireless sniffer
- interface wireless snooper
- iot modbus
- ip accounting
- ip accounting web-access
- ip address
- ip arp
- ip cloud
- ip cloud advanced
- ip dhcp-client
- ip dhcp-client option
- ip dhcp-relay
- ip dhcp-server
- ip dhcp-server config
- ip dhcp-server lease
- ip dhcp-server matcher
- ip dhcp-server network
- ip dhcp-server option
- ip dhcp-server option sets
- ip dns
- ip dns adlist
- ip dns forwarders
- ip dns static
- ip firewall address-list
- ip firewall connection tracking
- ip firewall filter
- ip firewall layer7-protocol
- ip firewall mangle
- ip firewall nat
- ip firewall raw
- ip firewall service-port
- ip hotspot service-port
- ip ipsec identity
- ip ipsec mode-config
- ip ipsec peer
- ip ipsec policy
- ip ipsec profile
- ip ipsec proposal
- ip ipsec settings
- ip neighbor discovery-settings
- ip pool
- ip proxy
- ip route
- ip route rule
- ip route vrf
- ip service
- ip settings
- ip smb
- ip socks
- ip ssh
- ip tftp settings
- ip traffic-flow
- ip traffic-flow ipfix
- ip traffic-flow target
- ip upnp
- ip upnp interfaces
- ip vrf
- ipv6 address
- ipv6 dhcp-client
- ipv6 dhcp-server
- ipv6 dhcp-server option
- ipv6 firewall address-list
- ipv6 firewall filter
- ipv6 firewall mangle
- ipv6 firewall nat
- ipv6 firewall raw
- ipv6 nd
- ipv6 nd prefix
- ipv6 nd prefix default
- ipv6 route
- ipv6 settings
- mpls
- mpls interface
- mpls ldp
- mpls ldp accept-filter
- mpls ldp advertise-filter
- mpls ldp interface
- port firmware
- port remote-access
- ppp aaa
- ppp profile
- ppp secret
- queue interface
- queue simple
- queue tree
- queue type
- radius
- radius incoming
- routing bfd configuration
- routing bgp aggregate
- routing bgp connection
- routing bgp instance
- routing bgp network
- routing bgp peer
- routing bgp template
- routing filter
- routing filter community-list
- routing filter num-list
- routing filter rule
- routing filter select-rule
- routing id
- routing igmp-proxy
- routing igmp-proxy interface
- routing mme
- routing ospf area
- routing ospf area range
- routing ospf instance
- routing ospf interface-template
- routing ospf static-neighbor
- routing pimsm instance
- routing pimsm interface-template
- routing rip
- routing ripng
- routing rule
- routing table
- snmp
- snmp community
- system clock
- system clock manual
- system health settings
- system identity
- system leds settings
- system logging
- system logging action
- system note
- system ntp client
- system ntp client servers
- system ntp server
- system package update
- system resource irq rps
- system routerboard settings
- system scheduler
- system script
- system upgrade mirror
- system ups
- system watchdog
- tool bandwidth-server
- tool e-mail
- tool graphing
- tool graphing interface
- tool graphing resource
- tool mac-server
- tool mac-server mac-winbox
- tool mac-server ping
- tool netwatch
- tool romon
- tool sms
- tool sniffer
- tool traffic-generator
- user
- user aaa
- user group
- user settings
# END PATH LIST
unfiltered:
description:
- Whether to output all fields, and not just the ones supported as input for M(community.routeros.api_modify).
- Unfiltered output can contain counters and other state information.
type: bool
default: false
handle_disabled:
description:
- How to handle unset values.
- V(exclamation) prepends the keys with V(!) in the output with value V(null).
- V(null-value) uses the regular key with value V(null).
- V(omit) omits these values from the result.
type: str
choices:
- exclamation
- null-value
- omit
default: exclamation
hide_defaults:
description:
- Whether to hide default values.
type: bool
default: true
include_dynamic:
description:
- Whether to include dynamic values.
- By default, they are not returned, and the C(dynamic) keys are omitted.
- If set to V(true), they are returned as well, and the C(dynamic) keys are returned as well.
type: bool
default: false
include_builtin:
description:
- Whether to include builtin values.
- By default, they are not returned, and the C(builtin) keys are omitted.
- If set to V(true), they are returned as well, and the C(builtin) keys are returned as well.
type: bool
default: false
version_added: 2.4.0
include_read_only:
description:
- Whether to include read-only fields.
- By default, they are not returned.
type: bool
default: false
version_added: 2.10.0
restrict:
description:
- Restrict output to entries matching the following criteria.
version_added: 2.18.0
seealso:
- module: community.routeros.api
- module: community.routeros.api_facts
- module: community.routeros.api_find_and_modify
- module: community.routeros.api_modify
"""
EXAMPLES = r"""
---
- name: Get IP addresses
community.routeros.api_info:
hostname: "{{ hostname }}"
password: "{{ password }}"
username: "{{ username }}"
path: ip address
register: ip_addresses
- name: Print data for IP addresses
ansible.builtin.debug:
var: ip_addresses.result
- name: Get IP addresses
community.routeros.api_info:
hostname: "{{ hostname }}"
password: "{{ password }}"
username: "{{ username }}"
path: ip address
register: ip_addresses
- name: Print data for IP addresses
ansible.builtin.debug:
var: ip_addresses.result
"""
RETURN = r"""
result:
description: A list of all elements for the current path.
sample:
- '.id': '*1'
actual-interface: bridge
address: "192.168.88.1/24"
comment: defconf
disabled: false
dynamic: false
interface: bridge
invalid: false
network: 192.168.88.0
type: list
elements: dict
returned: always
"""
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.text.converters import to_native
from ansible_collections.community.routeros.plugins.module_utils.api import (
api_argument_spec,
check_has_library,
create_api,
get_api_version,
)
from ansible_collections.community.routeros.plugins.module_utils._api_data import (
PATHS,
join_path,
split_path,
)
from ansible_collections.community.routeros.plugins.module_utils._api_helper import (
restrict_argument_spec,
restrict_entry_accepted,
validate_and_prepare_restrict,
)
try:
from librouteros.exceptions import LibRouterosError
except Exception:
# Handled in api module_utils
pass
def compose_api_path(api, path):
api_path = api.path()
for p in path:
api_path = api_path.join(p)
return api_path
def main():
module_args = dict(
path=dict(type='str', required=True, choices=sorted([join_path(path) for path in PATHS if PATHS[path].fully_understood])),
unfiltered=dict(type='bool', default=False),
handle_disabled=dict(type='str', choices=['exclamation', 'null-value', 'omit'], default='exclamation'),
hide_defaults=dict(type='bool', default=True),
include_dynamic=dict(type='bool', default=False),
include_builtin=dict(type='bool', default=False),
include_read_only=dict(type='bool', default=False),
)
module_args.update(api_argument_spec())
module_args.update(restrict_argument_spec())
module = AnsibleModule(
argument_spec=module_args,
supports_check_mode=True,
)
check_has_library(module)
api = create_api(module)
path = split_path(module.params['path'])
versioned_path_info = PATHS.get(tuple(path))
if versioned_path_info is None:
module.fail_json(msg='Path /{path} is not yet supported'.format(path='/'.join(path)))
if versioned_path_info.needs_version:
api_version = get_api_version(api)
supported, not_supported_msg = versioned_path_info.provide_version(api_version)
if not supported:
msg = 'Path /{path} is not supported for API version {api_version}'.format(path='/'.join(path), api_version=api_version)
if not_supported_msg:
msg = '{0}: {1}'.format(msg, not_supported_msg)
module.fail_json(msg=msg)
path_info = versioned_path_info.get_data()
handle_disabled = module.params['handle_disabled']
hide_defaults = module.params['hide_defaults']
include_dynamic = module.params['include_dynamic']
include_builtin = module.params['include_builtin']
include_read_only = module.params['include_read_only']
restrict_data = validate_and_prepare_restrict(module, path_info)
try:
api_path = compose_api_path(api, path)
result = []
unfiltered = module.params['unfiltered']
for entry in api_path:
if not include_dynamic:
if entry.get('dynamic', False):
continue
if not include_builtin:
if entry.get('builtin', False):
continue
if not restrict_entry_accepted(entry, path_info, restrict_data):
continue
if not unfiltered:
for k in list(entry):
if k == '.id':
continue
if k == 'dynamic' and include_dynamic:
continue
if k == 'builtin' and include_builtin:
continue
if k not in path_info.fields:
entry.pop(k)
if handle_disabled != 'omit':
for k, field_info in path_info.fields.items():
if field_info.write_only:
entry.pop(k, None)
continue
if k not in entry:
if handle_disabled == 'exclamation':
k = '!%s' % k
entry[k] = None
for k, field_info in path_info.fields.items():
if hide_defaults:
if field_info.default is not None and entry.get(k) == field_info.default:
entry.pop(k)
if field_info.absent_value and k not in entry:
entry[k] = field_info.absent_value
if not include_read_only and k in entry and field_info.read_only:
entry.pop(k)
result.append(entry)
module.exit_json(result=result)
except (LibRouterosError, UnicodeEncodeError) as e:
module.fail_json(msg=to_native(e))
if __name__ == '__main__':
main()

File diff suppressed because it is too large Load diff

View file

@ -1,83 +1,63 @@
#!/usr/bin/python #!/usr/bin/python
# Copyright (c) Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r""" DOCUMENTATION = '''
---
module: command module: command
author: "Egor Zaitsev (@heuels)" author: "Egor Zaitsev (@heuels)"
short_description: Run commands on remote devices running MikroTik RouterOS short_description: Run commands on remote devices running MikroTik RouterOS
description: description:
- Sends arbitrary commands to an RouterOS node and returns the results read from the device. This module includes an argument - Sends arbitrary commands to an RouterOS node and returns the results
that will cause the module to wait for a specific condition before returning or timing out if the condition is not met. read from the device. This module includes an
- The module always indicates a (changed) status. You can use R(the changed_when task property,override_the_changed_result) argument that will cause the module to wait for a specific condition
to determine whether a command task actually resulted in a change or not. before returning or timing out if the condition is not met.
extends_documentation_fragment:
- community.routeros.attributes
attributes:
check_mode:
support: none
details:
- Before community.routeros 3.0.0, the module claimed to support check mode. It simply executed the command in check
mode.
diff_mode:
support: none
platform:
support: full
platforms: RouterOS
idempotent:
support: N/A
details:
- Whether the executed command is idempotent depends on the command.
options: options:
commands: commands:
description: description:
- List of commands to send to the remote RouterOS device over the configured provider. The resulting output from the - List of commands to send to the remote RouterOS device over the
command is returned. If the O(wait_for) argument is provided, the module is not returned until the condition is satisfied configured provider. The resulting output from the command
or the number of retries has expired. is returned. If the I(wait_for) argument is provided, the
module is not returned until the condition is satisfied or
the number of retries has expired.
required: true required: true
type: list
elements: str
wait_for: wait_for:
description: description:
- List of conditions to evaluate against the output of the command. The task will wait for each condition to be true - List of conditions to evaluate against the output of the
before moving forward. If the conditional is not true within the configured number of retries, the task fails. See command. The task will wait for each condition to be true
examples. before moving forward. If the conditional is not true
type: list within the configured number of retries, the task fails.
elements: str See examples.
match: match:
description: description:
- The O(match) argument is used in conjunction with the O(wait_for) argument to specify the match policy. Valid values - The I(match) argument is used in conjunction with the
are V(all) or V(any). If the value is set to V(all) then all conditionals in the wait_for must be satisfied. If the I(wait_for) argument to specify the match policy. Valid
value is set to V(any) then only one of the values must be satisfied. values are C(all) or C(any). If the value is set to C(all)
then all conditionals in the wait_for must be satisfied. If
the value is set to C(any) then only one of the values must be
satisfied.
default: all default: all
choices: ['any', 'all'] choices: ['any', 'all']
type: str
retries: retries:
description: description:
- Specifies the number of retries a command should by tried before it is considered failed. The command is run on the - Specifies the number of retries a command should by tried
target device every retry and evaluated against the O(wait_for) conditions. before it is considered failed. The command is run on the
target device every retry and evaluated against the
I(wait_for) conditions.
default: 10 default: 10
type: int
interval: interval:
description: description:
- Configures the interval in seconds to wait between retries of the command. If the command does not pass the specified - Configures the interval in seconds to wait between retries
conditions, the interval indicates how long to wait before trying the command again. of the command. If the command does not pass the specified
conditions, the interval indicates how long to wait before
trying the command again.
default: 1 default: 1
type: int '''
seealso:
- ref: ansible_collections.community.routeros.docsite.ssh-guide
description: How to connect to RouterOS devices with SSH.
- ref: ansible_collections.community.routeros.docsite.quoting
description: How to quote and unquote commands and arguments.
"""
EXAMPLES = r""" EXAMPLES = """
---
- name: Run command on remote devices - name: Run command on remote devices
community.routeros.command: community.routeros.command:
commands: /system routerboard print commands: /system routerboard print
@ -103,29 +83,31 @@ EXAMPLES = r"""
- result[1] contains ether1 - result[1] contains ether1
""" """
RETURN = r""" RETURN = """
stdout: stdout:
description: The set of responses from the commands. description: The set of responses from the commands
returned: always apart from low level errors (such as action plugin) returned: always apart from low level errors (such as action plugin)
type: list type: list
sample: ['...', '...'] sample: ['...', '...']
stdout_lines: stdout_lines:
description: The value of stdout split into a list. description: The value of stdout split into a list
returned: always apart from low level errors (such as action plugin) returned: always apart from low level errors (such as action plugin)
type: list type: list
sample: [['...', '...'], ['...'], ['...']] sample: [['...', '...'], ['...'], ['...']]
failed_conditions: failed_conditions:
description: The list of conditionals that have failed. description: The list of conditionals that have failed
returned: failed returned: failed
type: list type: list
sample: ['...', '...'] sample: ['...', '...']
""" """
import re
import time import time
from ansible_collections.community.routeros.plugins.module_utils.routeros import run_commands from ansible_collections.community.routeros.plugins.module_utils.routeros import run_commands
from ansible_collections.community.routeros.plugins.module_utils.routeros import routeros_argument_spec from ansible_collections.community.routeros.plugins.module_utils.routeros import routeros_argument_spec
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ComplexList
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.parsing import Conditional from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.parsing import Conditional
from ansible.module_utils.six import string_types from ansible.module_utils.six import string_types
@ -141,10 +123,10 @@ def main():
"""main entry point for module execution """main entry point for module execution
""" """
argument_spec = dict( argument_spec = dict(
commands=dict(type='list', elements='str', required=True), commands=dict(type='list', required=True),
wait_for=dict(type='list', elements='str'), wait_for=dict(type='list'),
match=dict(type='str', default='all', choices=['all', 'any']), match=dict(default='all', choices=['all', 'any']),
retries=dict(default=10, type='int'), retries=dict(default=10, type='int'),
interval=dict(default=1, type='int') interval=dict(default=1, type='int')
@ -153,7 +135,7 @@ def main():
argument_spec.update(routeros_argument_spec) argument_spec.update(routeros_argument_spec)
module = AnsibleModule(argument_spec=argument_spec, module = AnsibleModule(argument_spec=argument_spec,
supports_check_mode=False) supports_check_mode=True)
result = {'changed': False} result = {'changed': False}
@ -186,7 +168,7 @@ def main():
module.fail_json(msg=msg, failed_conditions=failed_conditions) module.fail_json(msg=msg, failed_conditions=failed_conditions)
result.update({ result.update({
'changed': True, 'changed': False,
'stdout': responses, 'stdout': responses,
'stdout_lines': list(to_lines(responses)) 'stdout_lines': list(to_lines(responses))
}) })

View file

@ -1,48 +1,35 @@
#!/usr/bin/python #!/usr/bin/python
# Copyright (c) Ansible Project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
DOCUMENTATION = r""" DOCUMENTATION = '''
---
module: facts module: facts
author: "Egor Zaitsev (@heuels)" author: "Egor Zaitsev (@heuels)"
short_description: Collect facts from remote devices running MikroTik RouterOS short_description: Collect facts from remote devices running MikroTik RouterOS
description: description:
- Collects a base set of device facts from a remote device that is running RouterOS. This module prepends all of the base - Collects a base set of device facts from a remote device that
network fact keys with C(ansible_net_<fact>). The facts module will always collect a base set of facts from the device is running RotuerOS. This module prepends all of the
base network fact keys with C(ansible_net_<fact>). The facts
module will always collect a base set of facts from the device
and can enable or disable collection of additional facts. and can enable or disable collection of additional facts.
extends_documentation_fragment:
- community.routeros.attributes
- community.routeros.attributes.facts
- community.routeros.attributes.facts_module
- community.routeros.attributes.idempotent_not_modify_state
attributes:
platform:
support: full
platforms: RouterOS
options: options:
gather_subset: gather_subset:
description: description:
- When supplied, this argument will restrict the facts collected to a given subset. Possible values for this argument - When supplied, this argument will restrict the facts collected
include V(all), V(hardware), V(config), V(interfaces), and V(routing). to a given subset. Possible values for this argument include
- Can specify a list of values to include a larger subset. Values can also be used with an initial V(!) to specify that C(all), C(hardware), C(config), and C(interfaces). Can specify a list of
a specific subset should not be collected. values to include a larger subset. Values can also be used
with an initial C(!) to specify that a specific subset should
not be collected.
required: false required: false
default: default: '!config'
- '!config' '''
type: list
elements: str
seealso:
- ref: ansible_collections.community.routeros.docsite.ssh-guide
description: How to connect to RouterOS devices with SSH.
"""
EXAMPLES = r""" EXAMPLES = """
---
- name: Collect all facts from the device - name: Collect all facts from the device
community.routeros.facts: community.routeros.facts:
gather_subset: all gather_subset: all
@ -58,123 +45,123 @@ EXAMPLES = r"""
- "!hardware" - "!hardware"
""" """
RETURN = r""" RETURN = """
ansible_facts: ansible_facts:
description: "Dictionary of IP geolocation facts for a host's IP address." description: "Dictionary of ip geolocation facts for a host's IP address"
returned: always returned: always
type: dict type: dict
contains: contains:
ansible_net_gather_subset: ansible_net_gather_subset:
description: The list of fact subsets collected from the device. description: The list of fact subsets collected from the device
returned: always returned: always
type: list type: list
# default # default
ansible_net_model: ansible_net_model:
description: The model name returned from the device. description: The model name returned from the device
returned: O(gather_subset) contains V(default) returned: always
type: str type: str
ansible_net_serialnum: ansible_net_serialnum:
description: The serial number of the remote device. description: The serial number of the remote device
returned: O(gather_subset) contains V(default) returned: always
type: str type: str
ansible_net_version: ansible_net_version:
description: The operating system version running on the remote device. description: The operating system version running on the remote device
returned: O(gather_subset) contains V(default) returned: always
type: str type: str
ansible_net_hostname: ansible_net_hostname:
description: The configured hostname of the device. description: The configured hostname of the device
returned: O(gather_subset) contains V(default) returned: always
type: str type: str
ansible_net_arch: ansible_net_arch:
description: The CPU architecture of the device. description: The CPU architecture of the device
returned: O(gather_subset) contains V(default) returned: always
type: str type: str
ansible_net_uptime: ansible_net_uptime:
description: The uptime of the device. description: The uptime of the device
returned: O(gather_subset) contains V(default) returned: always
type: str type: str
ansible_net_cpu_load: ansible_net_cpu_load:
description: Current CPU load. description: Current CPU load
returned: O(gather_subset) contains V(default) returned: always
type: str type: str
# hardware # hardware
ansible_net_spacefree_mb: ansible_net_spacefree_mb:
description: The available disk space on the remote device in MiB. description: The available disk space on the remote device in MiB
returned: O(gather_subset) contains V(hardware) returned: when hardware is configured
type: dict type: dict
ansible_net_spacetotal_mb: ansible_net_spacetotal_mb:
description: The total disk space on the remote device in MiB. description: The total disk space on the remote device in MiB
returned: O(gather_subset) contains V(hardware) returned: when hardware is configured
type: dict type: dict
ansible_net_memfree_mb: ansible_net_memfree_mb:
description: The available free memory on the remote device in MiB. description: The available free memory on the remote device in MiB
returned: O(gather_subset) contains V(hardware) returned: when hardware is configured
type: int type: int
ansible_net_memtotal_mb: ansible_net_memtotal_mb:
description: The total memory on the remote device in MiB. description: The total memory on the remote device in MiB
returned: O(gather_subset) contains V(hardware) returned: when hardware is configured
type: int type: int
# config # config
ansible_net_config: ansible_net_config:
description: The current active config from the device. description: The current active config from the device
returned: O(gather_subset) contains V(config) returned: when config is configured
type: str type: str
ansible_net_config_nonverbose: ansible_net_config_nonverbose:
description: description:
- The current active config from the device in minimal form. - The current active config from the device in minimal form.
- This value is idempotent in the sense that if the facts module is run twice and the device's config was not changed - This value is idempotent in the sense that if the facts module is run twice and the device's config
between the runs, the value is identical. This is achieved by running C(/export) and stripping the timestamp from was not changed between the runs, the value is identical. This is achieved by running C(/export)
the comment in the first line. and stripping the timestamp from the comment in the first line.
returned: O(gather_subset) contains V(config) returned: when config is configured
type: str type: str
version_added: 1.2.0 version_added: 1.2.0
# interfaces # interfaces
ansible_net_all_ipv4_addresses: ansible_net_all_ipv4_addresses:
description: All IPv4 addresses configured on the device. description: All IPv4 addresses configured on the device
returned: O(gather_subset) contains V(interfaces) returned: when interfaces is configured
type: list type: list
ansible_net_all_ipv6_addresses: ansible_net_all_ipv6_addresses:
description: All IPv6 addresses configured on the device. description: All IPv6 addresses configured on the device
returned: O(gather_subset) contains V(interfaces) returned: when interfaces is configured
type: list type: list
ansible_net_interfaces: ansible_net_interfaces:
description: A hash of all interfaces running on the system. description: A hash of all interfaces running on the system
returned: O(gather_subset) contains V(interfaces) returned: when interfaces is configured
type: dict type: dict
ansible_net_neighbors: ansible_net_neighbors:
description: The list of neighbors from the remote device. description: The list of neighbors from the remote device
returned: O(gather_subset) contains V(interfaces) returned: when interfaces is configured
type: dict type: dict
# routing # routing
ansible_net_bgp_peer: ansible_net_bgp_peer:
description: A dictionary with BGP peer information. description: The dict bgp peer
returned: O(gather_subset) contains V(routing) returned: peer information
type: dict type: dict
ansible_net_bgp_vpnv4_route: ansible_net_bgp_vpnv4_route:
description: A dictionary with BGP vpnv4 route information. description: The dict bgp vpnv4 route
returned: O(gather_subset) contains V(routing) returned: vpnv4 route information
type: dict type: dict
ansible_net_bgp_instance: ansible_net_bgp_instance:
description: A dictionary with BGP instance information. description: The dict bgp instance
returned: O(gather_subset) contains V(routing) returned: bgp instance information
type: dict type: dict
ansible_net_route: ansible_net_route:
description: A dictionary for routes in all routing tables. description: The dict routes in all routing table
returned: O(gather_subset) contains V(routing) returned: routes information in all routing table
type: dict type: dict
ansible_net_ospf_instance: ansible_net_ospf_instance:
description: A dictionary with OSPF instances. description: The dict ospf instance
returned: O(gather_subset) contains V(routing) returned: ospf instance information
type: dict type: dict
ansible_net_ospf_neighbor: ansible_net_ospf_neighbor:
description: A dictionary with OSPF neighbors. description: The dict ospf neighbor
returned: O(gather_subset) contains V(routing) returned: ospf neighbor information
type: dict type: dict
""" """
import re import re
@ -308,7 +295,7 @@ class Config(FactsBase):
'/export', '/export',
] ]
RM_DATE_RE = re.compile(r'^# [a-z0-9/-][a-z0-9/-]* [0-9:]* by RouterOS') RM_DATE_RE = re.compile(r'^# [a-z0-9/][a-z0-9/]* [0-9:]* by RouterOS')
def populate(self): def populate(self):
super(Config, self).populate() super(Config, self).populate()
@ -388,7 +375,7 @@ class Interfaces(FactsBase):
for line in data.split('\n'): for line in data.split('\n'):
if len(line) == 0 or line[:5] == 'Flags': if len(line) == 0 or line[:5] == 'Flags':
continue continue
elif not preprocessed or not re.match(self.WRAPPED_LINE_RE, line): elif not re.match(self.WRAPPED_LINE_RE, line):
preprocessed.append(line) preprocessed.append(line)
else: else:
preprocessed[-1] += line preprocessed[-1] += line
@ -465,7 +452,7 @@ class Routing(FactsBase):
for line in data.split('\n'): for line in data.split('\n'):
if len(line) == 0 or line[:5] == 'Flags': if len(line) == 0 or line[:5] == 'Flags':
continue continue
elif not preprocessed or not re.match(self.WRAPPED_LINE_RE, line): elif not re.match(self.WRAPPED_LINE_RE, line):
preprocessed.append(line) preprocessed.append(line)
else: else:
preprocessed[-1] += line preprocessed[-1] += line
@ -589,12 +576,14 @@ FACT_SUBSETS = dict(
VALID_SUBSETS = frozenset(FACT_SUBSETS.keys()) VALID_SUBSETS = frozenset(FACT_SUBSETS.keys())
warnings = list()
def main(): def main():
"""main entry point for module execution """main entry point for module execution
""" """
argument_spec = dict( argument_spec = dict(
gather_subset=dict(default=['!config'], type='list', elements='str') gather_subset=dict(default=['!config'], type='list')
) )
argument_spec.update(routeros_argument_spec) argument_spec.update(routeros_argument_spec)
@ -651,7 +640,7 @@ def main():
key = 'ansible_net_%s' % key key = 'ansible_net_%s' % key
ansible_facts[key] = value ansible_facts[key] = value
module.exit_json(ansible_facts=ansible_facts) module.exit_json(ansible_facts=ansible_facts, warnings=warnings)
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -1,13 +1,29 @@
# Copyright (c) 2016 Red Hat Inc. #
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # (c) 2016 Red Hat Inc.
# SPDX-License-Identifier: GPL-3.0-or-later #
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import json
import re import re
from ansible.errors import AnsibleConnectionFailure from ansible.errors import AnsibleConnectionFailure
from ansible.module_utils.common.text.converters import to_text, to_bytes
from ansible.plugins.terminal import TerminalBase from ansible.plugins.terminal import TerminalBase
from ansible.utils.display import Display from ansible.utils.display import Display
@ -31,9 +47,7 @@ class TerminalModule(TerminalBase):
terminal_stdout_re = [ terminal_stdout_re = [
re.compile(br"\x1b<"), re.compile(br"\x1b<"),
re.compile( re.compile(br"\[[\w\-\.]+\@[\w\s\-\.\/]+\] ?> ?$"),
br"((\[[\w\-\.]+\@)|(\r\<(([\w\-\.]*\@)|)))"
br"[\w\s\-\.\/]+\] ?(<SAFE)?> ?$"),
re.compile(br"Please press \"Enter\" to continue!"), re.compile(br"Please press \"Enter\" to continue!"),
re.compile(br"Do you want to see the software license\? \[Y\/n\]: ?"), re.compile(br"Do you want to see the software license\? \[Y\/n\]: ?"),
] ]

View file

@ -1,8 +1,4 @@
--- ---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
# See template for more information: # See template for more information:
# https://github.com/ansible/ansible/blob/devel/test/lib/ansible_test/config/config.yml # https://github.com/ansible/ansible/blob/devel/test/lib/ansible_test/config/config.yml
modules: modules:

View file

@ -1,18 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- hosts: localhost
tasks:
- name: Find all roles
find:
paths:
- "{{ (playbook_dir | default('.')) ~ '/roles' }}"
file_type: directory
depth: 1
register: result
- name: Include all roles
include_role:
name: "{{ item }}"
loop: "{{ result.files | map(attribute='path') | map('regex_replace', '.*/', '') | sort }}"

View file

@ -1,6 +0,0 @@
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
shippable/posix/group1
skip/python2.6

View file

@ -1,63 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: "Test split filter"
assert:
that:
- "'' | community.routeros.split == []"
- "'foo bar' | community.routeros.split == ['foo', 'bar']"
- >
'foo bar="a b c"' | community.routeros.split == ['foo', 'bar=a b c']
- name: "Test split filter error handling"
set_fact:
test: >-
{{ 'a="' | community.routeros.split }}
ignore_errors: true
register: result
- name: "Verify split filter error handling"
assert:
that:
- >-
"Unexpected end of string during escaped parameter" in result.msg
- name: "Test quote_argument filter"
assert:
that:
- >
'a=' | community.routeros.quote_argument == 'a=""'
- >
'a=b' | community.routeros.quote_argument == 'a=b'
- >
'a=b c' | community.routeros.quote_argument == 'a="b\\_c"'
- >
'a=""' | community.routeros.quote_argument == 'a="\\"\\""'
- name: "Test quote_argument_value filter"
assert:
that:
- >
'' | community.routeros.quote_argument_value == '""'
- >
'foo' | community.routeros.quote_argument_value == 'foo'
- >
'"foo bar"' | community.routeros.quote_argument_value == '"\\"foo\\_bar\\""'
- name: "Test join filter"
assert:
that:
- >
['a=', 'b=c d'] | community.routeros.join == 'a="" b="c\\_d"'
- name: "Test list_to_dict filter"
assert:
that:
- >
['a=', 'b=c'] | community.routeros.list_to_dict == {'a': '', 'b': 'c'}
- >
['a=', 'b=c'] | community.routeros.list_to_dict(skip_empty_values=True) == {'b': 'c'}
- >
['a', 'b=c'] | community.routeros.list_to_dict(require_assignment=False) == {'a': none, 'b': 'c'}

View file

@ -1,43 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: Run api module
community.routeros.api:
username: foo
password: bar
hostname: localhost
path: ip address
ignore_errors: true
register: result
- name: Validate result
assert:
that:
- result is failed
- result.msg in potential_errors
vars:
potential_errors:
- "Error while connecting: [Errno 111] Connection refused"
- "Error while connecting: [Errno 99] Cannot assign requested address"
- name: Run command module
community.routeros.command:
commands:
- /ip address print
vars:
ansible_host: localhost
ansible_connection: ansible.netcommon.network_cli
ansible_network_os: community.routeros.routeros
ansible_user: foo
ansible_ssh_pass: bar
ansible_ssh_port: 12349
ignore_errors: true
register: result
- name: Validate result
assert:
that:
- result is failed
- "'Unable to connect to port 12349 ' in result.msg or 'ssh connect failed: Connection refused' in result.msg"

View file

@ -1,7 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
collections:
- ansible.netcommon

View file

@ -1,6 +0,0 @@
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
shippable/posix/group1
skip/python2.6

View file

@ -1,63 +0,0 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: "Test split filter"
assert:
that:
- "'' | community.routeros.split == []"
- "'foo bar' | community.routeros.split == ['foo', 'bar']"
- >
'foo bar="a b c"' | community.routeros.split == ['foo', 'bar=a b c']
- name: "Test split filter error handling"
set_fact:
test: >-
{{ 'a="' | community.routeros.split }}
ignore_errors: true
register: result
- name: "Verify split filter error handling"
assert:
that:
- >-
"Unexpected end of string during escaped parameter" in result.msg
- name: "Test quote_argument filter"
assert:
that:
- >
'a=' | community.routeros.quote_argument == 'a=""'
- >
'a=b' | community.routeros.quote_argument == 'a=b'
- >
'a=b c' | community.routeros.quote_argument == 'a="b\\_c"'
- >
'a=""' | community.routeros.quote_argument == 'a="\\"\\""'
- name: "Test quote_argument_value filter"
assert:
that:
- >
'' | community.routeros.quote_argument_value == '""'
- >
'foo' | community.routeros.quote_argument_value == 'foo'
- >
'"foo bar"' | community.routeros.quote_argument_value == '"\\"foo\\_bar\\""'
- name: "Test join filter"
assert:
that:
- >
['a=', 'b=c d'] | community.routeros.join == 'a="" b="c\\_d"'
- name: "Test list_to_dict filter"
assert:
that:
- >
['a=', 'b=c'] | community.routeros.list_to_dict == {'a': '', 'b': 'c'}
- >
['a=', 'b=c'] | community.routeros.list_to_dict(skip_empty_values=True) == {'b': 'c'}
- >
['a', 'b=c'] | community.routeros.list_to_dict(require_assignment=False) == {'a': none, 'b': 'c'}

4
tests/requirements.yml Normal file
View file

@ -0,0 +1,4 @@
integration_tests_dependencies:
- ansible.netcommon
unit_tests_dependencies:
- ansible.netcommon

View file

@ -0,0 +1,10 @@
{
"include_symlinks": false,
"prefixes": [
"docs/docsite/"
],
"output": "path-line-column-message",
"requirements": [
"antsibull"
]
}

View file

@ -0,0 +1,23 @@
#!/usr/bin/env python
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""Check extra collection docs with antsibull-lint."""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import sys
import subprocess
def main():
"""Main entry point."""
if not os.path.isdir(os.path.join('docs', 'docsite')):
return
p = subprocess.run(['antsibull-lint', 'collection-docs', '.'], check=False)
if p.returncode not in (0, 3):
print('{0}:0:0: unexpected return code {1}'.format(sys.argv[0], p.returncode))
if __name__ == '__main__':
main()

View file

@ -0,0 +1,7 @@
{
"include_symlinks": true,
"prefixes": [
"plugins/"
],
"output": "path-message"
}

View file

@ -0,0 +1,43 @@
#!/usr/bin/env python
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""Prevent unwanted files from being added to the source tree."""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import sys
def main():
"""Main entry point."""
paths = sys.argv[1:] or sys.stdin.read().splitlines()
allowed_extensions = (
'.cs',
'.ps1',
'.psm1',
'.py',
)
skip_paths = set([
])
skip_directories = (
)
for path in paths:
if path in skip_paths:
continue
if any(path.startswith(skip_directory) for skip_directory in skip_directories):
continue
ext = os.path.splitext(path)[1]
if ext not in allowed_extensions:
print('%s: extension must be one of: %s' % (path, ', '.join(allowed_extensions)))
if __name__ == '__main__':
main()

View file

@ -1,9 +1,5 @@
docs/docsite/rst/api-guide.rst rstcheck plugins/modules/command.py validate-modules:doc-missing-type
docs/docsite/rst/quoting.rst rstcheck plugins/modules/command.py validate-modules:parameter-list-no-elements
docs/docsite/rst/ssh-guide.rst rstcheck plugins/modules/command.py validate-modules:parameter-type-not-in-doc
tests/update-docs.py compile-2.6 plugins/modules/facts.py validate-modules:parameter-list-no-elements
tests/update-docs.py compile-2.7 plugins/modules/facts.py validate-modules:parameter-type-not-in-doc
tests/update-docs.py compile-3.5
tests/update-docs.py future-import-boilerplate
tests/update-docs.py metaclass-boilerplate
tests/update-docs.py shebang

View file

@ -1,3 +0,0 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Ansible Project

View file

@ -1,6 +1,5 @@
tests/update-docs.py compile-2.6 plugins/modules/command.py validate-modules:doc-missing-type
tests/update-docs.py compile-2.7 plugins/modules/command.py validate-modules:parameter-list-no-elements
tests/update-docs.py compile-3.5 plugins/modules/command.py validate-modules:parameter-type-not-in-doc
tests/update-docs.py future-import-boilerplate plugins/modules/facts.py validate-modules:parameter-list-no-elements
tests/update-docs.py metaclass-boilerplate plugins/modules/facts.py validate-modules:parameter-type-not-in-doc
tests/update-docs.py shebang

View file

@ -1,3 +0,0 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Ansible Project

View file

@ -1 +1,5 @@
tests/update-docs.py shebang plugins/modules/command.py validate-modules:doc-missing-type
plugins/modules/command.py validate-modules:parameter-list-no-elements
plugins/modules/command.py validate-modules:parameter-type-not-in-doc
plugins/modules/facts.py validate-modules:parameter-list-no-elements
plugins/modules/facts.py validate-modules:parameter-type-not-in-doc

View file

@ -1,3 +0,0 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Ansible Project

View file

@ -1 +0,0 @@
tests/update-docs.py shebang

View file

@ -1,3 +0,0 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Ansible Project

View file

@ -1 +0,0 @@
tests/update-docs.py shebang

View file

@ -1,3 +0,0 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Ansible Project

View file

@ -1 +0,0 @@
tests/update-docs.py shebang

View file

@ -1,3 +0,0 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Ansible Project

View file

@ -1 +0,0 @@
tests/update-docs.py shebang

View file

@ -1,3 +0,0 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Ansible Project

View file

@ -1 +0,0 @@
tests/update-docs.py shebang

View file

@ -1,3 +0,0 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Ansible Project

View file

@ -1 +0,0 @@
tests/update-docs.py shebang

View file

@ -1,3 +0,0 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Ansible Project

View file

@ -1 +0,0 @@
tests/update-docs.py shebang

View file

@ -1,3 +0,0 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Ansible Project

View file

@ -1,4 +0,0 @@
plugins/modules/api_facts.py pylint:ansible-bad-import-from
plugins/modules/command.py pylint:ansible-bad-import-from
plugins/modules/facts.py pylint:ansible-bad-import-from
tests/update-docs.py shebang

View file

@ -1,3 +0,0 @@
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later
SPDX-FileCopyrightText: Ansible Project

Some files were not shown because too many files have changed in this diff Show more