npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ansible-dynamic-inventory

v1.0.1

Published

Ansible Dynamic Inventory Script for LXD Containers

Downloads

10

Readme

pageresBuild Status

Ansible LXDynamic Inventory (with NodeJS)

A dynamic inventory script for use with Ansible and LXD Containers and written in node.js.

I did find one other dynamic inventory script for LXD, however it did not meet my needs. Some requirements which are met by this script are:

  • Utilizes the LXD REST API throughout starting at the Ansible host.
  • Groups can be dynamically configured based on meta variables set on the containers.

And I chose NodeJS because I like JavaScript.

Install

$ npm install --save

This will simply copy the precompiled lxd.nex script, along with lxd.ini into your inventory directory. Then update your inventory file and add any LXD hosts using the lxd connector as in ubuntu-adi-test-lxdserver ansible_connection=lxd.

You should then be able to issue a playbook or other applicable ansible command to any LXD containers configured on that LXD host! Code Editor Screenshot lxd.ini

Building from source

$ npm build

Will compile the lxd.js script into a self contained executable lxd.nex which can be used without requiring installation of node dependancies.

Although the actual build of the lxd.js script should work anywhere (that node would work), the npm install from source only supports Ubuntu and has been tested on both Trusty (Travis-ci) and Xenial. Basically the tests involve creating a test LXD server which in turn creates several nested test containers, afterwhich the script can be used on the aforementioned test environment.

a bit more detail...

Since authentication for the LXD API is done through client certificate authentication, this script will automatically generate a client certificate. You will want to change the lxd.ini file to reflect your own SSL cert details:

Code Editor Screenshot lxd.ini

The certifcate will be stored in ~/.ansible/tmp/ssl or whatever location you have configured for remote_tmp in your ansible.cfg file.

Dynamic Groups

The script will check the LXD container configuration value user.ansible.group in order to determine group placement within the Ansible Inventory. Container configs can be set when creating containers by using the lxc command line as follows:

lxc config set <container> <key> <value>

thus to have this script dynamically group your containers into say 3 different groups named "testgroup1", "anygroupname2", and "group3", you would use the following commands to set the config values on the applicable containers:

lxc config set container1 user.ansible.group testgroup1
lxc config set container2 user.ansible.group testgroup1
lxc config set black user.ansible.group anygroupname2
lxc config set white user.ansible.group anygroupname2
lxc config set yello user.ansible.group anygroupname2
lxc config set miosotis user.ansible.group group3
lxc config set abbi user.ansible.group group3
lxc config set twgirl user.ansible.group group3
lxc config set Liliana user.ansible.group group3

or by other APIs such as the LXD REST API More on available APIs here https://linuxcontainers.org/lxd/rest-api. Groups not configured with a value for user.ansible.group would simply be ungrouped in the Ansible inventory.

License

MIT B) June07