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-crucible

v0.4.0

Published

Crucible is a tool for writing Ansible Playbooks as Javascript or Typescript Code. Ansible as Code, as it were.

Downloads

2

Readme

Crucible for Ansible

Crucible is a tool for writing Ansible Playbooks as Javascript or Typescript Code. Ansible as Code, as it were.

Features Overview:

  • Run Ansible Tasks and Plays with Javascript/Typescript
  • Simple, in-line secret editing
  • Include complex logic in your Plays

Background

I'm a software engineer. I write code. I've been using Ansible for a while now to manage my home lab and make life easier when I have to rebuild servers or VMs. I recently extended from just using Ansible to using Pulumi as well for handling VM creation and management. Pulumi is similar to Terraform, but instead of a custom configuration language (HCL in the case of Terraform), Pulumi lets you define your Infrastructure using an actual programming language. This provides me with immense flexibility and I can use all the power of a programming language (for loops, if/else logic, etc.) to define my infrastructure. It's awesome.

Well, I wanted to be able to apply the same power and flexibility to my Ansible setup. I've run into many cases in Ansible where it would be so nice to just use an if or for statement without trying to figure out the logic and limitations of Ansible's when:, with_items:, etc.

So, I decided to see what I could make, and Crucible was born.

Installation

> yarn install ansible-crucible

Usage

Creating a new Crucible project

> crucible init <project name>

This will create a new crucible project in the current directory, with a sample program, the necessary config files, and an appropriate .gitignore.

Managing Secrets

> crucible vault create <vault name> # Start a wizard to define a new vault

Once a vault is defined, you can include secrets in your code files like so:

import { secret } from 'ansible-crucible';
const some_secret = secret('vault_name', { foo: 'bar' }) // The secret value may be any JSON-serializable value

You can also encrypt parts of non-code files like so:

some:
  value:
    - CRUCIBLE_SECRET(vault_name, secret)

Or encrypt the whole file by adding a first line (any comment format will work - Crucible just looks for the presence of CRUCIBLE_ENCRYPT_FILE on the first line of the file):

# CRUCIBLE_ENCRYPT_FILE(vault_name)

After adding some secrets, encrypt them all in-place:

> crucible vault encrypt [file] # Encrypt all of the secrets in the project or in a given file

To decrypt, you can:

> crucible vault decrypt [file] # Decrypt all of the secrets in the project or in a given file

Or:

> crucible vault edit <file> # Decrypt, open, and re-encrypt the given file

If you're using Git, Crucible will configure a pre-commit hook that will attempt to catch non-encrypted secrets.

NB: By default, the all-file versions of the vault commands will only include files of types .js, .ts, .json, .yml, .yaml, .conf, .cnf, .cf, .ini. This can be changed via the secrets.file_types config parameter. The Git pre-commit hook will check all staged files - not just those of these types.

Licensing

This project is still in it's infancy and I'm unsure of where it will go for me - whether it will continue to just be a side/fun project, or if it has the ability to pay for some of the time that I've spent on it. I'm a lover of Open Source and feel that it can have great use amongst nerds and homelabbers like me, so I wanted to share it as soon as I could. However, for now, I'm reserving my rights when it comes to commercial use, and have defined the below guidelines (which may admittedly change in either direction, so fair warning there). If you're interested in using this tool commercially, I'd love to hear about your use case and am willing negotiate licensing.

  • Personal Use is fully permitted
  • Commercial Use:
    • May be used by companies of fewer than 3 developers/engineers in the following cases:
      • May be used for internal projects
      • May be used to deploy a customer facing product
    • May not be used with customers (eg where a company manages automation/deployment/systems for another company)
    • May not be used in any production systems or workflows by companies with greater than 3 developers/engineers
    • Forks are permitted, but copy-left is required
    • Contact author to negotiate otherwise