Code Monkey home page Code Monkey logo

puppet-netstdlib's Introduction

##Overview Build Status

netstdlib is a collection of puppet functions and facts for network related work.

These functions and facts are very handy when using puppet to do complex logic on code that deals with configuring or interpreting network interfaces.

Most of them simply expose the native ruby implementations into the puppet manifest so you can use them to say, edit OpenStack config files, or manipulate DCHP server pools.

Examples

# Use macaddress_rand instead of FQDNs because we have lots of VMs with
# the same hostname
cron::d { 'puppet_agent':
  ensure  => $ensure,
  minute  => macaddress_rand(60),
  user    => 'root',
  command => 'puppet agent -t >/dev/null 2>&1',
}
# Have the puppet server query DNS to get the current round-robin A records
$web_server_ips_array = gethostbyname2array("webs.yourdomain.com")
validate_array($web_server_ips_array)
# Reverse Lookup your ip to a name:
$my_name = gethostbyaddr2array($::ipaddress)
notify { "My reverse dns seems to be: ${my_name}": }

##Functions

cidr_to_broadcast

Converts an CIDR address of the form 192.168.0.1/24 into its broadcast address

cidr_to_netmask

Converts an CIDR address of the form 192.168.0.1/24 into its netmask address

cidr_to_network

Converts an CIDR address of the form 192.168.0.1/24 into its network address

fqdn_mac

Generate MAC addresses based on the results of fqdn_rand. Useful for VMs that might have the same hostname.

gethostbyaddr2array

Resolve an IP address into one or more names. (Looks up reverse DNS PTRs)

gethostbyname2array

Resolve a name into one or more IP addresses.

int_to_ip

Converts an IP in its 32 bit integer representation to a dotted address of the form 192.168.0.1

ip_in_cidr

Checks if an ip address is contained within a CIDR address of the form 192.168.0.1/24

ip_to_int

Converts a dotted address of the form 192.168.0.1 into its 32 bit integer representation

mac_to_eui64

Converts a MAC address of the form 52:54:00:12:09:f3 into its EUI64 representation of the form 5054:00ff:fe12:09f3

netmask_to_masklen

Converts a netmask of the form 255.255.0.0 to the mask length (e.g. 16)

##Limitations

Puppet functions are server-side, facts are client side. Keep this in mind as any DNS related functions will take place on the server.

puppet-netstdlib's People

Contributors

solarkennedy avatar bobtfish avatar evankrall avatar tisoft avatar pauloconnor avatar

Watchers

Andreas Unterkircher avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.