{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/11266","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/11266/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/11266/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/11266/events","html_url":"https://github.com/ansible/ansible/issues/11266","id":88406998,"number":11266,"title":"Make 'ansible-galaxy install -r requirements.yml' idempotent","user":{"login":"tjanez","id":2518544,"avatar_url":"https://avatars.githubusercontent.com/u/2518544?v=3","gravatar_id":"","url":"https://api.github.com/users/tjanez","html_url":"https://github.com/tjanez","followers_url":"https://api.github.com/users/tjanez/followers","following_url":"https://api.github.com/users/tjanez/following{/other_user}","gists_url":"https://api.github.com/users/tjanez/gists{/gist_id}","starred_url":"https://api.github.com/users/tjanez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjanez/subscriptions","organizations_url":"https://api.github.com/users/tjanez/orgs","repos_url":"https://api.github.com/users/tjanez/repos","events_url":"https://api.github.com/users/tjanez/events{/privacy}","received_events_url":"https://api.github.com/users/tjanez/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/feature_idea","name":"feature_idea","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2015-06-15T12:15:06Z","updated_at":"2016-02-15T15:47:04Z","closed_at":null,"body":"##### Issue Type:\r\n\r\nBug Report/Feature Idea\r\n\r\n##### Ansible Version:\r\n\r\n```\r\nansible 1.9.1\r\n  configured module search path = None\r\n```\r\n\r\n##### Ansible Configuration:\r\n\r\n```ini\r\n[defaults]                                                                      \r\nlog_path = ../.tmp/ansible.log                                                  \r\n# path to the directory containing roles                                        \r\nroles_path = roles                                                              \r\nhash_behaviour = merge                                                          \r\nerror_on_undefined_vars = yes                                                   \r\nhost_key_checking=False\r\n```\r\n\r\n##### Environment:\r\n\r\nN/A\r\n\r\n##### Summary:\r\n\r\nRunning `ansible-galaxy install -r requirements.yml` should be idempotent (e.g. it should behave like `pip install -r requirements.txt`).\r\n\r\n##### Steps To Reproduce:\r\n\r\n1. Create `requirements.yml` file with the following contents:\r\n\r\n    ```yaml\r\n    # nodejs role\r\n    - src: https://github.com/nodesource/ansible-nodejs-role\r\n      version: 592a239dca52e1c5ff79cfefd0072efe3831428e\r\n      name: nodejs\r\n    ```\r\n2. Run `ansible-galaxy install -r requirements.yml`.\r\n3. Re-run `ansible-galaxy install -r requirements.yml`.\r\n\r\n\r\n##### Expected Results:\r\n\r\n```bash\r\n[tadej@tlinux64 admin]$ ansible-galaxy install -r requirements.yml\r\n- executing: git clone https://github.com/nodesource/ansible-nodejs-role nodejs\r\n- executing: git archive --prefix=nodejs/ --output=/tmp/tmpVoJEMx.tar 592a239dca52e1c5ff79cfefd0072efe3831428e\r\n- extracting nodejs to roles/nodejs\r\n- nodejs was installed successfully\r\n```\r\n\r\nOn the second run, `ansible-galaxy` should detect that the `nodejs` role is already installed and make sure the installed version matches the version specified in `requirements.yml`.\r\n\r\n##### Actual Results:\r\n\r\n```bash\r\n[tadej@tlinux64 admin]$ ansible-galaxy install -r requirements.yml\r\n- executing: git clone https://github.com/nodesource/ansible-nodejs-role nodejs\r\n- executing: git archive --prefix=nodejs/ --output=/tmp/tmpVoJEMx.tar 592a239dca52e1c5ff79cfefd0072efe3831428e\r\n- extracting nodejs to roles/nodejs\r\n- nodejs was installed successfully\r\n[tadej@tlinux64 admin]$ ansible-galaxy install -r requirements.yml\r\n- executing: git clone https://github.com/nodesource/ansible-nodejs-role nodejs\r\n- executing: git archive --prefix=nodejs/ --output=/tmp/tmp73DSKM.tar 592a239dca52e1c5ff79cfefd0072efe3831428e\r\n- extracting nodejs to roles/nodejs\r\n- error: the specified role nodejs appears to already exist. Use --force to replace it.\r\n- nodejs was NOT installed successfully.\r\n- you can use --ignore-errors to skip failed roles.\r\n```\r\n\r\n##### Additional Info:\r\n\r\n- One can specify `--ignore-errors` to ignore the failed roles, however, this is not the appropriate solution, since this would also ignore errors where `ansible-galaxy` failed to fetch a role from a remote server.\r\n\r\n- It should be possible to obtain the version of the installed role via `meta/.galaxy_install_info` file. For example, for the `nodejs` role installed before, it has the following contents:\r\n\r\n    ```\r\n    {install_date: 'Mon Jun 15 11:56:40 2015', version: 592a239dca52e1c5ff79cfefd0072efe3831428e}\r\n    ```\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/184263474","html_url":"https://github.com/ansible/ansible/issues/11266#issuecomment-184263474","issue_url":"https://api.github.com/repos/ansible/ansible/issues/11266","id":184263474,"user":{"login":"scottcunningham","id":982046,"avatar_url":"https://avatars.githubusercontent.com/u/982046?v=3","gravatar_id":"","url":"https://api.github.com/users/scottcunningham","html_url":"https://github.com/scottcunningham","followers_url":"https://api.github.com/users/scottcunningham/followers","following_url":"https://api.github.com/users/scottcunningham/following{/other_user}","gists_url":"https://api.github.com/users/scottcunningham/gists{/gist_id}","starred_url":"https://api.github.com/users/scottcunningham/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottcunningham/subscriptions","organizations_url":"https://api.github.com/users/scottcunningham/orgs","repos_url":"https://api.github.com/users/scottcunningham/repos","events_url":"https://api.github.com/users/scottcunningham/events{/privacy}","received_events_url":"https://api.github.com/users/scottcunningham/received_events","type":"User","site_admin":false},"created_at":"2016-02-15T15:47:04Z","updated_at":"2016-02-15T15:47:04Z","body":":+1: "}}