Debian Codegraph @

ansible_collections/community/routeros/README.md

raw
1 <!--
2 Copyright (c) Ansible Project
3 GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 SPDX-License-Identifier: GPL-3.0-or-later
5 -->
6
7 # Community RouterOS Collection
8 [![Documentation](https://img.shields.io/badge/docs-brightgreen.svg)](https://docs.ansible.com/ansible/devel/collections/community/routeros/)
9 [![CI](https://github.com/ansible-collections/community.routeros/actions/workflows/nox.yml/badge.svg?branch=main)](https://github.com/ansible-collections/community.routeros/actions)
10 [![Codecov](https://img.shields.io/codecov/c/github/ansible-collections/community.routeros)](https://codecov.io/gh/ansible-collections/community.routeros)
11 [![REUSE status](https://api.reuse.software/badge/github.com/ansible-collections/community.routeros)](https://api.reuse.software/info/github.com/ansible-collections/community.routeros)
12
13 Provides modules for [Ansible](https://www.ansible.com/community) to manage [MikroTik RouterOS](https://mikrotik.com/software) instances.
14
15 You can find [documentation for the modules and plugins in this collection here](https://docs.ansible.com/ansible/devel/collections/community/routeros/).
16
17 ## Code of Conduct
18
19 We follow [Ansible Code of Conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html) in all our interactions within this project.
20
21 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.
22
23 ## Communication
24
25 * Join the Ansible forum:
26 * [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.
27 * [Posts tagged with 'routeros'](https://forum.ansible.com/tag/routeros): subscribe to participate in RouterOS related conversations.
28 * [Social Spaces](https://forum.ansible.com/c/chat/4): gather and interact with fellow enthusiasts.
29 * [News & Announcements](https://forum.ansible.com/c/news/5): track project-wide announcements including social events.
30
31 * The Ansible [Bullhorn newsletter](https://docs.ansible.com/ansible/devel/community/communication.html#the-bullhorn): used to announce releases and important changes.
32
33 For more information about communication, see the [Ansible communication guide](https://docs.ansible.com/ansible/devel/community/communication.html).
34
35 ## Tested with Ansible
36
37 Tested with the current ansible-core 2.15, ansible-core 2.16, ansible-core 2.17, ansible-core 2.18, ansible-core 2.19, ansible-core 2.20, ansible-core 2.21 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.
38
39 ## External requirements
40
41 The exact requirements for every module are listed in the module documentation.
42
43 ### Supported connections
44
45 The collection supports the `network_cli` connection.
46
47 ### Edge cases
48
49 Please note that `community.routeros.api` module does **not** support Windows jump hosts!
50
51 ## Collection Documentation
52
53 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.
54
55 Browsing the [**devel** collection documentation](https://docs.ansible.com/ansible/devel/collections/community/routeros) shows docs for the _latest version released on Galaxy_.
56
57 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_.
58
59 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**.
60
61 ## Included content
62
63 - `community.routeros.api`
64 - `community.routeros.api_facts`
65 - `community.routeros.api_find_and_modify`
66 - `community.routeros.api_info`
67 - `community.routeros.api_modify`
68 - `community.routeros.command`
69 - `community.routeros.facts`
70
71 You can find [documentation for the modules and plugins in this collection here](https://docs.ansible.com/ansible/devel/collections/community/routeros/).
72
73 ## Using this collection
74
75 See [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for general detail on using collections.
76
77 There are two approaches for using this collection. The `command` and `facts` modules use the `network_cli` connection and connect with SSH. The `api` module connects with the HTTP/HTTPS API.
78
79 ### Prerequisites
80
81 The terminal-based modules in this collection (`community.routeros.command` and `community.routeros.facts`) do not support arbitrary symbols in 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, the `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.
82
83 ```yaml
84 - community.routeros.command:
85 commands:
86 - /ip
87 - print
88 ```
89
90 ### Connecting with `network_cli`
91
92 Example inventory `hosts` file:
93
94 ```.ini
95 [routers]
96 router ansible_host=192.168.1.1
97
98 [routers:vars]
99 ansible_connection=ansible.netcommon.network_cli
100 ansible_network_os=community.routeros.routeros
101 ansible_user=admin
102 ansible_ssh_pass=test1234
103 ```
104
105 Example playbook:
106
107 ```.yaml
108 ---
109 - name: RouterOS test with network_cli connection
110 hosts: routers
111 gather_facts: false
112 tasks:
113 - name: Run a command
114 community.routeros.command:
115 commands:
116 - /system resource print
117 register: system_resource_print
118 - name: Print its output
119 ansible.builtin.debug:
120 var: system_resource_print.stdout_lines
121
122 - name: Retrieve facts
123 community.routeros.facts:
124 - ansible.builtin.debug:
125 msg: "First IP address: {{ ansible_net_all_ipv4_addresses[0] }}"
126 ```
127
128 ### Connecting with HTTP/HTTPS API
129
130 Example playbook:
131
132 ```.yaml
133 ---
134 - name: RouterOS test with API
135 hosts: localhost
136 gather_facts: false
137 vars:
138 hostname: 192.168.1.1
139 username: admin
140 password: test1234
141 module_defaults:
142 group/community.routeros.api:
143 hostname: "{{ hostname }}"
144 password: "{{ password }}"
145 username: "{{ username }}"
146 tls: true
147 force_no_cert: false
148 validate_certs: true
149 validate_cert_hostname: true
150 ca_path: /path/to/ca-certificate.pem
151 tasks:
152 - name: Get "ip address print"
153 community.routeros.api:
154 path: ip address
155 register: print_path
156 - name: Print the result
157 ansible.builtin.debug:
158 var: print_path.msg
159
160 - name: Change IP address to 192.168.1.1 for interface bridge
161 community.routeros.api_find_and_modify:
162 path: ip address
163 find:
164 interface: bridge
165 values:
166 address: "192.168.1.1/24"
167
168 - name: Retrieve facts
169 community.routeros.api_facts:
170 - ansible.builtin.debug:
171 msg: "First IP address: {{ ansible_net_all_ipv4_addresses[0] }}"
172 ```
173
174 ## Contributing to this collection
175
176 We're following the general Ansible contributor guidelines; see [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html).
177
178 If you want to clone this repositority (or a fork of it) to improve it, you can proceed as follows:
179 1. Create a directory `ansible_collections/community`;
180 2. In there, checkout this repository (or a fork) as `routeros`;
181 3. Add the directory containing `ansible_collections` to your [ANSIBLE_COLLECTIONS_PATH](https://docs.ansible.com/ansible/latest/reference_appendices/config.html#collections-paths).
182
183 See [Ansible's dev guide](https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html#contributing-to-collections) for more information.
184
185 ## Release notes
186
187 See the [collection's changelog](https://github.com/ansible-collections/community.routeros/blob/main/CHANGELOG.md).
188
189 ## Roadmap
190
191 We plan to regularly release minor and patch versions, whenever new features are added or bugs fixed. Our collection follows [semantic versioning](https://semver.org/), so breaking changes will only happen in major releases.
192
193 ## More information
194
195 - [Ansible Collection overview](https://github.com/ansible-collections/overview)
196 - [Ansible User guide](https://docs.ansible.com/ansible/latest/user_guide/index.html)
197 - [Ansible Developer guide](https://docs.ansible.com/ansible/latest/dev_guide/index.html)
198 - [Ansible Collections Checklist](https://github.com/ansible-collections/overview/blob/master/collection_requirements.rst)
199 - [Ansible Community code of conduct](https://docs.ansible.com/ansible/latest/community/code_of_conduct.html)
200 - [The Bullhorn (the Ansible Contributor newsletter)](https://us19.campaign-archive.com/home/?u=56d874e027110e35dea0e03c1&id=d6635f5420)
201 - [Changes impacting Contributors](https://github.com/ansible-collections/overview/issues/45)
202
203 ## Licensing
204
205 This collection is primarily licensed and distributed as a whole under the GNU General Public License v3.0 or later.
206
207 See [LICENSES/GPL-3.0-or-later.txt](https://github.com/ansible-collections/community.routeros/blob/main/COPYING) for the full text.
208
209 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).
210
211 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/).