TOOCS.asdf
TOOCS / Ansible Role: TOOCS.asdf
- Installs
asdf - For
zshusers, sets up~/.zloginfor an easy experience - Uses
asdfto install your chosen languages (limited support, see Install languages)
What is TOOCS?
TOOCS - The Opinionated One-Click Setups is a collection of tools and Ansible roles designed to set up a system quickly and easily. They are a straightforward way to install a specific tool. You can use them directly or as a step-by-step guide by looking at the code.
They are called "opinionated" because while they ensure easy setup, they do not guarantee consistent methods. New versions may introduce changes.
It's important to read the code to understand what's happening!
Table of Contents
Requirements
This role works only on macOS & Ubuntu/Debian.
Post Install - Shell Configuration
Zsh Users
If you're using zsh, this TOOCS will automatically configure the ~/.zlogin file for you. No further action is needed.
If you're not using a framework like oh-my-zsh, or you get an error message like 'command not found: compinit', please add this line to the top of your ~/.zlogin file:
autoload -Uz compinit && compinit
Non-Zsh Users
If you're not using zsh, you need to do some manual setup. Depending on your OS and shell, run the following:
Bash on Ubuntu (and other Linux):
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrcBash on macOS:
echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bash_profile echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bash_profileFish Shell:
echo 'source ~/.asdf/asdf.fish' >> ~/.config/fish/config.fish mkdir -p ~/.config/fish/completions; cp ~/.asdf/completions/asdf.fish ~/.config/fish/completions
Restart your shell to apply the changes (usually opening a new terminal tab works).
If you are having detection issues with the shims you installed, it might be because the lines above are not at the bottom of your ~/.bash_profile, ~/.zshrc, or ~/.config/fish/config.fish. They need to be sourced after setting your $PATH.
Source: official 'asdf' setup
Install Languages
After installing asdf, this TOOCS can automatically install various versions of languages you choose. It handles the prerequisite dependencies for each language and prefers to compile from source instead of using pre-compiled binaries.
The variable languages_to_install is where you list all the languages and specific versions you want to install.
To install a language, add an entry to the
languages_to_installlistThe entry should look like:
- LANG: - x.x.x - y.y.yWhere
LANGis the language name, andx.x.x / y.y.yare version numbers.The
languages_to_installlist is ordered:languages_to_install: - erlang: - 21.1.14 - 20.3.8.9 - elixir: - 1.7.4In this example, both versions of
erlangwill be installed beforeelixir. This is useful sinceelixirneedserlangto compile.For each language, the list of versions to install is also ordered.
- The first version in the list will be set as
global - For languages that support multiple
globalversions, all listed versions will be set as global in order (e.g., Python):
languages_to_install: - erlang: - 21.1.14 - 20.3.8.9 - python: # Supports multiple `global` - 3.7.0 - 2.6.6 - 2.7.15In this case, after executing the TOOCS, your shell will be set up like this:
- The
erlcommand will use version21.1.14 - The
pythoncommand will use version3.7.0 - For Python, which supports multiple
globalversions, you will also have access to:python3.7/pip3.7python2.7/pip2.7python2.6/pip2.6python3/pip3=> Latestpython3version:python3.7/pip3.7python2/pip2=> Latestpython2version:python2.7/pip2.7
- The first version in the list will be set as
Supported Languages
- Python
- Supports multiple
globalversions - On Debian stretch (and Ubuntu bionic), only Python versions
>= 2.7.13and>= 3.5.3can be installed automatically. Earlier versions can be manually installed later, but it requires a workaround. See: Pyenv - Common Build Problems - OpenSSL
- Supports multiple
- Erlang
- Compiled with documentation but no
jinterface
- Compiled with documentation but no
- Elixir
- Requires
erlang - Compiled from source
- **/!\ Ensure the current version of
erlangis supported by the version ofelixiryou want to install /!\**- For example,
elixir v1.6.6is not compatible witherlang 21; to compileelixir v1.6.6, you must useerlang 20.
- For example,
- Requires
Role Variables
asdf_version- Version of
asdfto install - Default:
v0.6.2
- Version of
skip_shell_setup- If
True, it will only installasdfwithout setting up the shell - Default:
False
- If
languages_to_install- List of languages and versions to install using
asdf. See Install Languages - Default:
[]
- List of languages and versions to install using
Example Playbook
- hosts: sandbox
tasks:
- include_role:
name: TOOCS.asdf
# OR
- hosts: sandbox
tasks:
- include_role:
name: TOOCS.asdf
vars:
asdf_version: v0.6.1
skip_shell_setup: True
# OR
- hosts: sandbox
tasks:
- include_role:
name: TOOCS.asdf
vars:
languages_to_install:
- python:
- 3.7.0
- 2.7.15
- 2.6.6
- erlang:
- 20.3.8.9
- 21.1.4
- elixir:
- 1.7.4
- 1.6.6
License
MIT
Author Information
Follow me on Twitter: @ThisIsFlorianK
Learn more about my work: Florian Kempenich - Personal Website
