Skip to content

Commit

Permalink
Implementation of proposal 2 for issue #84
Browse files Browse the repository at this point in the history
Signed-off-by: Karl Hepworth <karl.hepworth@gmail.com>
  • Loading branch information
fubarhouse committed Jun 27, 2018
1 parent d566ce7 commit 5648426
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 30 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ To ensure all packages are removed before running the play, you can use the go_r
go_reget: true
````

To add/change the shell profiles to configure, use the `shell_profiles` array.
To add/change the absolute path of shell profiles to configure, use `golang_shell_profile`.

**If you do not define `golang_shell_profile`, the functionality will be ignored.**

````yaml
shell_profiles:
- .bash_profile
golang_shell_profile: /root/.bash_profile
````

To clean up an installation completely prior to role execution:
Expand Down
4 changes: 0 additions & 4 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,3 @@ go_get:
- name: golint
url: github.com/golang/lint/golint
go_install: []

# Configuration
shell_profiles:
- .bash_profile
7 changes: 3 additions & 4 deletions tasks/cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@

- name: "Go-Lang | Ensure shell profiles are clean"
lineinfile:
dest: "{{ item[0].stat.path }}"
dest: "{{ item[0] }}"
regexp: "{{ item[1].regex }}"
line: "{{ item[1].lineinfile }}"
state: absent
with_nested:
- "{{ stat_shell_profiles.results }}"
- "{{ golang_shell_profile }}"
- "{{ shell_exports }}"
when:
- shell_profiles is defined
- golang_shell_profile is defined
- shell_exports is defined
- item[0].stat.exists|bool == true
11 changes: 4 additions & 7 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@

- name: "Go-Lang | Ensure shell profiles are configured"
lineinfile:
dest: "{{ item[0].stat.path }}"
dest: "{{ item[0] }}"
regexp: "{{ item[1].regex }}"
line: "{{ item[1].lineinfile }}"
state: present
with_nested:
- "{{ stat_shell_profiles.results }}"
- "{{ golang_shell_profile }}"
- "{{ shell_exports }}"
when:
- stat_shell_profiles is defined
- shell_profiles is defined
- item[0].stat.exists|bool == true
- golang_shell_profile is defined

- name: "Go-Lang | Verify version"
shell: "{{ GOROOT }}/bin/go version"
Expand All @@ -49,6 +47,5 @@
changed_when: false

- name: "Go-Lang | Restart shell"
shell: "{{ fubarhouse_user_dir }}/{{ item }}"
with_items: "{{ shell_profiles }}"
shell: "{{ golang_shell_profile }}"
failed_when: false
13 changes: 1 addition & 12 deletions tasks/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,6 @@
- GOROOT is defined
- GOPATH is not defined

- name: "Go-Lang | Detect configured shell profiles"
stat:
path: "{{ fubarhouse_user_dir }}/{{ item }}"
changed_when: false
failed_when: false
with_items: "{{ shell_profiles }}"
register: stat_shell_profiles
when:
- shell_profiles is defined
- stat_shell_profiles is not defined

- name: "Go-Lang | Define shell exports"
set_fact:
shell_exports:
Expand All @@ -78,7 +67,7 @@
- regex: "PATH:{{ GOPATH }}/bin"
lineinfile: "export PATH=$PATH:{{ GOPATH }}/bin"
when:
- stat_shell_profiles is defined
- golang_shell_profile is defined
- shell_exports is not defined

- name: "Go-Lang | Define GOROOT_BOOTSTRAP"
Expand Down
1 change: 1 addition & 0 deletions tests/test.retry
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
localhost

0 comments on commit 5648426

Please sign in to comment.