Skip to content

Instantly share code, notes, and snippets.

@ashiato45
Last active February 6, 2019 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashiato45/065b760019369cd73856763b049f3b1c to your computer and use it in GitHub Desktop.
Save ashiato45/065b760019369cd73856763b049f3b1c to your computer and use it in GitHub Desktop.
Install pyenv and install modules by pip-module
---
- hosts: all
remote_user: ubuntu
tasks:
- name: sync
synchronize:
src: .
dest: /home/ubuntu
- name: loadpyenv
git:
repo: 'git://github.com/pyenv/pyenv.git'
dest: /home/ubuntu/.pyenv
accept_hostkey: yes
- name: writepyenv
blockinfile:
dest: /home/ubuntu/.bash_profile
content: |
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
create: yes
- name: readprofile
shell: bash -lc 'source /home/ubuntu/.bash_profile'
- name: pyenvinstall
shell: bash -lc "pyenv install -s 3.5.0" # s skips if it exists
- name: pyenvset
shell: bash -lc "pyenv global 3.5.0"
- set_fact: ansible_python_interpreter=/home/ubuntu/.pyenv/shims/python
- name: hoge
pip:
requirements: /home/ubuntu/oden/requirements.txt
- name: killpy
shell: killall python
ignore_errors: yes
- name: startpy
shell: python oden/oden.py worker > log.txt 2>&1 &
async: 15
poll: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment