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

gracefully check is already bootstrapped and pip is installed #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
- name: Check if bootstrap is needed
raw: stat $HOME/.bootstrapped
raw: test -e $HOME/.bootstrapped || echo -n need_bootstrap
register: need_bootstrap
ignore_errors: True
changed_when: false

- name: Booleanize need_bootstrap
set_fact:
need_bootstrap={{need_bootstrap.stdout == "need_bootstrap"}}

- name: Run bootstrap.sh
script: bootstrap.sh
when: need_bootstrap | failed
when: need_bootstrap

- name: Check if we need to install pip
shell: "{{ansible_python_interpreter}} -m pip --version"
shell: "{{ansible_python_interpreter}} -c 'import pkgutil; print(pkgutil.find_loader(\"pip\") is None)'"
register: need_pip
ignore_errors: True
changed_when: false
when: need_bootstrap | failed
when: need_bootstrap

- name: Booleanize need_pip
set_fact:
need_pip={{need_bootstrap and need_pip.stdout == "True"}}

- name: Copy get-pip.py
copy: src=get-pip.py dest=~/get-pip.py
when: need_pip | failed
when: need_pip

- name: Install pip
shell: "{{ansible_python_interpreter}} ~/get-pip.py"
when: need_pip | failed
when: need_pip

- name: Remove get-pip.py
file: path=~/get-pip.py state=absent
when: need_pip | failed
when: need_pip

- name: Install pip launcher
copy: src=runner dest=~/bin/pip mode=0755
when: need_pip | failed
when: need_pip