-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_interface.yml
51 lines (46 loc) · 2.03 KB
/
create_interface.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# ======= How to run standalone:
# boburciu@WX-5CG020BDT2: ~$ cd ~/netbox-ansible-automation
# boburciu@WX-5CG020BDT2:~/netbox-ansible-automation$ ansible-playbook -i ./hosts -v create_interface.yml -e 'interface_description="Management port"'
# boburciu@WX-5CG020BDT2:~/netbox-ansible-automation$ ansible-playbook -i ./hosts -v create_interface.yml -e 'interface_name="10GE1/0/1" interface_device="SWH-TOR-R1-1" external_vars="./external_vars.yml" ansible_python_interpreter="/usr/bin/python3"'
- name: Create interface
connection: local
hosts: docker_netbox_19216820023
gather_facts: False
collections:
- netbox.netbox
tasks:
# - include_vars: external_vars.yml
- include_vars: '{{external_vars}}'
- name: Create interface
netbox_device_interface:
netbox_url: '{{ url_var }}'
netbox_token: '{{ token_var }}'
data:
device: '{{ interface_device }}'
name: '{{ interface_name }}'
type: '{{ interface_type }}' # mandatory param
state: present
- name: Create interface with all data - when info is available via NAPALM call
netbox_device_interface:
netbox_url: '{{ url_var }}'
netbox_token: '{{ token_var }}'
data:
device: '{{ interface_device }}'
name: '{{ interface_name }}'
mac_address: '{{ interface_mac_address }}'
enabled: '{{ interface_enabled }}'
type: '{{ interface_type }}'
mtu: '{{ interface_mtu }}'
mgmt_only: '{{ interface_mgmt_only }}'
description: '{{ interface_description }}'
state: present
when: interface_mac_address is defined
# - name: Obtain all interfaces
# debug:
# msg: '{{ item }}'
# # debug:
# # msg: >
# # "{{ item.value.name }}"
# loop: "{{ query('netbox.netbox.nb_lookup', 'interfaces',
# api_endpoint=url_var,
# token=token_var) }}"