Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
refactor(TASKS): source asdf via shell
Browse files Browse the repository at this point in the history
  • Loading branch information
niall-byrne committed Jul 3, 2022
1 parent 7ca08c8 commit dcc2cff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion molecule/common/tasks/verify_binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
"asdf_source": "{{ asdf_user_home }}/.asdf/asdf.sh"

- name: Capture output from version command
command: "bash -lc 'source {{ asdf_source }}; {{ version_command }}'"
shell: "source {{ asdf_source }}; {{ version_command }}"
changed_when: true
args:
chdir: "{{ asdf_user_home }}"
executable: "/bin/sh"
become: True
become_user: "{{ asdf_user }}"
register: version_output
Expand Down
18 changes: 11 additions & 7 deletions tasks/plugins_darwin/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
- name: Install asdf Plugins
become: True
become_user: "{{ asdf_user }}"
command: "bash -lc 'source {{ asdf_source }}; asdf plugin-add {{ item.name }} {{ item.repository | default() }}'"
shell: "source {{ asdf_source }}; asdf plugin-add {{ item.name }} {{ item.repository | default() }}"
args:
creates: "{{ asdf_user_home }}/.asdf/plugins/{{ item.name }}"
chdir: "{{ asdf_user_home }}"
creates: "{{ asdf_user_home }}/.asdf/plugins/{{ item.name }}"
executable: "/bin/sh"
with_items: "{{ asdf_plugins }}"
when: asdf_plugins|length > 0
ignore_errors: True
Expand All @@ -35,11 +36,12 @@
- name: Install asdf Apps
become: True
become_user: "{{ asdf_user }}"
command: "bash -lc 'source {{ asdf_source }}; asdf install {{ item.0.name }} {{ item.1 }}'"
shell: "source {{ asdf_source }}; asdf install {{ item.0.name }} {{ item.1 }}"
environment: "{{ item[0]['environment'] | default({}) }}"
args:
creates: "{{ asdf_user_home }}/.asdf/installs/{{ item.0.name }}/{{ item.1 }}"
chdir: "{{ asdf_user_home }}"
creates: "{{ asdf_user_home }}/.asdf/installs/{{ item.0.name }}/{{ item.1 }}"
executable: "/bin/sh"
with_subelements:
- "{{ asdf_plugins }}"
- versions
Expand All @@ -50,10 +52,11 @@
- name: Uninstall asdf Apps
become: True
become_user: "{{ asdf_user }}"
command: "bash -lc 'source {{ asdf_source }}; asdf uninstall {{ item.0.name }} {{ item.1 }}'"
shell: "source {{ asdf_source }}; asdf uninstall {{ item.0.name }} {{ item.1 }}"
args:
removes: "{{ asdf_user_home }}/.asdf/installs/{{ item.0.name }}/{{ item.1 }}"
chdir: "{{ asdf_user_home }}"
removes: "{{ asdf_user_home }}/.asdf/installs/{{ item.0.name }}/{{ item.1 }}"
executable: "/bin/sh"
with_subelements:
- "{{ asdf_plugins }}"
- delete_versions
Expand All @@ -64,9 +67,10 @@
- name: Set Global App Versions
become: True
become_user: "{{ asdf_user }}"
command: "bash -lc 'source {{ asdf_source }}; asdf global {{ item.name }} {{ item.global | default(item.versions | difference(item.delete_versions|default([])) | sort | first) }}'"
shell: "source {{ asdf_source }}; asdf global {{ item.name }} {{ item.global | default(item.versions | difference(item.delete_versions|default([])) | sort | first) }}"
args:
chdir: "{{ asdf_user_home }}"
executable: "/bin/sh"
when: item.versions is defined
changed_when: false
with_items: "{{ asdf_plugins }}"
Expand Down

0 comments on commit dcc2cff

Please sign in to comment.