{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3072","repository_url":"https://api.github.com/repos/ansible/ansible-modules-core","labels_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3072/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3072/comments","events_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3072/events","html_url":"https://github.com/ansible/ansible-modules-core/pull/3072","id":134810550,"number":3072,"title":"add 'only_upgrade' switch to apt module","user":{"login":"rsommer","id":178013,"avatar_url":"https://avatars.githubusercontent.com/u/178013?v=3","gravatar_id":"","url":"https://api.github.com/users/rsommer","html_url":"https://github.com/rsommer","followers_url":"https://api.github.com/users/rsommer/followers","following_url":"https://api.github.com/users/rsommer/following{/other_user}","gists_url":"https://api.github.com/users/rsommer/gists{/gist_id}","starred_url":"https://api.github.com/users/rsommer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rsommer/subscriptions","organizations_url":"https://api.github.com/users/rsommer/orgs","repos_url":"https://api.github.com/users/rsommer/repos","events_url":"https://api.github.com/users/rsommer/events{/privacy}","received_events_url":"https://api.github.com/users/rsommer/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible-modules-core/labels/needs_rebase","name":"needs_rebase","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-02-19T09:10:09Z","updated_at":"2016-03-18T08:08:22Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/pulls/3072","html_url":"https://github.com/ansible/ansible-modules-core/pull/3072","diff_url":"https://github.com/ansible/ansible-modules-core/pull/3072.diff","patch_url":"https://github.com/ansible/ansible-modules-core/pull/3072.patch"},"body":"##### Issue Type:\r\n\r\nPlease pick one and delete the rest:\r\n - Feature Pull Request\r\n\r\n##### Plugin Name:\r\n\r\napt\r\n\r\n##### Ansible Version:\r\n\r\n```\r\nansible 2.1.0 (devel f9526b2ab2) last updated 2016/02/19 09:45:54 (GMT +200)\r\n  lib/ansible/modules/core: (devel 4822861483) last updated 2016/02/19 09:56:13 (GMT +200)\r\n  lib/ansible/modules/extras: (detached HEAD f6c5ed987f) last updated 2016/02/19 08:40:12 (GMT +200)\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = Default w/o overrides\r\n```\r\n\r\n##### Summary:\r\n\r\nEspecially when managing a lot of hosts it comes in handy to be able to just install/upgrade packages that are already installed. apt-get provides the '--only-upgrade' flag for this. You can now run an adhoc command or a special playbook against all your hosts to upgrade a package only where it is already installed.\r\n\r\n##### Example output:\r\n\r\n```\r\n$ ansible all -m apt -a \"name=postgresql-9.3 state=present only_upgrade=True\"\r\n\r\ndb.example.com | SUCCESS => {\r\n    \"cache_update_time\": 0, \r\n    \"cache_updated\": false, \r\n    \"changed\": true, \r\n    \"stderr\": \"\", \r\n    \"stdout\": \"Reading package lists...\\nBuilding dependency tree...\\nReading state information...\\nSkipping postgresql-9.3, it is not installed and only upgrades are requested.\\n0 upgraded, 0 newly installed, 0 to remove and 67 not upgraded.\\n\", \r\n    \"stdout_lines\": [\r\n        \"Reading package lists...\", \r\n        \"Building dependency tree...\", \r\n        \"Reading state information...\", \r\n        \"Skipping postgresql-9.3, it is not installed and only upgrades are requested.\", \r\n        \"0 upgraded, 0 newly installed, 0 to remove and 67 not upgraded.\"\r\n    ]\r\n}\r\n```\r\n\r\nA current drawback is that \"changed\" is always true.\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/comments/198245879","html_url":"https://github.com/ansible/ansible-modules-core/pull/3072#issuecomment-198245879","issue_url":"https://api.github.com/repos/ansible/ansible-modules-core/issues/3072","id":198245879,"user":{"login":"mika","id":115592,"avatar_url":"https://avatars.githubusercontent.com/u/115592?v=3","gravatar_id":"","url":"https://api.github.com/users/mika","html_url":"https://github.com/mika","followers_url":"https://api.github.com/users/mika/followers","following_url":"https://api.github.com/users/mika/following{/other_user}","gists_url":"https://api.github.com/users/mika/gists{/gist_id}","starred_url":"https://api.github.com/users/mika/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mika/subscriptions","organizations_url":"https://api.github.com/users/mika/orgs","repos_url":"https://api.github.com/users/mika/repos","events_url":"https://api.github.com/users/mika/events{/privacy}","received_events_url":"https://api.github.com/users/mika/received_events","type":"User","site_admin":false},"created_at":"2016-03-18T08:08:22Z","updated_at":"2016-03-18T08:08:22Z","body":"worksforme"}}