updated netboxinventory state
This commit is contained in:
parent
6b4126f8d2
commit
d5b1ed53ce
@ -1,31 +1,61 @@
|
|||||||
---
|
---
|
||||||
{%- from "netboxinventory/map.jinja" import netbox with context %}
|
{%- from "netboxinventory/map.jinja" import netbox with context %}
|
||||||
netboxinventory_dependencies:
|
netboxinventory-dependencies:
|
||||||
pip.installed:
|
pip.installed:
|
||||||
- name: pynetbox
|
- name: pynetbox
|
||||||
|
|
||||||
{%- if salt['netbox.get'](app='dcim', endpoint='sites', name=salt['grains.get']('location')) == {} %}
|
{% set nodename = salt['grains.get']('nodename') %}
|
||||||
netbox.create_site_{{ salt['grains.get']('location') }}:
|
{% set location = salt['grains.get']('location') %}
|
||||||
|
{% set type = salt['grains.get']('type') %}
|
||||||
|
{% set manufacturer = salt['smbios.get']('system-manufacturer') %}
|
||||||
|
{% set model = salt['smbios.get']('system-product-name') %}
|
||||||
|
|
||||||
|
{%- if salt['netbox.get'](app='dcim', endpoint='manufacturers', name=manufacturer) == {} %}
|
||||||
|
netbox.create_manufacturer_{{ manufacturer|md5 }}:
|
||||||
module.run:
|
module.run:
|
||||||
- name: netbox.create_site
|
- name: netbox.create_manufacturer
|
||||||
- site: {{ salt['grains.get']('location') }}
|
- m_name: "{{ manufacturer }}"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{%- if salt['netbox.get'](app='dcim', endpoint='device-roles', name=salt['grains.get']('type')) == {} %}
|
{%- if salt['netbox.get'](app='dcim', endpoint='device-types', model=model) == {} %}
|
||||||
netbox.create_device_role_{{ salt['grains.get']('type') }}:
|
netbox.create_device_type_{{ model|md5 }}:
|
||||||
|
module.run:
|
||||||
|
- name: netbox.create_device_type
|
||||||
|
- model: "{{ model }}"
|
||||||
|
- manufacturer: "{{ manufacturer }}"
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if salt['netbox.get'](app='dcim', endpoint='sites', name=location) == {} %}
|
||||||
|
netbox.create_site_{{ salt['grains.get']('location')|md5 }}:
|
||||||
|
module.run:
|
||||||
|
- name: netbox.create_site
|
||||||
|
- site: "{{ location }}"
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
{%- if salt['netbox.get'](app='dcim', endpoint='device-roles', name=type) == {} %}
|
||||||
|
netbox.create_device_role_{{ type|md5 }}:
|
||||||
module.run:
|
module.run:
|
||||||
- name: netbox.create_device_role
|
- name: netbox.create_device_role
|
||||||
- role: {{ salt['grains.get']('type') }}
|
- role: "{{ type }}"
|
||||||
- color: "2196f3"
|
- color: "2196f3"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{%- if salt['netbox.get'](app='dcim', endpoint='devices', name=salt['grains.get']('nodename')) == {} %}
|
{%- if salt['netbox.get'](app='dcim', endpoint='devices', name=nodename) == {} %}
|
||||||
netbox.create_device_{{ salt['grains.get']('nodename')|to_camelcase }}:
|
netbox.create_device_{{ nodename|md5 }}:
|
||||||
module.run:
|
module.run:
|
||||||
- name: netbox.create_device
|
- name: netbox.create_device
|
||||||
- m_name: {{ salt['grains.get']('nodename') }}
|
- m_name: "{{ nodename }}"
|
||||||
- site: {{ salt['grains.get']('location') }}
|
- site: "{{ location }}"
|
||||||
- role: {{ salt['grains.get']('type') }}
|
- role: "{{ type }}"
|
||||||
- manufacturer: default
|
- manufacturer: "{{ manufacturer }}"
|
||||||
- model: default
|
- model: "{{ model }}"
|
||||||
{%- endif %}
|
{%- else %}
|
||||||
|
netbox.update_device_{{ nodename|md5 }}:
|
||||||
|
module.run:
|
||||||
|
- name: netbox.update_device
|
||||||
|
- m_name: "{{ nodename }}"
|
||||||
|
- site: "{{ location }}"
|
||||||
|
- role: "{{ type }}"
|
||||||
|
- manufacturer: "{{ manufacturer }}"
|
||||||
|
- model: "{{ model }}"
|
||||||
|
{%- endif %}
|
||||||
|
Loading…
Reference in New Issue
Block a user