Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

suzuki-shunsuke/ansible-pyenv-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ansible-pyenv-module

Build Status

ansible module to run pyenv command.

https://galaxy.ansible.com/suzuki-shunsuke/pyenv-module/

Notice

Supported platform

  • GenericLinux
  • MacOSX

We test this module in

  • Ubuntu 16.04 (Vagrant, Virtualbox)
  • CentOS 7.3 (Vagrant, Virtualbox)
  • MaxOS Sierra 10.12.5

Requirements

If you want to install pyenv and python build dependencies with ansible role, we recommend the suzuki-shunsuke.pyenv. And if you want to install pyenv-virtualenv with ansible role, we recommend the suzuki-shunsuke.pyenv-virtualenv.

Supported pyenv subcommands and options

$ pyenv install [-s] [-f] <version>
$ pyenv uninstall -f <version>
$ pyenv install -l
$ pyenv versions [--bare]
$ pyenv global
$ pyenv global <versions>
$ pyenv virtualenv [-f|--force] [version] <virtualenv-name>
$ pyenv virtualenvs [--bare] [--skip-aliases]

Install

$ ansible-galaxy install suzuki-shunsuke.pyenv-module
# playbook.yml

- hosts: default
  roles:
  # After you call this role, you can use this module.
  - suzuki-shunsuke.pyenv-module

Options

In addition to this document, please see pyenv command reference and the output of pyenv help <command> command also.

Common Options

name type required default choices / example description
subcommand str no install [install, uninstall, versions, global, virtualenvs, virtualenv]
pyenv_root str no ~/.pyenv If the environment variable "PYENV_ROOT" is not set, this option is required
expanduser bool no yes By default the environment variable PYENV_ROOT and "pyenv_root" option are filtered by os.path.expanduser

Options of the "install" subcommand

parameter type required default choices / example description
version str no 3.6.1
list bool no no -l option
skip_existing bool no yes -s option
force bool no no -f option

Either "version" or "list" option is required. If the "list" option is set, the return value of that task has "versions" field.

Options of the "uninstall" subcommand

parameter type required default choices / example description
version str yes 2.7.13

Options of the "global" subcommand

parameter type required default choices description
versions list no

The return value of the "global" subcommand has "versions" field.

Options of the "versions" subcommand

parameter type required default choices description
bare bool no yes

The return value of the "versions" subcommand has "versions" field.

Options of the "virtualenvs" subcommand

parameter type required default choices description
skip_aliases bool no yes
bare bool no yes

The return value of the "virtualenvs" subcommand has "virtualenvs" field.

Options of the "virtualenv" subcommand

parameter type required default example description
force bool no no
version str yes 2.7.13
virtualenv_name str yes ansible

Example

- name: pyenv install -s 3.6.1
  pyenv:
    version: 3.6.1
    pyenv_root: "~/.pyenv"

- name: pyenv install -f 3.6.1
  pyenv:
    version: 3.6.1
    pyenv_root: "~/.pyenv"
    force: yes

- name: pyenv uninstall -f 2.6.9
  pyenv:
    subcommand: uninstall
    version: 2.6.9
    pyenv_root: "~/.pyenv"

- name: pyenv global 3.6.1
  pyenv:
    subcommand: global
    versions:
    - 3.6.1
    pyenv_root: "~/.pyenv"

- name: pyenv global
  pyenv:
    subcommand: global
    pyenv_root: "~/.pyenv"
  register: result
- debug:
    var: result.versions

- name: pyenv install -l
  pyenv:
    list: yes
    pyenv_root: "{{ansible_env.HOME}}/.pyenv"
  register: result
- debug:
    var: result.versions

- name: pyenv versions --bare
  pyenv:
    subcommand: versions
    pyenv_root: "{{ansible_env.HOME}}/.pyenv"
  register: result
- debug:
    var: result.versions

- name: pyenv virtualenvs --skip-aliases --bare
  pyenv:
    subcommand: virtualenvs
    pyenv_root: "~/.pyenv"
  register: result
- debug:
    var: result.virtualenvs

- name: pyenv virtualenv --force 2.7.13 ansible
  pyenv:
    subcommand: virtualenv
    pyenv_root: "~/.pyenv"
    version: 2.7.13
    virtualenv_name: ansible
    force: yes

Change Log

See CHANGELOG.md.

Licence

MIT

Develop

Requirements

  • Vagrant
  • Ansible
  • Node.js
  • yarn

Setup

$ yarn install
$ cd tests
$ ansible-galaxy install -r roles.yml

Test

$ cd tests
$ vagrant up --provision