Code Monkey home page Code Monkey logo

ozy's Introduction

CI

ozy

ozy is a Rust program that makes it easy for you and your team to share and collaborate using commonly used programs such as vault, nomad, or conda on Linux.

Getting Started

ozy takes a configuration URL as a parameter - this is specific to your team and controls which applications are supported and at which versions.

To demonstrate ozy, we'll be using the sample configuration served directly from GitHub, along with the latest ozy binary built in releases. The sample config supports some of the Hashicorp apps, and some other simple apps. There's a convenience single-step installer for this, suitable for piping directly into bash:

curl -sL https://raw.githubusercontent.com/aquanauts/ozy/main/conf/install.sh | bash

Behind the scenes this fetches a released ozy binary and executes ozy init https://path/to/this/github/conf/sample-team-conf.yaml.

This will cause ozy to be installed in ~/.ozy. In this directory there are some ozy.*.yaml files, and a bin directory. As part of the installation ozy will check and tell you how to put ~/.ozy/bin into your path. It will place magic symlinks there that let it masquerade as all the applications it can install.

To see what the installer is doing see ozy init - but in short it is configuring itself from an Aquatic-specific endpoint.

Running a command

Assume that your installation has been configured to support Hashicorp's nomad. One simply runs the nomad command:

nomad --version
Installing nomad 0.9.4
100%|************************| 26.8M/26.8M [00:07<00:00, 3.55MiB/s]
Nomad v0.9.4 (a81aa846a45fb8248551b12616287cb57c418cd6)

ozy will notice that nomad is not installed, and will go grab it based on the ~/.ozy/ozy.yaml configuration file. Note, you can override the version -- for example, if you want to run a later version of nomad -- see the pinning versions section below. Additionally you can use ozy run to specify a specific version for a one-off execution.

Getting info on supported commands

$ ozy info
ozy v0.0.1
Team URL: http://localhost:8000/sample-team-conf.yaml
Team config name: Aquatic Team Configuration
  nomad: nomad 0.9.5 (zip installer from https://releases.hashicorp.com/nomad/0.9.5/nomad_0.9.5_linux_amd64.zip)
  vault: vault 1.2.3 (zip installer from https://releases.hashicorp.com/vault/1.2.3/vault_1.2.3_linux_amd64.zip)
  terraform: terraform 0.12.13 (zip installer from https://releases.hashicorp.com/terraform/0.12.13/terraform_0.12.13_linux_amd64.zip)

Updating

Assuming the config on the remote url has changed to a new version of nomad:

$ ozy update
100%|************************| 3.86k/3.86k [00:00<00:00, 17.3MiB/s]
Upgrading nomad from 0.9.3 to 0.9.4
Upgrading vault from 1.2.2 to 1.2.3

This will cause ozy to re-fetch your team's ozy config url, and note the updates.

$ ozy update --dry-run
100%|************************| 3.86k/3.86k [00:00<00:00, 17.3MiB/s]
Would upgrade nomad from 0.9.3 to 0.9.4
Would upgrade vault from 1.2.2 to 1.2.3
Dry run only - no changes made

Eagerly installing all versions

If you're the kind of person who would prefer a fail-fast; or you're going to be working offline for a bit, then you can ensure all the current versions of supported applications are installed:

$ ozy install-all
Installing nomad 0.9.4
...

Initializing

If you need to completely re-initialize, or are wondering what happens behind the scenes when you first install ozy, then this is the place for you. The ozy init command takes a URL and uses that to fetch the ~/.ozy/ozy.yaml for your team. It also remembers that URL (in ~/.ozy/ozy.user.yaml) so that subsequent updates fetch from there too.

$ ozy init https://some.ozy.server.net/ozy.yaml
ozy is installed and is ready to run

Pinning Versions

Individual projects can choose to pin versions of apps by creating a .ozy.yaml file in the directory that they are in. When you run ozy in that directory, ozy will use the versions listed in that file in preference to the system wide ozy found in ~/.ozy/ozy.yaml

For example, assuming you are in some directory and ozy is in your PATH:

$ echo "apps:
  nomad:
    version: 0.10.0" > .ozy.yaml 
$ nomad --version
Installing nomad 0.10.0
100%|************************| 33.0M/33.0M [00:08<00:00, 3.85MiB/s]
Nomad v0.10.0 (25ee121d951939504376c70bf8d7950c1ddb6a82)

Directories are walked up from the current directory, looking for ~/.ozy.yaml files. Settings are applied from the combination of all configuration files found, with the most deeply-nested yaml file settings taking precedence.

Running a command through ozy

You can directly run a command through ozy:

$ ozy run nomad -- --help
Usage: nomad [-version] [-help] [-autocomplete-(un)install] <command> [args]

Common commands:
...

You can also specify a specific version:

$ ozy run nomad --version 0.9.1 -- --version
Installing nomad 0.9.1
100%|************************| 25.4M/25.4M [00:00<00:00, 73.7MiB/s]
Nomad v0.9.1 (4b2bdbd9ab68a27b10c2ee781cceaaf62e114399)

Removing a command

TODO: this

$ ozy rm nomad

The real nomad lives in ~/.cache/ozy/nomad/0.9.4/nomad. The symlink in ~/.ozy/bin/nomad points to ozy. rm will remove the symlink, which is as good as deleting the executable.

Full cleanup

TODO: this

$ ozy clean

This will remove ~/.cache/ozy!

Writing your own ozy.yaml

TODO

Making a release

To make a release of ozy:

  • Update the __version__ in ozy/__init__.py
  • Ensure the RELEASE_NOTES.md are updated
  • Push the changes to GitHub
  • Create a tag of the form v1.2.3 and push it to GitHub
  • GH actions will make the binaries automatically
  • Go to https://github.com/aquanauts/ozy/releases and check everything's ok
  • Update the release description and make non-draft if all's ok

ozy's People

Contributors

mattgodbolt avatar yeetfield avatar apmorton avatar cread avatar benrady-aq avatar dependabot[bot] avatar lhayhurst avatar kpweiler avatar dgroo avatar aq-kevin-weiler avatar

Stargazers

t avatar  avatar Akshay U Hegde avatar Nissi Nassime avatar Jonathan Basseri avatar Rupert Tombs avatar gc-ss avatar Jonathan Yu avatar Andy Mroczkowski avatar  avatar Bharat Gupta avatar  avatar  avatar Coleman Rollins avatar

Watchers

 avatar  avatar  avatar James Cloos avatar

ozy's Issues

After initial install under OSX ozy is a little confused

cread@cread-mac:~$ shellcheck -V
Installing shellcheck 0.7.0
100%|██████████████████████████████████████████████████████████████████████████████████████████████| 1.50M/1.50M [00:00<00:00, 12.7MiB/s]
ShellCheck - shell script analysis tool
version: 0.7.0
license: GNU General Public License, version 3
website: https://www.shellcheck.net
cread@cread-mac:~$ Usage: ozy [OPTIONS] COMMAND [ARGS]...
Try 'ozy --help' for help.

Error: no such option: -B

There is a second or two lag from the exec returning to us getting the ozy usage error, so it's either something with my current shell (GNU bash, version 5.0.18(1)-release (x86_64-apple-darwin19.5.0)), but more likely it's something in the initial install process as subsequent invocations work correctly.

ozy invocations can leave pyinstaller files in /tmp

I've noticed a lot of /tmp/_MEIxxxxx files in my /tmp and I think it's because pyinstaller installs there. If ozy fails, or maybe in other situations (we exec a new process, so maybe that?) we get junk left in /tmp.

Quite a strong argument to move away from python and/or pyinstaller.

Confusing version number

When installing an app:

Running tarball installer for ccache v.4.8

the version here is 4.8 not .4.8 or v.4.8 - the extra period confuses me at least. ccache 4.8 or ccache version 4.8 or even ccache v4.8 but not v.4.8 make sense to me.

Race during ozy update can leave non-executable ozy binary installed

ozy/rozy/src/main.rs

Lines 270 to 277 in fa7c733

let dest_path = files::get_ozy_bin_dir()?.join("ozy.tmp");
files::delete_if_exists(&dest_path)?;
utils::download_to(&dest_path, download_url)?;
let mut perms = std::fs::metadata(&dest_path)?.permissions();
perms.set_mode(0o755);
std::fs::set_permissions(&dest_path, perms)?;
let err = exec::execvp(&dest_path, std::env::args().collect::<Vec<String>>());

If multiple processes decide to update you can end up with one process blowing away ozy.tmp and redownloading it while the other is execv'ing the new version.

If you get very unlucky this can cause a non-chmodded file to be placed in ~/.ozy/bin/ozy, breaking ozy.

Fake filesystems confuse `ozy`

In one use case we have some stuff in an automounter directory. ozy will see its .ozy.yaml as a "directory":

machine:~/d/t/o/env $ pwd
Error: While loading ozy config

Caused by:
    0: Reading config YAML
    1: Is a directory (os error 21)
/home/mgodbolt/dev/project/out/env

Maybe we should ignore .ozy.yaml type things that seem to be bogus as we walk up the directory structure?

Install fails if `/tmp` is on a different drive

1651406 rename("/tmp/install-ozy-1651396/ozy", "/home/matthew/.ozy/bin/ozy") = -1 EXDEV (Invalid cross-device link)

from:

$ env OZY_VERSION=0.1.8 strace -o/tmp/asd -f bash /tmp/fas
Installing ozy pointing at the ozy sample team configuration on GitHub...
Using 0.1.8 as it was set in the environment
Installing ozy v0.1.8 for Linux-x86_64
Error: Cross-device link (os error 18)

Unify subprocess creation within the installation context

Several installers create subprocesses as part of their installation process. These subprocesses should all

  • not inherit their parent's stdin
  • redirect stdout to parent's stderr
  • inherit parent's stdout
  • have the Ozy bin directory on their path

We should explicitly refactor this desired common logic out

ozy makefile-config must ensure installers don't output to STDOUT

$ ozy makefile-config OZY_BIN_DIR conda > /tmp/moose
Installing conda 4.7.12
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 70.5M/70.5M [00:00<00:00, 110MiB/s]
Please run using "bash" or "sh", but not "." or "source"\n/tmp/tmplznsgq9m: line 13: return: can only `return' from a function or sourced script

Example install script is broken

I tried fixing but got as far as:

#!/usr/bin/env bash
# Should be suitable to be `curl | bash`'d

set -euo pipefail

echo Installing ozy pointing at the ozy sample team configuration on GitHub...

OZY_CONFIG_URL=https://raw.githubusercontent.com/aquanauts/ozy/main/conf/sample-team-conf.yaml
OZY_OS=$(uname)
OZY_ARCH=$(uname -p)
#OZY_VERSION=$(curl -sL ${OZY_CONFIG_URL} | grep 'ozy_version:' | awk '{print $2}')
OZY_VERSION=0.1.8

echo Installing ozy v${OZY_VERSION} for ${OZY_OS}-${OZY_ARCH}

TMP_INSTALL_FILE="$(mktemp)"
curl -sL -o "${TMP_INSTALL_FILE}" https://github.com/aquanauts/ozy/releases/download/v${OZY_VERSION}/ozy-${OZY_OS}-${OZY_ARCH}
chmod +x "${TMP_INSTALL_FILE}"
${TMP_INSTALL_FILE} init ${OZY_CONFIG_URL}
rm -f "${TMP_INSTALL_FILE}"

echo
echo '********************************'
echo 'Installed ok. Make sure you follow any instructions above to ensure ozy is on your path.'
echo '********************************'

added the OS and ARCH properly, hacking it to 0.1.8 but still:

Installing ozy pointing at the ozy sample team configuration on GitHub...
Installing ozy v0.1.8 for Linux-x86_64
Error: While loading ozy config

Caused by:
    0: Reading config YAML
    1: No such file or directory (os error 2)

In fact, any attemp to execute the ozy cases this:

bollo:~/d/c/ce-ci (main|✚1) $ /tmp/tmp.CYWrZW95Nt --help
Error: While loading ozy config

Caused by:
    0: Reading config YAML
    1: No such file or directory (os error 2)

Add support for sha256

New feature: presently the sample team config has entries for sha256, sha256_signature, and sha256_gpg_key. These aren't being checked by the installers, so if a file has been corrupted or tampered with ozy will not know.

Add a feature to verify the sha256.

Consider using `~/.local/bin` in addition to (or instead of) `~/.ozy/bin`

~/.local/bin is defined as part of the systemd file-hierarchy

Any distro that uses systemd (or makes an attempt to be compatible with systemd conventions) will recognize this directory and place it on the users path upon login if it exists.

Note that this path is not guaranteed to exist, so you may need to create it upon first use.
On a similar note, this path will not appear on $PATH if it does not exist, so you may need login-cycle after creating it.

Using ~/.local/bin decreases $PATH bloat, but it also means you may conflict with binaries placed by others.
These potential conflicts already existed in the logical sense that weird and unexpected things may happen depending on order within $PATH, but now they become "that file already existed" issues when placing symlinks.

Installing new apps in a pipeline confuses downstream

e.g.


$ app1 | jq -C .

where app1 is controlled by ozy, if app1 has to install and installation generates stdout, then jq is confused and the whole thing goes wrong.

Perhaps we need to redirect all output to stderr during installation? (Happened during a conda package install).

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.