{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/1509","repository_url":"https://api.github.com/repos/ansible/ansible-modules-core","labels_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/1509/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/1509/comments","events_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/1509/events","html_url":"https://github.com/ansible/ansible-modules-core/issues/1509","id":87755446,"number":1509,"title":"git module: always returns status changed","user":{"login":"tommarshall","id":1125251,"avatar_url":"https://avatars.githubusercontent.com/u/1125251?v=3","gravatar_id":"","url":"https://api.github.com/users/tommarshall","html_url":"https://github.com/tommarshall","followers_url":"https://api.github.com/users/tommarshall/followers","following_url":"https://api.github.com/users/tommarshall/following{/other_user}","gists_url":"https://api.github.com/users/tommarshall/gists{/gist_id}","starred_url":"https://api.github.com/users/tommarshall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommarshall/subscriptions","organizations_url":"https://api.github.com/users/tommarshall/orgs","repos_url":"https://api.github.com/users/tommarshall/repos","events_url":"https://api.github.com/users/tommarshall/events{/privacy}","received_events_url":"https://api.github.com/users/tommarshall/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/bug_report","name":"bug_report","color":"fbca04"},{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/needs_info","name":"needs_info","color":"eb6420"},{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/P3","name":"P3","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":25,"created_at":"2015-06-12T15:05:39Z","updated_at":"2016-08-11T15:39:24Z","closed_at":null,"body":"**Issue Type:**\r\n\r\nBug report\r\n\r\n**Ansible Version:**\r\n\r\n1.9.1\r\n\r\n**Environment:**\r\n\r\nOS X 10.3 provisioning Ubuntu 14.04\r\n\r\n**Summary:**\r\n\r\ngit module always returns status changed, even if there was no changes at all.\r\n\r\nThe repo is cloned into `/opt`, which requires root permissions, however the repo itself cannot be cloned by the root user, so is cloned to `/tmp`, then moved into `/opt`. There's a second job to pull future updates as the `foo` user when the repo already exists.\r\n\r\n    - name: Check if scripts repository is already installed.\r\n      stat: \"path=/opt/scripts\"\r\n      register: scripts_repo\r\n    \r\n    - name: Clone the scripts repository.\r\n      git:\r\n        repo: ssh://git@repo.example.com:/example.com/server-scripts.git\r\n        dest: /tmp/scripts\r\n        accept_hostkey: true\r\n      sudo: yes\r\n      sudo_user: foo\r\n      when: not scripts_repo.stat.exists\r\n    \r\n    - name: Move the scripts repo.\r\n      command: mv /tmp/scripts /opt/scripts\r\n      sudo: yes\r\n      when: not scripts_repo.stat.exists\r\n    \r\n    - name: Ensure scripts is up to date (when not cloning).\r\n      git:\r\n        repo: ssh://git@repo.example.com:/example.com/server-scripts.git\r\n        dest: /opt/scripts\r\n        accept_hostkey: true\r\n      sudo: yes\r\n      sudo_user: foo\r\n      when: scripts_repo.stat.exists\r\n      register: scripts_update \r\n\r\n    - debug: var=scripts_update \r\n\r\nOutput from task runner indicated that the before and after commit refs are the same, however changed is `true`:\r\n\r\n    TASK: [Check if scripts repository is already installed.] *********************\r\n    ok: [192.168.33.10]\r\n\r\n    TASK: [Clone the scripts repository.] *****************************************\r\n    skipping: [192.168.33.10]\r\n\r\n    TASK: [Move the scripts repo.] ************************************************\r\n    skipping: [192.168.33.10]\r\n\r\n    TASK: [Ensure scripts is up to date (when not cloning).] **********************\r\n    changed: [192.168.33.10]\r\n\r\n    TASK: [debug var=scripts_update] **********************************************\r\n    ok: [192.168.33.10] => {\r\n        \"var\": {\r\n            \"scripts_update\": {\r\n                \"after\": \"a8f34d434fcc0a1356aa4d8dda1eb1112bbff105\",\r\n                \"before\": \"a8f34d434fcc0a1356aa4d8dda1eb1112bbff105\",\r\n                \"changed\": true,\r\n                \"invocation\": {\r\n                    \"module_args\": \"\",\r\n                    \"module_name\": \"git\"\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\nI've found a [similar issue from 2014](https://github.com/ansible/ansible/issues/6526), which was caused by an unclean repository, however in this case the repo itself appears to be clean:\r\n\r\n    /opt/scripts $ sudo -u foo git status\r\n    On branch master\r\n    Your branch is up-to-date with 'origin/master'.\r\n\r\n    nothing to commit, working directory clean\r\n\r\n**Steps To Reproduce:**\r\n\r\nUnclear. We're doing the same round the houses approach for another repo, and that is reporting `changed` correctly.\r\n\r\n**Expected Results:**\r\n\r\n`scripts_update.changed` should be `false` when the before and after commit refs are the same.\r\n\r\n**Actual Results:**\r\n\r\n`scripts_update.changed` is `true`."},"comment":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/comments/239200078","html_url":"https://github.com/ansible/ansible-modules-core/issues/1509#issuecomment-239200078","issue_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/1509","id":239200078,"user":{"login":"tommarshall","id":1125251,"avatar_url":"https://avatars.githubusercontent.com/u/1125251?v=3","gravatar_id":"","url":"https://api.github.com/users/tommarshall","html_url":"https://github.com/tommarshall","followers_url":"https://api.github.com/users/tommarshall/followers","following_url":"https://api.github.com/users/tommarshall/following{/other_user}","gists_url":"https://api.github.com/users/tommarshall/gists{/gist_id}","starred_url":"https://api.github.com/users/tommarshall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tommarshall/subscriptions","organizations_url":"https://api.github.com/users/tommarshall/orgs","repos_url":"https://api.github.com/users/tommarshall/repos","events_url":"https://api.github.com/users/tommarshall/events{/privacy}","received_events_url":"https://api.github.com/users/tommarshall/received_events","type":"User","site_admin":false},"created_at":"2016-08-11T15:39:24Z","updated_at":"2016-08-11T15:39:24Z","body":"@jctanner The contents of `.gitmodules` & `.git/config` are as shown above before the second clone, and are unchanged after the second clone."}}
{"actor":{"display_login":"tommarshall"}}