Skip to content

Nix expression to build Bash script and container to connect to servers via IPMI

Notifications You must be signed in to change notification settings

kitnil/nix-docker-ipmi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nix IPMI

This project provides a Nix expression to build Bash script to connect to servers with IPMI support.

Prerequisites

Before you begin, ensure you have met the following requirements:

  • You have installed either Nix, NixOS, Docker
  • You received IPMI credentials

Installing Nix IPMI

To install IPMI Sciprt, follow these steps:

With Docker installed

Build the container with Nix:

nix-build --no-out-link

Then import the container and look launch command:

sudo docker load /nix/store/….tar.gz
sudo docker inspect docker-registry.intr/utils/nix-ipmi:master | grep cmd

make sure xhost is installed on your system and run the container, e.g.:

xhost +local:

docker run --rm --network=host --tty --interactive --user 1000:997                       \
       --env DISPLAY=$DISPLAY --volume /etc/localtime:/etc/localtime:ro                  \
       --volume /tmp/.X11-unix:/tmp/.X11-unix docker-registry.intr/utils/nix-ipmi:master \
       jenkins.ipmi IPMI_PASSWORD

NOTE: Replace IPMI_PASSWORD.

With Nix installed

Add an overlay as you prefer, for example:

with import <nixpkgs> {
  overlays = [
    (self: super: {
      ipmi = (super.callPackage (builtins.fetchGit {
        url = "https://gitlab.intr/utils/nix-ipmi";
        ref = "master";
      }) { });
      # …
    })
  ];
};

Add a ipmi package to your package collection:

Wrapper

You could create a new package, which wraps ipmi package with default environment variables, for example:

(stdenv.mkDerivation {
  name = "ipmi";
  builder = writeScript "builder.sh" (''
    source $stdenv/setup
    mkdir -p $out/bin
    cat > $out/bin/ipmi <<'EOF'
    #!${bash}/bin/bash
    IPMI_HOST=$1 IPMI_OUTPUT=/tmp/$IPMI_HOST.jviewer.jnlp     \
    IPMI_USER=ADMIN IPMI_PASSWORD=$(cat $HOME/.ipmi_password) \
    ${ipmi}/bin/ipmi
    EOF
    chmod 555 $out/bin/ipmi
  '');
})

$HOME/.ipmi_password is a plain text file, but you could use GPG or password manager like password-store.

Prefetch jdk-7u75-linux-x64.tar.gz in your Nix Store.

nix-shell

nix-shell --pure --run 'ipmi web16.ipmi.intr IPMI_PASSWORD' --show-trace

web16.ipmi.intr web25.intr.ipmi web15.ipmi.intr web24.ipmi.intr

Using Nix IPMI

To use Nix IPMI just call ipmi with a server name, for example:

ipmi jenkins.ipmi

If you have the following error, launch "ControlPanel" from a terminal, then in "Security" tab set "Security Level" to "Medium".

Your security settings have blocked a self-signed application from running

Contributing to Nix IPMI

  1. Fork this repository.
  2. Create a branch: git checkout -b <branch_name>.
  3. Make your changes and commit them: git commit -m '<commit_message>'
  4. Push to the original branch: git push origin <project_name>/<location>
  5. Create the pull request.

Tests

Make sure ipmi could connect to web16.ipmi.intr web25.intr.ipmi web15.ipmi.intr web24.ipmi.intr.

Contributors

Thanks to the following people who have contributed to this project:

Contact

If you want to contact me you can reach me at go.wigust@gmail.com.

License

This project uses the following license: GPL3+.

About

Nix expression to build Bash script and container to connect to servers via IPMI

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published