Snippets Collections
- name: Create interfaces
  delegate_to: localhost
  when: ansible_facts[item].speed is defined and not 'lo' == item
  netbox.netbox.netbox_device_interface:
    netbox_url: "{{ netbox_url }}"
    netbox_token: "{{ netbox_token }}"
    data:
      device: "{{ inventory_hostname }}"
      name: "{{ item }}"
      type: "{{ speed_to_iftype[ ansible_facts[item].speed ] }}"
    state: present
  loop: "{{ ansible_interfaces }}"

- name: Create IP address
  delegate_to: localhost
  when: ansible_facts[item].ipv4.address is defined and not 'lo' == item
  netbox.netbox.netbox_ip_address:
    netbox_url: "{{ netbox_url }}"
    netbox_token: "{{ netbox_token }}"
    data:
      address: "{{ ansible_facts[item].ipv4.address }}/{{ vars.ansible_facts[item].ipv4.netmask }}"
      status: Active
      dns_name: "{{ lookup('community.general.dig', ansible_facts[item].ipv4.address+'/PTR', '@ns.our.internal') | regex_replace('\\.$', '') }}"
      assigned_object:
        name: "{{ item }}"
        device: "{{ inventory_hostname }}"
    state: present
  loop: "{{ ansible_interfaces }}"
#!/usr/bin/env bash

set -e

# Dotfiles' project root directory
ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Host file location
HOSTS="$ROOTDIR/hosts"
# Main playbook
PLAYBOOK="$ROOTDIR/dotfiles.yml"

# Installs ansible
apt-get update && apt-get install -y ansible

# Runs Ansible playbook using our user.
ansible-playbook -i "$HOSTS" "$PLAYBOOK" --ask-become-pass

exit 0
star

Mon Jul 04 2022 05:54:40 GMT+0000 (UTC)

#netbox #ansible
star

Wed Mar 03 2021 04:09:21 GMT+0000 (UTC) https://thebroken.link/managing-dotfiles-with-ansible/

#bash #ansible

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension