andrewrothstein / ansible-miniconda

MIT License
28 stars 26 forks source link

Failed conda curl remove task when run a second time #8

Closed clintval closed 6 years ago

clintval commented 6 years ago

When conda curl is not installed you have a task to attempt removal which is giving me errors when I run this role more than once. Would you consider checking for existance of conda curl before attempting the removal?

diff --git a/tasks/main.yml b/tasks/main.yml
index 553c436..d186c58 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -48,12 +48,20 @@
   when: miniconda_pkg_update
   command: '{{miniconda_conda_bin}} update -y --all'

+- name: check for installation of conda curl
+  become: '{{miniconda_escalate}}'
+  shell: '{{miniconda_conda_bin}} list -f curl | grep curl'
+  ignore_errors: True
+  register: miniconda_curl_exists
+  when: miniconda_conda_binary.stat.exists
+
 - name: remove conda-curl since it conflicts with the system curl
   become: '{{miniconda_escalate}}'
   become_user: root
   command: '{{miniconda_conda_bin}} remove -y curl'
   args:
     removes: '{{miniconda_link_dir}}/lib/libcurl.a'
+  when: miniconda_curl_exists is success

 - name: make system default python etc...
   when: miniconda_make_sys_default

I can submit a PR if you would like!

clintval commented 6 years ago

In an empty playbook:

- hosts: servers
  roles:
    - andrewrothstein.miniconda

When run three times I get this the third time:

==> default: Running provisioner: ansible...
    default: Running ansible-playbook...

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [default]

TASK [andrewrothstein.bash : resolve platform specific vars] *******************

TASK [andrewrothstein.bash : install bash] *************************************
ok: [default] => (item=bash)
ok: [default] => (item=bash-completions)
ok: [default] => (item=bc)

TASK [andrewrothstein.bash : ensure the bash completions directory exists] *****
ok: [default]

TASK [andrewrothstein.unarchive-deps : resolve platform specific vars] *********

TASK [andrewrothstein.unarchive-deps : install common pkgs...] *****************
ok: [default] => (item=unzip)
ok: [default] => (item=gzip)
ok: [default] => (item=bzip2)
ok: [default] => (item=tar)
ok: [default] => (item=xz)

TASK [andrewrothstein.miniconda : check for installation of Miniconda] *********
ok: [default]

TASK [andrewrothstein.miniconda : download installer...] ***********************
skipping: [default]

TASK [andrewrothstein.miniconda : installing....] ******************************
skipping: [default]

TASK [andrewrothstein.miniconda : deleting installer...] ***********************
skipping: [default]

TASK [andrewrothstein.miniconda : link miniconda...] ***************************
ok: [default]

TASK [andrewrothstein.miniconda : update conda pkgs...] ************************
skipping: [default]

TASK [andrewrothstein.miniconda : remove conda-curl since it conflicts with the system curl] ***
fatal: [default]: FAILED! => {"changed": true, "cmd": ["/usr/local/anaconda/bin/conda", "remove", "-y", "curl"], "delta": "0:00:02.619096", "end": "2018-06-21 16:40:07.080686", "msg": "non-zero return code", "rc": 1, "start": "2018-06-21 16:40:04.461590", "stderr": "\nPackagesNotFoundError: The following packages are missing from the target environment:\n  - curl", "stderr_lines": ["", "PackagesNotFoundError: The following packages are missing from the target environment:", "  - curl"], "stdout": "Solving environment: ...working... failed", "stdout_lines": ["Solving environment: ...working... failed"]}
        to retry, use: --limit @/home/clint/libraries/gimme/playbook.retry

PLAY RECAP *********************************************************************
default                    : ok=6    changed=0    unreachable=0    failed=1

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

At least to keep your role idempotent I'll submit a PR for your review.

andrewrothstein commented 6 years ago

I believe I addressed this with v5.2.0 of the role.