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

Commit

Permalink
fix: fix critical bug
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Jul 10, 2017
1 parent 57a6e72 commit a558bb6
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

ansible role to install [gvm](https://github.com/moovweb/gvm)

This role is based on [the official gvm-installer](https://github.com/moovweb/gvm/blob/master/binscripts/gvm-installer).

> ## Notice: GVM == Go (Not Groovy) Version Manager
> This role has nothing to do with [Groovy enVironment Manager](http://sdkman.io/).
## Requirements

* git
Expand All @@ -12,7 +17,8 @@ ansible role to install [gvm](https://github.com/moovweb/gvm)

name | required | default | description
--- | --- | --- | ---
gvm_root | no | $GVM_ROOT >> $HOME/.gvm
gvm_dest | no | `$HOME` | If `gvm_dest == $HOME`, the gvm repository is cloned to `$HOME/.gvm`, otherwise to `{{ gvm_dest }}/gvm`
gvm_goroot | no | `undefined` |
gvm_is_dependencies_installed | no | no | By default build dependencies are not installed
gvm_rc_path | no | "NOT ADD" | By default configuration is not added
gvm_repo | no | https://github.com/moovweb/gvm |
Expand All @@ -34,7 +40,7 @@ Nothing.
- hosts: servers
roles:
- role: suzuki-shunsuke.gvm
gvm_root: "{{ ansible_env.HOME }}/.ghq/github.com/moovweb/gvm"
gvm_dest: "{{ ansible_env.HOME }}/.ghq/github.com/moovweb"
gvm_is_dependencies_installed: yes
gvm_rc_path: "{{ ansible_env.HOME }}/.bashrc"
gvm_darwin_build_dependencies:
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
# defaults file for gvm
gvm_dest: "{{ ansible_env.HOME }}"
gvm_root: "{{ ansible_env.get('GVM_ROOT', '{}/.gvm'.format(ansible_env.HOME)) }}"
gvm_repo: https://github.com/moovweb/gvm
gvm_version: HEAD
Expand Down
32 changes: 29 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
---
# tasks file for gvm
# https://github.com/moovweb/gvm/blob/master/binscripts/gvm-installer
- name: set gvm_name
set_fact:
gvm_name: "{{ (gvm_dest == ansible_env.HOME) | ternary('.gvm', 'gvm')}}"
- name: set gvm_root
set_fact:
gvm_root: "{{ gvm_dest }}/{{ gvm_name }}"
- name: Create directories
file:
dest: "{{ gvm_root | dirname }}"
dest: "{{ gvm_dest }}"
state: directory
- name: Clone gvm
git:
Expand All @@ -15,15 +21,35 @@
- name: Add configurations to ~/.bashrc, ~/.profile, or ~/.zshrc or etc
lineinfile:
dest: "{{ gvm_rc_path }}"
line: '[[ -s "{{ gvm_root }}/scripts/gvm" ]] && source "{{ gvm_root }}/scripts/gvm"'
regexp: '^\[\[ -s ".*/scripts/gvm" \]\] && source ".*/scripts/gvm"$'
create: yes
- name: Add configurations to $GVM_DEST/$GVM_NAME/scripts/gvm
lineinfile:
dest: "{{ gvm_root }}/scripts/gvm"
line: 'export GVM_ROOT="{{ gvm_root }}"'
regexp: '^export GVM_ROOT='
create: yes
- name: Add configurations to ~/.bashrc, ~/.profile, or ~/.zshrc or etc
- name: Add configurations to $GVM_DEST/$GVM_NAME/scripts/gvm
lineinfile:
dest: "{{ gvm_rc_path }}"
dest: "{{ gvm_root }}/scripts/gvm"
line: '. $GVM_ROOT/scripts/gvm-default'
create: yes
when: gvm_rc_path != "NOT ADD"
- block:
- name: create directories
file:
name: "{{ gvm_root }}/{{ item }}"
state: directory
items:
- environments
- pkgsets/system/global
- gos/system
- name: create $GVM_DEST/$GVM_NAME/environments/system
template:
src: system
dest: "{{ gvm_root }}/environments/system"
when: gvm_goroot is not undefined
- include: "{{ gvm_os_families.get(ansible_os_family, 'default') }}.yml"
static: no
when: gvm_is_dependencies_installed and ansible_os_family in gvm_os_families
7 changes: 7 additions & 0 deletions templates/system
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Automatically generated file. DO NOT EDIT!
export GVM_ROOT; GVM_ROOT="{{ gvm_dest }}/{{ gvm_name }}"
export gvm_go_name; gvm_go_name="system"
export gvm_pkgset_name; gvm_pkgset_name="global"
export GOROOT; GOROOT="{{ gvm_go_root }}"
export GOPATH; GOPATH="{{ gvm_dest }}/{{ gvm_name }}/pkgsets/system/global"
export PATH; PATH="{{ gvm_dest }}/{{ gvm_name }}/pkgsets/system/global/bin:$GOROOT/bin:$GVM_ROOT/bin:\$PATH"
3 changes: 0 additions & 3 deletions tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@
gvm_rc_path: "{{ ansible_env.HOME }}/.bashrc"
gvm_version: 1.0.20
gvm_update: no
- role: ansible-gvm
gvm_is_dependencies_installed: yes
gvm_rc_path: "{{ ansible_env.HOME }}/.bashrc"

0 comments on commit a558bb6

Please sign in to comment.