Comcast/ansible-sdkman

sdkman believes its already installed

damianoneill opened this issue · 7 comments

Hi, I am running the role on a host with a user (doneill-test) with no sudo privileges with

---
- hosts: localhost
  vars: 
    # https://github.com/Comcast/ansible-sdkman/blob/master/defaults/main.yml
    sdkman_dir: ~/.sdkman
    # sdkman_update: true
    # sdkman_auto_selfupdate: true
  roles:
    - { role: comcast.sdkman }

I'm executing the play as follows:

ansible-playbook --skip-tags sdkman_privilege version-managers-playbook.yml -e "ansible_remote_tmp=/tmp/.ansible-doneill-test/tmp"

This fails on this task

TASK [comcast.sdkman : Configure SDKMAN] *****************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "checksum": "4a375f43a431a74667f6bce45925353092d17532", "msg": "Destination directory /home/doneill-test/.sdkman/etc does not exist"}

Look at the verbose output, this is because sdkman doesn't install.

TASK [comcast.sdkman : Run SDKMAN script] ****************************************************************************************************************************************
task path: /home/doneill-test/.ansible/roles/comcast.sdkman/tasks/install.yml:71
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: doneill-test
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /tmp/.ansible-doneill-test/tmp `"&& mkdir "` echo /tmp/.ansible-doneill-test/tmp/ansible-tmp-1610118133.57-24896-28165169837914 `" && echo ansible-tmp-1610118133.57-24896-28165169837914="` echo /tmp/.ansible-doneill-test/tmp/ansible-tmp-1610118133.57-24896-28165169837914 `" ) && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/commands/command.py
<127.0.0.1> PUT /home/doneill-test/.ansible/tmp/ansible-local-24749jnejFh/tmp1pEtwE TO /tmp/.ansible-doneill-test/tmp/ansible-tmp-1610118133.57-24896-28165169837914/AnsiballZ_command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /tmp/.ansible-doneill-test/tmp/ansible-tmp-1610118133.57-24896-28165169837914/ /tmp/.ansible-doneill-test/tmp/ansible-tmp-1610118133.57-24896-28165169837914/AnsiballZ_command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'SDKMAN_DIR='"'"'~/.sdkman'"'"' /usr/bin/python2 /tmp/.ansible-doneill-test/tmp/ansible-tmp-1610118133.57-24896-28165169837914/AnsiballZ_command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /tmp/.ansible-doneill-test/tmp/ansible-tmp-1610118133.57-24896-28165169837914/ > /dev/null 2>&1 && sleep 0'
NOTIFIED HANDLER comcast.sdkman : Cleanup SDKMAN script for localhost
changed: [localhost] => {
    "changed": true,
    "cmd": [
        "/bin/bash",
        "/tmp/sdkman_script"
    ],
    "delta": "0:00:00.006546",
    "end": "2021-01-08 15:02:13.657004",
    "invocation": {
        "module_args": {
            "_raw_params": "/bin/bash /tmp/sdkman_script",
            "_uses_shell": false,
            "argv": null,
            "chdir": null,
            "creates": "/home/doneill-test/.sdkman/bin/sdkman-init.sh",
            "executable": null,
            "removes": null,
            "stdin": null,
            "stdin_add_newline": true,
            "strip_empty_ends": true,
            "warn": true
        }
    },
    "rc": 0,
    "start": "2021-01-08 15:02:13.650458",
    "stderr": "",
    "stderr_lines": [],
    "stdout": "\n                                -+syyyyyyys:\n                            `/yho:`       -yd.\n                         `/yh/`             +m.\n                       .oho.                 hy                          .`\n                     .sh/`                   :N`                `-/o`  `+dyyo:.\n                   .yh:`                     `M-          `-/osysoym  :hs` `-+sys:      hhyssssssssy+\n                 .sh:`                       `N:          ms/-``  yy.yh-      -hy.    `.N-````````+N.\n               `od/`                         `N-       -/oM-      ddd+`     `sd:     hNNm        -N:\n              :do`                           .M.       dMMM-     `ms.      /d+`     `NMMs       `do\n            .yy-                             :N`    ```mMMM.      -      -hy.       /MMM:       yh\n          `+d+`           `:/oo/`       `-/osyh/ossssssdNMM`           .sh:         yMMN`      /m.\n         -dh-           :ymNMMMMy  `-/shmNm-`:N/-.``   `.sN            /N-         `NMMy      .m/\n       `oNs`          -hysosmMMMMydmNmds+-.:ohm           :             sd`        :MMM/      yy\n      .hN+           /d:    -MMMmhs/-.`   .MMMh   .ss+-                 `yy`       sMMN`     :N.\n     :mN/           `N/     `o/-`         :MMMo   +MMMN-         .`      `ds       mMMh      do\n    /NN/            `N+....--:/+oooosooo+:sMMM:   hMMMM:        `my       .m+     -MMM+     :N.\n   /NMo              -+ooooo+/:-....`...:+hNMN.  `NMMMd`        .MM/       -m:    oMMN.     hs\n  -NMd`                                    :mm   -MMMm- .s/     -MMm.       /m-   mMMd     -N.\n `mMM/                                      .-   /MMh. -dMo     -MMMy        od. .MMMs..---yh\n +MMM.                                           sNo`.sNMM+     :MMMM/        sh`+MMMNmNm+++-\n mMMM-                                           /--ohmMMM+     :MMMMm.       `hyymmmdddo\n MMMMh.                  ````                  `-+yy/`yMMM/     :MMMMMy       -sm:.``..-:-.`\n dMMMMmo-.``````..-:/osyhddddho.           `+shdh+.   hMMM:     :MmMMMM/   ./yy/` `:sys+/+sh/\n .dMMMMMMmdddddmmNMMMNNNNNMMMMMs           sNdo-      dMMM-  `-/yd/MMMMm-:sy+.   :hs-      /N`\n  `/ymNNNNNNNmmdys+/::----/dMMm:          +m-         mMMM+ohmo/.` sMMMMdo-    .om:       `sh\n     `.-----+/.`       `.-+hh/`         `od.          NMMNmds/     `mmy:`     +mMy      `:yy.\n           /moyso+//+ossso:.           .yy`          `dy+:`         ..       :MMMN+---/oys:\n         /+m:  `.-:::-`               /d+                                    +MMMMMMMNh:`\n        +MN/                        -yh.                                     `+hddhy+.\n       /MM+                       .sh:\n      :NMo                      -sh/\n     -NMs                    `/yy:\n    .NMy                  `:sh+.\n   `mMm`               ./yds-\n  `dMMMmyo:-.````.-:oymNy:`\n  +NMMMMMMMMMMMMMMMMms:`\n    -+shmNMMMNmdy+:`\n\n\n                                                                 Now attempting installation...\n\n\nLooking for a previous installation of SDKMAN...\nSDKMAN found.\n\n======================================================================================================\n You already have SDKMAN installed.\n SDKMAN was found at:\n\n    ~/.sdkman\n\n Please consider running the following if you need to upgrade.\n\n    $ sdk selfupdate force\n\n======================================================================================================",
    "stdout_lines": [
        "",
        "                                -+syyyyyyys:",
        "                            `/yho:`       -yd.",
        "                         `/yh/`             +m.",
        "                       .oho.                 hy                          .`",
        "                     .sh/`                   :N`                `-/o`  `+dyyo:.",
        "                   .yh:`                     `M-          `-/osysoym  :hs` `-+sys:      hhyssssssssy+",
        "                 .sh:`                       `N:          ms/-``  yy.yh-      -hy.    `.N-````````+N.",
        "               `od/`                         `N-       -/oM-      ddd+`     `sd:     hNNm        -N:",
        "              :do`                           .M.       dMMM-     `ms.      /d+`     `NMMs       `do",
        "            .yy-                             :N`    ```mMMM.      -      -hy.       /MMM:       yh",
        "          `+d+`           `:/oo/`       `-/osyh/ossssssdNMM`           .sh:         yMMN`      /m.",
        "         -dh-           :ymNMMMMy  `-/shmNm-`:N/-.``   `.sN            /N-         `NMMy      .m/",
        "       `oNs`          -hysosmMMMMydmNmds+-.:ohm           :             sd`        :MMM/      yy",
        "      .hN+           /d:    -MMMmhs/-.`   .MMMh   .ss+-                 `yy`       sMMN`     :N.",
        "     :mN/           `N/     `o/-`         :MMMo   +MMMN-         .`      `ds       mMMh      do",
        "    /NN/            `N+....--:/+oooosooo+:sMMM:   hMMMM:        `my       .m+     -MMM+     :N.",
        "   /NMo              -+ooooo+/:-....`...:+hNMN.  `NMMMd`        .MM/       -m:    oMMN.     hs",
        "  -NMd`                                    :mm   -MMMm- .s/     -MMm.       /m-   mMMd     -N.",
        " `mMM/                                      .-   /MMh. -dMo     -MMMy        od. .MMMs..---yh",
        " +MMM.                                           sNo`.sNMM+     :MMMM/        sh`+MMMNmNm+++-",
        " mMMM-                                           /--ohmMMM+     :MMMMm.       `hyymmmdddo",
        " MMMMh.                  ````                  `-+yy/`yMMM/     :MMMMMy       -sm:.``..-:-.`",
        " dMMMMmo-.``````..-:/osyhddddho.           `+shdh+.   hMMM:     :MmMMMM/   ./yy/` `:sys+/+sh/",
        " .dMMMMMMmdddddmmNMMMNNNNNMMMMMs           sNdo-      dMMM-  `-/yd/MMMMm-:sy+.   :hs-      /N`",
        "  `/ymNNNNNNNmmdys+/::----/dMMm:          +m-         mMMM+ohmo/.` sMMMMdo-    .om:       `sh",
        "     `.-----+/.`       `.-+hh/`         `od.          NMMNmds/     `mmy:`     +mMy      `:yy.",
        "           /moyso+//+ossso:.           .yy`          `dy+:`         ..       :MMMN+---/oys:",
        "         /+m:  `.-:::-`               /d+                                    +MMMMMMMNh:`",
        "        +MN/                        -yh.                                     `+hddhy+.",
        "       /MM+                       .sh:",
        "      :NMo                      -sh/",
        "     -NMs                    `/yy:",
        "    .NMy                  `:sh+.",
        "   `mMm`               ./yds-",
        "  `dMMMmyo:-.````.-:oymNy:`",
        "  +NMMMMMMMMMMMMMMMMms:`",
        "    -+shmNMMMNmdy+:`",
        "",
        "",
        "                                                                 Now attempting installation...",
        "",
        "",
        "Looking for a previous installation of SDKMAN...",
        "SDKMAN found.",
        "",
        "======================================================================================================",
        " You already have SDKMAN installed.",
        " SDKMAN was found at:",
        "",
        "    ~/.sdkman",
        "",
        " Please consider running the following if you need to upgrade.",
        "",
        "    $ sdk selfupdate force",
        "",
        "======================================================================================================"
    ]
}

I have tried setting your variables sdkman_update: true, sdkman_auto_selfupdate: true but this makes no difference.

Before running the play ~/.sdkman does not exist, nor after the play executes.

In task TASK [comcast.sdkman : Check for SDKMAN installation] ~/.sdkman exists:false

I have also tried using a different directory name ~/.sdkman2 this fails the same way, with sdkman installer saying the .sdkman2 directory exists.

Any help would be much appreciated.

Thanks,
Damian.

debug.log

Full log attached.

Hi @ALL checking in to see if anyone has had a chance to look at this?

Hi @damianoneill. No, I haven't had a chance to look into this just yet, but I'm sorry you're having trouble with it. I may have some time to look into it this weekend.

Thanks, @elliotweiser that would be great.

After a series of OS upgrades and making adjustments to use Molecule v3, I'm finally at a point where I can test this again. I was able to successfully repro the issue. I'll see what I can find.

It looks like there is a mysterious new ~ directory which has been created just under the / directory. This is distinct in my case from /root, which is the $HOME directory of the root user. I suspect you may see something similar.

I was able to get this working by removing the explicit declaration of the sdkman_dir (after tearing down my docker container and starting from scratch). This will default to picking up the ansible_user's $HOME directory, anyway, which is equivalent to ~ anyway. The presence of the existing /root/.sdkman (or just $HOME/.sdkman) with nothing underneath it seemed to interfere with subsequent attempts to re-install. If you'd rather not rely on the default value, you can set sdkman_dir to the absolute path including /home/<your-username>/. I hope this helps.

Thanks @elliotweiser confirming your suggestion worked. Thanks for your time on this.

Damian.