A simple Ansible wrapper to install Roles as packages and share them.
Check list of available software w/o intalling lmm
.
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.
lmm
# Where prefix 'kato' stands for role owner lmm install kato.1password
And you can see all steps lmm
does to install 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
|
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
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
-
Clone this repo to any location
git clone git@github.com:katoquro/lmm.git
-
Init and check that everything is OK
./lmm.sh help
-
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
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 yourPATH
. -
{{ ansible_distribution_release }}
- ubuntu release like bionic, focal, jammy, etc. May be used in repo path.
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:
-
Create
<variable_name>.sh
file underroles/<my_roles>/vars/
directory -
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 variablevariable_name=$(sh variable_name.sh)
-
Use variable (file name w/o
.sh
) in your role.
-
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 aslatest
so you may upgrade them by callinginstall
again. -
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.