Skip to content

Commit 07274c7

Browse files
committed
device_type data provided as volume mount
1 parent c3166ad commit 07274c7

File tree

7 files changed

+104
-0
lines changed

7 files changed

+104
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
3+
- name: Create device type console port templates
4+
networktocode.nautobot.console_port_template:
5+
url: "{{ nautobot_url }}"
6+
token: "{{ nautobot_token }}"
7+
device_type: "{{ device_type_item.model }}"
8+
name: "{{ console_port_item.name }}"
9+
type: "{{ console_port_item.type }}"
10+
state: present
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
- name: Create default device types
3+
networktocode.nautobot.device_type:
4+
url: "{{ nautobot_url }}"
5+
token: "{{ nautobot_token }}"
6+
model: "{{ device_type_item.model }}"
7+
manufacturer: "{{ device_type_item.manufacturer }}"
8+
u_height: "{{ device_type_item.u_height }}"
9+
is_full_depth: "{{ device_type_item.is_full_depth }}"
10+
part_number: "{{ device_type_item.part_number | default('') }}"
11+
comments: "{{ device_type_item.comments | default('') }}"
12+
subdevice_role: "parent" # need to set subdevice_role=parent to allow device bays to be attached
13+
state: present
14+
15+
- name: Loop through interfaces and add them
16+
ansible.builtin.include_tasks: interfaces.yml
17+
loop: "{{ device_type_item.interfaces | default('[]') }}"
18+
loop_control:
19+
loop_var: interface_item
20+
21+
- name: Loop through console ports and add them
22+
ansible.builtin.include_tasks: console_ports.yml
23+
loop: "{{ device_type_item['console-ports'] | default('[]') }}"
24+
loop_control:
25+
loop_var: console_port_item
26+
27+
- name: Loop through module bays and add them
28+
ansible.builtin.include_tasks: module_bays.yml
29+
loop: "{{ device_type_item['module-bays'] | default('[]') }}"
30+
loop_control:
31+
loop_var: module_bay_item
32+
33+
- name: Loop through power ports and add them
34+
ansible.builtin.include_tasks: power_ports.yml
35+
loop: "{{ device_type_item['power-ports'] | default('[]') }}"
36+
loop_control:
37+
loop_var: power_port_item
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
3+
- name: Create device type interface templates
4+
networktocode.nautobot.device_interface_template:
5+
url: "{{ nautobot_url }}"
6+
token: "{{ nautobot_token }}"
7+
device_type: "{{ device_type_item.model }}"
8+
name: "{{ interface_item.name }}"
9+
type: "{{ interface_item.type }}"
10+
mgmt_only: "{{ interface_item.mgmt_only | default('false') }}"
11+
state: present
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
# Device Types repo: https://github.com/RSS-Engineering/undercloud-nautobot-device-types
3+
4+
- name: Collect device types from undercloud-nautobot-device-types repo
5+
ansible.builtin.set_fact:
6+
device_types_data: "{{ device_types_data | d([]) + [lookup('file', item.src) | from_yaml] }}"
7+
with_community.general.filetree: "/repo/device-types/"
8+
when: item.state == "file"
9+
check_mode: false
10+
11+
- name: Sync manufacturers
12+
networktocode.nautobot.manufacturer:
13+
url: "{{ nautobot_url }}"
14+
token: "{{ nautobot_token }}"
15+
name: "{{ item }}"
16+
description: "{{ item }}"
17+
state: present
18+
loop: "{{ device_types_data | community.general.json_query('[*].manufacturer') | unique }}"
19+
20+
- name: Loop through device types
21+
ansible.builtin.include_tasks: device_types.yml
22+
loop: "{{ device_types_data }}"
23+
loop_control:
24+
loop_var: device_type_item
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
3+
- name: Create device type module bay templates
4+
networktocode.nautobot.device_bay_template:
5+
url: "{{ nautobot_url }}"
6+
token: "{{ nautobot_token }}"
7+
device_type: "{{ device_type_item.model }}"
8+
name: "{{ module_bay_item.name }}"
9+
state: present
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
3+
- name: Create device type power port templates
4+
networktocode.nautobot.power_port_template:
5+
url: "{{ nautobot_url }}"
6+
token: "{{ nautobot_token }}"
7+
device_type: "{{ device_type_item.model }}"
8+
name: "{{ power_port_item.name }}"
9+
allocated_draw: "{{ power_port_item.allocated_draw | default(1) }}"
10+
maximum_draw: "{{ power_port_item.maximum_draw | default(1) }}"
11+
type: "{{ power_port_item.type }}"
12+
state: present

components/nautobot/kustomization.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ resources:
66
- cloudnative-postgres-nautobot.yaml
77
- secretstore-nautobot.yaml
88
- external-secret-nautobot-sso.yaml
9+
- device-sync-job.yaml
910

1011
configMapGenerator:
1112
- name: nautobot-sso

0 commit comments

Comments
 (0)