IBM / ansible-for-i

the tool is to provide several customized modules for Ansible to manage IBM i systems.
GNU General Public License v3.0
55 stars 53 forks source link

fatal: repository '/home/QSECOFR/as45gtmp' does not exist" #151

Closed mad5bokyndryl closed 1 year ago

mad5bokyndryl commented 1 year ago

Hi Trying to clone using Git some issues are displayed. Even the directory is created and in the correct path

The playbook

---
- hosts: localhost
  gather_facts: no
  tasks:

   - name: remove if ~/as45gtmp exists
     file:
       path: '~/as45gtmp'
       state: 'absent'

   - name: create a directory on IFS
     file:
       path: '~/as45gtmp'
       state: 'directory'
       mode: '0755'

   - name: git clone from source repository
     git:
       repo: -c http.sslVerify=false clone 'https://github.com/mad5bo/AS45G-DevOps-On-IBM-i.git'
       dest: '/home/QSECOFR/as45gtmp'
       version: master

   - name: move the content cloned to student's directory
     shell: mv ~/as45gtmp/as45g* ~/"{{ student }}"
...

Issue the command:

 ansible-playbook clone_git_repo.yml -e "{'student': 'as45g01'}" -vvv

The very very verbose

PLAYBOOK: clone_git_repo.yml ***********************************************************
1 plays in clone_git_repo.yml

PLAY [localhost] ***********************************************************************
META: ran handlers

TASK [remove if ~/as45gtmp exists] *****************************************************
task path: /home/QSECOFR/as45g01/clone_git_repo.yml:6
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: qsecofr
<127.0.0.1> EXEC /bin/sh -c 'echo ~qsecofr && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/QSECOFR/.ansible/tmp `"&& mkdir /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274211.053495-5174-264222780849938 && echo ansible-tmp-1680274211.053495-5174-264222780849938="` echo /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274211.053495-5174-264222780849938 `" ) && sleep 0'
Using module file /QOpenSys/pkgs/lib/python3.6/site-packages/ansible/modules/files/file.py
<127.0.0.1> PUT /home/QSECOFR/.ansible/tmp/ansible-local-5166znl5tmsl/tmpb7u3bscg TO /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274211.053495-5174-264222780849938/AnsiballZ_file.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274211.053495-5174-264222780849938/ /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274211.053495-5174-264222780849938/AnsiballZ_file.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/QOpenSys/pkgs/bin/python3.6 /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274211.053495-5174-264222780849938/AnsiballZ_file.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274211.053495-5174-264222780849938/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true,
    "diff": {
        "after": {
            "path": "/home/QSECOFR/as45gtmp",
            "state": "absent"
        },
        "before": {
            "path": "/home/QSECOFR/as45gtmp",
            "path_content": {
                "directories": [
                    "/home/QSECOFR/as45gtmp/.git",
                    "/home/QSECOFR/as45gtmp/.git/branches",
                    "/home/QSECOFR/as45gtmp/.git/hooks",
                    "/home/QSECOFR/as45gtmp/.git/info",
                    "/home/QSECOFR/as45gtmp/.git/refs",
                    "/home/QSECOFR/as45gtmp/.git/objects",
                    "/home/QSECOFR/as45gtmp/.git/refs/heads",
                    "/home/QSECOFR/as45gtmp/.git/refs/tags",
                    "/home/QSECOFR/as45gtmp/.git/objects/pack",
                    "/home/QSECOFR/as45gtmp/.git/objects/info"
                ],
                "files": [
                    "/home/QSECOFR/as45gtmp/.git/description",
                    "/home/QSECOFR/as45gtmp/.git/HEAD",
                    "/home/QSECOFR/as45gtmp/.git/config",
                    "/home/QSECOFR/as45gtmp/.git/hooks/applypatch-msg.sample",
                    "/home/QSECOFR/as45gtmp/.git/hooks/commit-msg.sample",
                    "/home/QSECOFR/as45gtmp/.git/hooks/fsmonitor-watchman.sample",
                    "/home/QSECOFR/as45gtmp/.git/hooks/post-update.sample",
                    "/home/QSECOFR/as45gtmp/.git/hooks/pre-applypatch.sample",
                    "/home/QSECOFR/as45gtmp/.git/hooks/pre-commit.sample",
                    "/home/QSECOFR/as45gtmp/.git/hooks/pre-merge-commit.sample",
                    "/home/QSECOFR/as45gtmp/.git/hooks/pre-push.sample",
                    "/home/QSECOFR/as45gtmp/.git/hooks/pre-rebase.sample",
                    "/home/QSECOFR/as45gtmp/.git/hooks/pre-receive.sample",
                    "/home/QSECOFR/as45gtmp/.git/hooks/prepare-commit-msg.sample",
                    "/home/QSECOFR/as45gtmp/.git/hooks/update.sample",
                    "/home/QSECOFR/as45gtmp/.git/info/exclude"
                ]
            },
            "state": "directory"
        }
    },
    "invocation": {
        "module_args": {
            "_diff_peek": null,
            "_original_basename": null,
            "access_time": null,
            "access_time_format": "%Y%m%d%H%M.%S",
            "attributes": null,
            "backup": null,
            "content": null,
            "delimiter": null,
            "directory_mode": null,
            "follow": true,
            "force": false,
            "group": null,
            "mode": null,
            "modification_time": null,
            "modification_time_format": "%Y%m%d%H%M.%S",
            "owner": null,
            "path": "/home/QSECOFR/as45gtmp",
            "recurse": false,
            "regexp": null,
            "remote_src": null,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": null,
            "state": "absent",
            "unsafe_writes": null
        }
    },
    "path": "/home/QSECOFR/as45gtmp",
    "state": "absent"
}

TASK [create a directory on IFS] *******************************************************
task path: /home/QSECOFR/as45g01/clone_git_repo.yml:14
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: qsecofr
<127.0.0.1> EXEC /bin/sh -c 'echo ~qsecofr && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/QSECOFR/.ansible/tmp `"&& mkdir /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274214.218478-5186-236633559198303 && echo ansible-tmp-1680274214.218478-5186-236633559198303="` echo /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274214.218478-5186-236633559198303 `" ) && sleep 0'
Using module file /QOpenSys/pkgs/lib/python3.6/site-packages/ansible/modules/files/file.py
<127.0.0.1> PUT /home/QSECOFR/.ansible/tmp/ansible-local-5166znl5tmsl/tmp76w0je2p TO /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274214.218478-5186-236633559198303/AnsiballZ_file.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274214.218478-5186-236633559198303/ /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274214.218478-5186-236633559198303/AnsiballZ_file.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/QOpenSys/pkgs/bin/python3.6 /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274214.218478-5186-236633559198303/AnsiballZ_file.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274214.218478-5186-236633559198303/ > /dev/null 2>&1 && sleep 0'
changed: [localhost] => {
    "changed": true,
    "diff": {
        "after": {
            "mode": "0755",
            "path": "/home/QSECOFR/as45gtmp",
            "state": "directory"
        },
        "before": {
            "mode": "02755",
            "path": "/home/QSECOFR/as45gtmp",
            "state": "absent"
        }
    },
    "gid": 0,
    "group": "0",
    "invocation": {
        "module_args": {
            "_diff_peek": null,
            "_original_basename": null,
            "access_time": null,
            "access_time_format": "%Y%m%d%H%M.%S",
            "attributes": null,
            "backup": null,
            "content": null,
            "delimiter": null,
            "directory_mode": null,
            "follow": true,
            "force": false,
            "group": null,
            "mode": "0755",
            "modification_time": null,
            "modification_time_format": "%Y%m%d%H%M.%S",
            "owner": null,
            "path": "/home/QSECOFR/as45gtmp",
            "recurse": false,
            "regexp": null,
            "remote_src": null,
            "selevel": null,
            "serole": null,
            "setype": null,
            "seuser": null,
            "src": null,
            "state": "directory",
            "unsafe_writes": null
        }
    },
    "mode": "0755",
    "owner": "qsecofr",
    "path": "/home/QSECOFR/as45gtmp",
    "size": 8192,
    "state": "directory",
    "uid": 0
}

TASK [git clone from source repository] ************************************************
task path: /home/QSECOFR/as45g01/clone_git_repo.yml:22
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: qsecofr
<127.0.0.1> EXEC /bin/sh -c 'echo ~qsecofr && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/QSECOFR/.ansible/tmp `"&& mkdir /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274216.408257-5198-194719197976265 && echo ansible-tmp-1680274216.408257-5198-194719197976265="` echo /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274216.408257-5198-194719197976265 `" ) && sleep 0'
Using module file /QOpenSys/pkgs/lib/python3.6/site-packages/ansible/modules/source_control/git.py
<127.0.0.1> PUT /home/QSECOFR/.ansible/tmp/ansible-local-5166znl5tmsl/tmpri5x2dly TO /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274216.408257-5198-194719197976265/AnsiballZ_git.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274216.408257-5198-194719197976265/ /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274216.408257-5198-194719197976265/AnsiballZ_git.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/QOpenSys/pkgs/bin/python3.6 /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274216.408257-5198-194719197976265/AnsiballZ_git.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/QSECOFR/.ansible/tmp/ansible-tmp-1680274216.408257-5198-194719197976265/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "cmd": "/QOpenSys/pkgs/bin/git clone --origin origin '-c http.sslVerify=false clone '\"'\"'https://github.com/mad5bo/AS45G-DevOps-On-IBM-i.git'\"'\"'' /home/QSECOFR/as45gtmp",
    "invocation": {
        "module_args": {
            "accept_hostkey": false,
            "archive": null,
            "bare": false,
            "clone": true,
            "depth": null,
            "dest": "/home/QSECOFR/as45gtmp",
            "executable": null,
            "force": false,
            "gpg_whitelist": [],
            "key_file": null,
            "recursive": true,
            "reference": null,
            "refspec": null,
            "remote": "origin",
            "repo": "-c http.sslVerify=false clone 'https://github.com/mad5bo/AS45G-DevOps-On-IBM-i.git'",
            "separate_git_dir": null,
            "ssh_opts": null,
            "track_submodules": false,
            "umask": null,
            "update": true,
            "verify_commit": false,
            "version": "master"
        }
    },
    "msg": "fatal: repository '/home/QSECOFR/as45gtmp' does not exist",
    "rc": 128,
    "stderr": "fatal: repository '/home/QSECOFR/as45gtmp' does not exist\n",
    "stderr_lines": [
        "fatal: repository '/home/QSECOFR/as45gtmp' does not exist"
    ],
    "stdout": "",
    "stdout_lines": []
}

PLAY RECAP *****************************************************************************
localhost                  : ok=2    changed=2    unreachable=0    failed=1    skipped=0
robgjertsen1 commented 1 year ago

Note that this is not an issue with the ansible collection. It looks like an error in playbook when executed on IBM i system in regard to "repo" parameter usage (having "clone" specified there, so we'll have "clone" twice in the command itself which I can see may be a problem). Extra flags specified in that field may also be a problem ("-c http.sslVerify=false"), but not certain of that.

robgjertsen1 commented 1 year ago

I am closing the issue because after analysis it appears to be a user error and probably a limitation also with what you can specify with git module parameters, and not an issue related the Ansible collection itself.