Skip to content

Commit 65f1f38

Browse files
Read The Docs via Sphinx (#297)
1 parent edd32b3 commit 65f1f38

File tree

82 files changed

+23438
-208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+23438
-208
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ __pycache__/
44
tests/output/*
55
venv/
66
.vscode/
7+
docs/_build/*
78

89
# https://github.com/ansible/ansible/issues/68499
910
# ansible_collections/

.readthedocs.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
sphinx:
3+
configuration: docs/conf.py
4+
5+
python:
6+
version: 3.6
7+
install:
8+
- requirements: docs/requirements.txt

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ script:
9999
# Sanity tests
100100
# --requirements - install pip packages as necessary
101101
# Skip pep8 as we use black instead
102-
- ansible-test sanity -v --requirements --python $PYTHON_VER --skip-test pep8
102+
- ansible-test sanity -v --requirements --python $PYTHON_VER --skip-test pep8 plugins/
103103

104104
# Unit tests, with code coverage
105105
- ansible-test units -v --coverage --python $PYTHON_VER

README.md

Lines changed: 1 addition & 199 deletions
Original file line numberDiff line numberDiff line change
@@ -16,205 +16,7 @@ To keep the code simple, we only officially support the two latest releases of N
1616
- Ansible 2.9+
1717
- NetBox write-enabled token when using modules or read-only token for `nb_lookup/nb_inventory`
1818

19-
## Existing Modules
20-
21-
- netbox_aggregate
22-
- netbox_cable
23-
- netbox_circuit
24-
- netbox_circuit_termination
25-
- netbox_circuit_type
26-
- netbox_cluster
27-
- netbox_cluster_group
28-
- netbox_cluster_type
29-
- netbox_console_port
30-
- netbox_console_port_template
31-
- netbox_console_server_port
32-
- netbox_console_server_port_template
33-
- netbox_device_bay
34-
- netbox_device_bay_template
35-
- netbox_device_interface
36-
- netbox_device_interface_template
37-
- netbox_device_role
38-
- netbox_device_type
39-
- netbox_device
40-
- netbox_front_port
41-
- netbox_front_port_template
42-
- netbox_inventory_item
43-
- netbox_ip_address
44-
- netbox_ipam_role
45-
- netbox_manufacturer
46-
- netbox_platform
47-
- netbox_power_feed
48-
- netbox_power_outlet
49-
- netbox_power_outlet_template
50-
- netbox_power_panel
51-
- netbox_power_port
52-
- netbox_power_port_template
53-
- netbox_prefix
54-
- netbox_provider
55-
- netbox_rack_group
56-
- netbox_rack_role
57-
- netbox_rack
58-
- netbox_rear_port
59-
- netbox_rear_port_template
60-
- netbox_region
61-
- netbox_rir
62-
- netbox_site
63-
- netbox_service
64-
- netbox_tenant_group
65-
- netbox_tenant
66-
- netbox_virtual_chassis
67-
- netbox_virtual_machine
68-
- netbox_vm_interface
69-
- netbox_vlan_group
70-
- netbox_vlan
71-
- netbox_vrf
72-
73-
## NetBox Plugins
74-
75-
- netbox lookup plugin
76-
- netbox inventory plugin (0.1.5)
77-
78-
## How to Use
79-
80-
- Install via Galaxy
81-
- `ansible-galaxy collection install netbox.netbox`
82-
- Install via source
83-
- `git clone git@github.com:netbox-community/ansible_modules.git`
84-
- `cd ansible_modules`
85-
- `ansible-galaxy collection build .`
86-
- `ansible-galaxy collection install netbox-netbox-X.X.X.tar.gz`
87-
- Can add `-p` to provide a different path other than the default path, but it must be within your `ansible.cfg` or provided via an environment variable.
88-
89-
### Example inventory
90-
91-
```yaml
92-
plugin: netbox.netbox.nb_inventory
93-
api_endpoint: http://netbox-demo.org:32768
94-
token: 0123456789abcdef0123456789abcdef01234567
95-
config_context: True
96-
interfaces: True
97-
group_by:
98-
- device_roles
99-
100-
compose:
101-
ansible_network_os: platform.slug
102-
```
103-
104-
More configuration options and examples can be found [here](plugins/inventory/nb_inventory.py)
105-
106-
### Example playbooks
107-
108-
Using the **collections** at the play level
109-
110-
```yaml
111-
- name: "Test NetBox modules"
112-
connection: local
113-
hosts: localhost
114-
gather_facts: False
115-
collections:
116-
- netbox.netbox
117-
118-
tasks:
119-
- name: Create device within NetBox with only required information
120-
netbox_device:
121-
netbox_url: http://netbox-demo.org:32768
122-
netbox_token: 0123456789abcdef0123456789abcdef01234567
123-
data:
124-
name: Test66
125-
device_type: Cisco Test
126-
device_role: Core Switch
127-
site: Test Site
128-
status: Staged
129-
state: present
130-
```
131-
132-
Using the **collections** at the task level
133-
134-
```yaml
135-
- name: "Test NetBox modules"
136-
connection: local
137-
hosts: localhost
138-
gather_facts: False
139-
140-
tasks:
141-
- name: Create device within NetBox with only required information
142-
netbox.netbox.netbox_device:
143-
netbox_url: http://netbox-demo.org:32768
144-
netbox_token: 0123456789abcdef0123456789abcdef01234567
145-
data:
146-
name: Test66
147-
device_type: Cisco Test
148-
device_role: Core Switch
149-
site: Test Site
150-
status: Staged
151-
state: present
152-
```
153-
154-
Using the **collections** in a role's task files
155-
156-
```yaml
157-
---
158-
- name: Create device within NetBox with only required information
159-
netbox.netbox.netbox_device:
160-
netbox_url: http://netbox-demo.org:32768
161-
netbox_token: 0123456789abcdef0123456789abcdef01234567
162-
data:
163-
name: Test66
164-
device_type: Cisco Test
165-
device_role: Core Switch
166-
site: Test Site
167-
status: Staged
168-
state: present
169-
170-
OR
171-
172-
---
173-
- name: Create device within NetBox with only required information
174-
collections:
175-
- netbox.netbox
176-
netbox_device:
177-
netbox_url: http://netbox-demo.org:32768
178-
netbox_token: 0123456789abcdef0123456789abcdef01234567
179-
data:
180-
name: Test66
181-
device_type: Cisco Test
182-
device_role: Core Switch
183-
site: Test Site
184-
status: Staged
185-
state: present
186-
```
187-
188-
Using the **collections** lookup plugin at the task level
189-
190-
```yaml
191-
- name: "TEST NETBOX_LOOKUP"
192-
connection: local
193-
hosts: localhost
194-
gather_facts: False
195-
collections:
196-
- netbox.netbox
197-
tasks:
198-
- name: "NETBOX_LOOKUP 1: Lookup returns exactly two sites"
199-
assert:
200-
that: "{{ query_result|count }} == 3"
201-
vars:
202-
query_result: "{{ query('netbox.netbox.nb_lookup', 'sites', api_endpoint='http://localhost:32768', token='0123456789abcdef0123456789abcdef01234567') }}"
203-
```
204-
>Note that if you are on MacOS and are running into ```ERROR! A worker was found in a dead state``` errors, try running the playbook with a ```env no_proxy='*'``` tag in front of the playbook. This is a known issue with MacOS as per this reference: https://github.com/ansible/ansible/issues/32554#issuecomment-642896861
205-
206-
### Using **nb_inventory** Within AWX/Tower
207-
208-
This will cover the basic usage of the NetBox inventory plugin within this collection.
209-
210-
1. Define `collections/requirements.yml` within a Git project.
211-
1. AWX/Tower will download the collection on each run. This can be handled differently or excluded if storing Ansible Collections on the AWX/Tower box.
212-
2. Define `inventory.yml` in Git project that adheres to inventory plugin structure.
213-
2. Add Git project to AWX/Tower as a project.
214-
3. Create inventory and select `source from project`.
215-
1. Select the AWX/Tower project from Step 2
216-
2. Select the `inventory.yml` file in the project from Step 1.1
217-
3. Click `Save` and sync source.
19+
We have a new docs site live that can be found [here](https://netbox-ansible-collection.readthedocs.io/en/latest/)
21820

21921
## How to Contribute
22022

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

0 commit comments

Comments
 (0)