paulbsd-salt/states/netboxinventory/init.sls
2021-08-19 21:15:24 +02:00

31 lines
1.1 KiB
Plaintext

---
{%- from "netboxinventory/map.jinja" import netbox with context %}
netboxinventory_dependencies:
pip.installed:
- name: pynetbox
{%- if salt['netbox.get'](app='dcim', endpoint='sites', name=salt['grains.get']('location')) == {} %}
netbox.create_site_{{ salt['grains.get']('location') }}:
module.run:
- name: netbox.create_site
- site: {{ salt['grains.get']('location') }}
{%- endif %}
{%- if salt['netbox.get'](app='dcim', endpoint='device-roles', name=salt['grains.get']('type')) == {} %}
netbox.create_device_role_{{ salt['grains.get']('type') }}:
module.run:
- name: netbox.create_device_role
- role: {{ salt['grains.get']('type') }}
- color: "2196f3"
{%- endif %}
{%- if salt['netbox.get'](app='dcim', endpoint='devices', name=salt['grains.get']('nodename')) == {} %}
netbox.create_device_{{ salt['grains.get']('nodename')|to_camelcase }}:
module.run:
- name: netbox.create_device
- m_name: {{ salt['grains.get']('nodename') }}
- site: {{ salt['grains.get']('location') }}
- role: {{ salt['grains.get']('type') }}
- manufacturer: default
- model: default
{%- endif %}