Skip to content

katoquro/lmm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lmm - Linux machine manager

A simple Ansible wrapper to install Roles as packages and share them.

Check list of available software w/o intalling lmm.

Why do you need this

This is a small script which allows you to install packages from Roles (a.k.a. recipes).

Note
Currently, it’s focused on DEB-based distros and tested on Ubuntu

Many packages of Ubuntu Linux have outdated versions or require 3rd party repositories (like Google Chrome or 1Password). Some of them don’t even have DEB-repo and should be installed by steps (Like Go-lang or NVM).

With lmm you can almost avoid bash/python/etc scripts for automatization, and you can use power of Ansible to describe steps to install packages.

How to install 1Password with lmm
# Where prefix 'kato' stands for role owner
lmm install kato.1password

And you can see all steps lmm does to install 1Password

./roles/kato.1password
link:roles/sudo.kato.1password/tasks/main.yml[role=include]

And you can see all steps which require sudo: they are become: true (means become the superuser)

Note
By default, ansible cannot become su by themselves (must be installed w/o sudo). So you have to 'activate su session' in the current terminal with command sudo true before you call lmm install

How to install

Requirements

As lmm is based on Ansible we recommend install it from pip to have the newest version.
sudo apt-get install git curl python3-pip unzip
# install ansible w/o sudo
pip3 install ansible

Install lmm with ansible

Copy and run this playbook with ansible

curl -s -o /tmp/lmm.yml https://raw.githubusercontent.com/katoquro/lmm/master/install-with-ansible.yml && ansible-playbook /tmp/lmm.yml

Manual installation

  1. Clone this repo to any location

    git clone git@github.com:katoquro/lmm.git
  2. Init and check that everything is OK

    ./lmm.sh help
  3. Optional - Create a Symlink

    You can create a Symbolic Link for the script to use it system-wide. Call it from cloned repo (you can choose any target in PATH)

    ln -s "$(pwd)/lmm.sh" ~/.local/bin/lmm

How to create custom roles

The full doc you can find at Ansible site

The simplest way to start is to copy existing role. If the new package requires version extract it to separate role variable.

Roles have convenient variables:

  • {{ _user }} - current username. May be used to give rights or find home folder.

  • {{ _install_dir }} - path to ~/.local/share/lmm. May be used to install packages w/o sudo there.

  • {{ _local_bin }} - path to ~/.local/bin. This path is used to create symlinks to installed packages w/o sudo. If you are using Gnome with Xorg it should be already in your PATH.

  • {{ ansible_distribution_release }} - ubuntu release like bionic, focal, jammy, etc. May be used in repo path.

Shell Variables

Declarative Ansible way has limitations when you want to have variables evaluated in your shell. However, such variables are very handy. The most obvious case is to check is program already available in user’s PATH. You may want to have this knowledge to run dependencies. E.g. install nvm with node when you are going to install yarn.

lmm allows to add shell variables in several steps:

  1. Create <variable_name>.sh file under roles/<my_roles>/vars/ directory

  2. Put a shell code there with echo for return value This code will be evaluated before an Ansible run and its out becomes value of variable. Like usual shell variable variable_name=$(sh variable_name.sh)

  3. Use variable (file name w/o .sh) in your role.

Q&A

  1. Why I don’t see 'upgrade' command for package/role

    Current roles are quite simple and don’t include such cases. However, many roles configure DEB-repos, so you will get upgrades via apt. Some packages are provided as latest so you may upgrade them by calling install again.

  2. Why I don’t see 'delete' command for package/role

    The current aim of lmm to provide easy installation of packages. lmm isn’t full-fledged package manager. Think about it as declarative replacement of installation scripts.

About

Local machine manager

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published