Improve docs (#2)

This commit is contained in:
Felix Fontein 2020-10-27 12:05:19 +01:00 committed by GitHub
parent 5297d4c494
commit 5368e44f83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 11 deletions

View file

@ -25,6 +25,10 @@ The collection supports the `network_cli` connection.
See [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for general detail on using collections. See [Ansible Using collections](https://docs.ansible.com/ansible/latest/user_guide/collections_using.html) for general detail on using collections.
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.
### Connecting with `network_cli`
Example inventory `hosts` file: Example inventory `hosts` file:
```.ini ```.ini
@ -42,7 +46,7 @@ Example playbook:
```.yaml ```.yaml
--- ---
- name: RouterOS test - name: RouterOS test with network_cli connection
hosts: routers hosts: routers
gather_facts: false gather_facts: false
tasks: tasks:
@ -61,6 +65,30 @@ Example playbook:
msg: "First IP address: {{ ansible_net_all_ipv4_addresses[0] }}" msg: "First IP address: {{ ansible_net_all_ipv4_addresses[0] }}"
``` ```
### Connecting with HTTP/HTTPS API
Example playbook:
```.yaml
---
- name: RouterOS test with API
hosts: localhost
gather_facts: no
vars:
hostname: 192.168.1.1
username: admin
password: test1234
tasks:
- name: Get "ip address print"
community.routeros.api:
hostname: "{{ hostname }}"
password: "{{ password }}"
username: "{{ username }}"
path: "ip address"
ssl: true
register: print_path
```
## Contributing to this collection ## Contributing to this collection
We're following the general Ansible contributor guidelines; see [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html). We're following the general Ansible contributor guidelines; see [Ansible Community Guide](https://docs.ansible.com/ansible/latest/community/index.html).

View file

@ -113,7 +113,7 @@ EXAMPLES = '''
tasks: tasks:
- name: Get "{{ path }} print" - name: Get "{{ path }} print"
community.network.api: community.routeros.api:
hostname: "{{ hostname }}" hostname: "{{ hostname }}"
password: "{{ password }}" password: "{{ password }}"
username: "{{ username }}" username: "{{ username }}"
@ -125,7 +125,7 @@ EXAMPLES = '''
msg: '{{ print_path }}' msg: '{{ print_path }}'
- name: Add ip address "{{ ip1 }}" and "{{ ip2 }}" - name: Add ip address "{{ ip1 }}" and "{{ ip2 }}"
community.network.api: community.routeros.api:
hostname: "{{ hostname }}" hostname: "{{ hostname }}"
password: "{{ password }}" password: "{{ password }}"
username: "{{ username }}" username: "{{ username }}"
@ -141,7 +141,7 @@ EXAMPLES = '''
msg: '{{ addout }}' msg: '{{ addout }}'
- name: Query for ".id" in "{{ path }} WHERE address == {{ ip2 }}" - name: Query for ".id" in "{{ path }} WHERE address == {{ ip2 }}"
community.network.api: community.routeros.api:
hostname: "{{ hostname }}" hostname: "{{ hostname }}"
password: "{{ password }}" password: "{{ password }}"
username: "{{ username }}" username: "{{ username }}"

View file

@ -60,22 +60,22 @@ options:
EXAMPLES = """ EXAMPLES = """
tasks: tasks:
- name: Run command on remote devices - name: Run command on remote devices
community.network.command: community.routeros.command:
commands: /system routerboard print commands: /system routerboard print
- name: Run command and check to see if output contains routeros - name: Run command and check to see if output contains routeros
community.network.command: community.routeros.command:
commands: /system resource print commands: /system resource print
wait_for: result[0] contains MikroTik wait_for: result[0] contains MikroTik
- name: Run multiple commands on remote nodes - name: Run multiple commands on remote nodes
community.network.command: community.routeros.command:
commands: commands:
- /system routerboard print - /system routerboard print
- /system identity print - /system identity print
- name: Run multiple commands and evaluate the output - name: Run multiple commands and evaluate the output
community.network.command: community.routeros.command:
commands: commands:
- /system routerboard print - /system routerboard print
- /interface ethernet print - /interface ethernet print

View file

@ -31,16 +31,16 @@ options:
EXAMPLES = """ EXAMPLES = """
- name: Collect all facts from the device - name: Collect all facts from the device
community.network.facts: community.routeros.facts:
gather_subset: all gather_subset: all
- name: Collect only the config and default facts - name: Collect only the config and default facts
community.network.facts: community.routeros.facts:
gather_subset: gather_subset:
- config - config
- name: Do not collect hardware facts - name: Do not collect hardware facts
community.network.facts: community.routeros.facts:
gather_subset: gather_subset:
- "!hardware" - "!hardware"
""" """