{"action":"created","issue":{"url":"https://api.github.com/repos/saltstack/salt/issues/33581","repository_url":"https://api.github.com/repos/saltstack/salt","labels_url":"https://api.github.com/repos/saltstack/salt/issues/33581/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/33581/comments","events_url":"https://api.github.com/repos/saltstack/salt/issues/33581/events","html_url":"https://github.com/saltstack/salt/pull/33581","id":157206696,"number":33581,"title":"Call zypper refresh after adding/modifying a repository","user":{"login":"dincamihai","id":1615643,"avatar_url":"https://avatars.githubusercontent.com/u/1615643?v=3","gravatar_id":"","url":"https://api.github.com/users/dincamihai","html_url":"https://github.com/dincamihai","followers_url":"https://api.github.com/users/dincamihai/followers","following_url":"https://api.github.com/users/dincamihai/following{/other_user}","gists_url":"https://api.github.com/users/dincamihai/gists{/gist_id}","starred_url":"https://api.github.com/users/dincamihai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dincamihai/subscriptions","organizations_url":"https://api.github.com/users/dincamihai/orgs","repos_url":"https://api.github.com/users/dincamihai/repos","events_url":"https://api.github.com/users/dincamihai/events{/privacy}","received_events_url":"https://api.github.com/users/dincamihai/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/saltstack/salt/labels/Pending%20Discussion","name":"Pending Discussion","color":"c7def8"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2016-05-27T13:28:20Z","updated_at":"2016-05-31T17:24:46Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/saltstack/salt/pulls/33581","html_url":"https://github.com/saltstack/salt/pull/33581","diff_url":"https://github.com/saltstack/salt/pull/33581.diff","patch_url":"https://github.com/saltstack/salt/pull/33581.patch"},"body":"### What does this PR do?\r\ncompletes this previous PR https://github.com/saltstack/salt/pull/33432\r\nand it attempts to fix this issue https://github.com/saltstack/salt/issues/27155\r\n\r\n### What issues does this PR fix or reference?\r\n\r\nIn my previous attempt to fix this I was tricked by zypper's caching mechanism which saves the gpg key once accepted and it made me believe that just fixing the `--gpg-auto-import-keys` position fixes the issue.\r\nI talked today with the maintainer of 'zypper' and it seems that an additional call like this\r\n```bash\r\nzypper --gpg-auto-import-keys refresh\r\n```\r\nis necessary after adding the repository.\r\nAt the moment, this is the only way to prevent subsequent `zypper refresh` from asking for confirmation of the gpg key.\r\nI didn't revert the previous commit introduced with https://github.com/saltstack/salt/pull/33432 because it still fixes the related issue with using `--gpg-auto-import-keys` in the wrong position when calling zypper.\r\n\r\n### Tests written?\r\n\r\nYes.\r\nMeanwhile I learned more about zypper and *modules/zypper.py::mod_repo* so I added more tests to capture the behavior of mod_repo when passing different parameters to it and to make sure the repository is refreshed only when specifically requested in the sls file with **gpgautoimport: True**\r\n\r\nPossible scenarios:\r\n- *url* only\r\n  ```yaml\r\n  repo_with_gpg:\r\n    pkgrepo.managed:\r\n      - url: {{ REPO_URL }}\r\n  ```\r\n  - when the repository is new:\r\n    - this only adds the new repository and does not call modify nor refresh\r\n\r\n  - when the repository already exist:\r\n    - raises *CommandExecutionError: Specified arguments did not result in modification of repo*\r\n\r\n- *url* and *refresh*\r\n  ```yaml\r\n  repo_with_gpg:\r\n    pkgrepo.managed:\r\n      - url: {{ REPO_URL }}\r\n      - refresh: True,\r\n  ```\r\n  - when the repository is new:\r\n    - this adds the repository, then modifies it by updating its *autorefresh* option but doesn't call `zypper refresh`\r\n  - when the repository already exist:\r\n    - modifies the repository by updating its *autorefresh* option but doesn't call `zypper refresh`\r\n\r\n- *url* and *gpgautoimport*\r\n  ```yaml\r\n  repo_with_gpg:\r\n    pkgrepo.managed:\r\n      - url: {{ REPO_URL }}\r\n      - gpgautoimport: True\r\n  ```\r\n  - when the repository is new:\r\n    - this adds the repository and refreshes with `zypper --gpg-auto-import-keys refresh <repo-name>` but does not call modify\r\n\r\n  - when the repository already exist:\r\n    - this only calls `zypper --gpg-auto-import-keys refresh <repo-name>` on the existing repository\r\n\r\n- *url*, *refresh* and *gpgautoimport*\r\n  ```yaml\r\n  repo_with_gpg:\r\n    pkgrepo.managed:\r\n      - url: {{ REPO_URL }}\r\n      - refresh: True,\r\n      - gpgautoimport: True\r\n  ```\r\n  - when the repository is new:\r\n    - this adds the repository, then modifies it by updating its *autorefresh* option and then refreshes with `zypper --gpg-auto-import-keys refresh <repo-name>`\r\n\r\n  - when the repository already exist:\r\n    - modifies the repository by updating its *autorefresh* option and calls refresh"},"comment":{"url":"https://api.github.com/repos/saltstack/salt/issues/comments/222759057","html_url":"https://github.com/saltstack/salt/pull/33581#issuecomment-222759057","issue_url":"https://api.github.com/repos/saltstack/salt/issues/33581","id":222759057,"user":{"login":"cachedout","id":111616,"avatar_url":"https://avatars.githubusercontent.com/u/111616?v=3","gravatar_id":"","url":"https://api.github.com/users/cachedout","html_url":"https://github.com/cachedout","followers_url":"https://api.github.com/users/cachedout/followers","following_url":"https://api.github.com/users/cachedout/following{/other_user}","gists_url":"https://api.github.com/users/cachedout/gists{/gist_id}","starred_url":"https://api.github.com/users/cachedout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cachedout/subscriptions","organizations_url":"https://api.github.com/users/cachedout/orgs","repos_url":"https://api.github.com/users/cachedout/repos","events_url":"https://api.github.com/users/cachedout/events{/privacy}","received_events_url":"https://api.github.com/users/cachedout/received_events","type":"User","site_admin":false},"created_at":"2016-05-31T17:24:46Z","updated_at":"2016-05-31T17:24:46Z","body":"Go Go Jenkins!"}}
{"actor":{"display_login":"cachedout"}}