From dcc2cff511410202c15d9e7632d0bc8442cb609f Mon Sep 17 00:00:00 2001 From: Niall Byrne <9848926+niall-byrne@users.noreply.github.com> Date: Sat, 2 Jul 2022 20:53:02 -0400 Subject: [PATCH] refactor(TASKS): source asdf via shell --- molecule/common/tasks/verify_binary.yml | 3 ++- tasks/plugins_darwin/main.yml | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/molecule/common/tasks/verify_binary.yml b/molecule/common/tasks/verify_binary.yml index c85a98f..cfe6fc9 100644 --- a/molecule/common/tasks/verify_binary.yml +++ b/molecule/common/tasks/verify_binary.yml @@ -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 diff --git a/tasks/plugins_darwin/main.yml b/tasks/plugins_darwin/main.yml index 130a53d..e837a71 100644 --- a/tasks/plugins_darwin/main.yml +++ b/tasks/plugins_darwin/main.yml @@ -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 @@ -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 @@ -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 @@ -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 }}"