TOOCS.asdf

Build Status Ansible Role

TOOCS / Ansible Role: TOOCS.asdf

  • Installs asdf
  • For zsh users, sets up ~/.zlogin for an easy experience
  • Uses asdf to 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' >> ~/.bashrc
    
  • Bash on macOS:

    echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bash_profile
    echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bash_profile
    
  • Fish 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_install list

  • The entry should look like:

    - LANG:
        - x.x.x
        - y.y.y
    

    Where LANG is the language name, and x.x.x / y.y.y are version numbers.

  • The languages_to_install list is ordered:

    languages_to_install:
      - erlang:
          - 21.1.14
          - 20.3.8.9
    
      - elixir:
          - 1.7.4
    

    In this example, both versions of erlang will be installed before elixir. This is useful since elixir needs erlang to 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 global versions, 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.15
    

    In this case, after executing the TOOCS, your shell will be set up like this:

    • The erl command will use version 21.1.14
    • The python command will use version 3.7.0
    • For Python, which supports multiple global versions, you will also have access to:
      • python3.7 / pip3.7
      • python2.7 / pip2.7
      • python2.6 / pip2.6
      • python3 / pip3 => Latest python3 version: python3.7 / pip3.7
      • python2 / pip2 => Latest python2 version: python2.7 / pip2.7

Supported Languages

  • Python
    • Supports multiple global versions
    • On Debian stretch (and Ubuntu bionic), only Python versions >= 2.7.13 and >= 3.5.3 can be installed automatically. Earlier versions can be manually installed later, but it requires a workaround. See: Pyenv - Common Build Problems - OpenSSL
  • Erlang
    • Compiled with documentation but no jinterface
  • Elixir
    • Requires erlang
    • Compiled from source
    • **/!\ Ensure the current version of erlang is supported by the version of elixir you want to install /!\**
      • For example, elixir v1.6.6 is not compatible with erlang 21; to compile elixir v1.6.6, you must use erlang 20.

Role Variables

  • asdf_version

    • Version of asdf to install
    • Default: v0.6.2
  • skip_shell_setup

    • If True, it will only install asdf without setting up the shell
    • Default: False
  • languages_to_install

    • List of languages and versions to install using asdf. See Install Languages
    • Default: []

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

Informazioni sul progetto

Install 'asdf'

Installa
ansible-galaxy install TOOCS.asdf
Licenza
mit
Download
175
Proprietario
The Opinionated One-Click Setups - TOOCS - Logo made with DesignEvo (www.designevo.com)