{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/19318","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/19318/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/19318/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/19318/events","html_url":"https://github.com/ansible/ansible/pull/19318","id":195398275,"number":19318,"title":"Set os_server metadata on existing instances","user":{"login":"manics","id":1644105,"avatar_url":"https://avatars.githubusercontent.com/u/1644105?v=3","gravatar_id":"","url":"https://api.github.com/users/manics","html_url":"https://github.com/manics","followers_url":"https://api.github.com/users/manics/followers","following_url":"https://api.github.com/users/manics/following{/other_user}","gists_url":"https://api.github.com/users/manics/gists{/gist_id}","starred_url":"https://api.github.com/users/manics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manics/subscriptions","organizations_url":"https://api.github.com/users/manics/orgs","repos_url":"https://api.github.com/users/manics/repos","events_url":"https://api.github.com/users/manics/events{/privacy}","received_events_url":"https://api.github.com/users/manics/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-13T23:23:39Z","updated_at":"2016-12-13T23:23:39Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ansible/ansible/pulls/19318","html_url":"https://github.com/ansible/ansible/pull/19318","diff_url":"https://github.com/ansible/ansible/pull/19318.diff","patch_url":"https://github.com/ansible/ansible/pull/19318.patch"},"body":"##### ISSUE TYPE: Feature Pull Request\r\n\r\n##### COMPONENT NAME: cloud/openstack/os_server.py\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste verbatim output from “ansible --version” between quotes below -->\r\n```\r\nansible 2.2.0.0\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\nAt present `os_server` can modify the floating IP on an existing instance, but most other properties are unchanged since they may require a rebuild of the instance. However user properties (the `os_server` `meta` arg) can be updated easily.\r\n\r\nNew or existing metadata keys/values will be added/updated on an existing instance, no keys will be deleted. This follows the behaviour of `shade.openstackcloud.OpenStackCloud.set_server_metadata`.\r\n\r\nFixes #5500.\r\n\r\n`test.yml`:\r\n```\r\n- hosts: localhost\r\n\r\n  tasks:\r\n\r\n  - os_server:\r\n      flavor_ram: 1024\r\n      image: CentOS7\r\n      key: test-key\r\n      name: test-1\r\n    register: instance\r\n\r\n  - debug: msg={{ instance.openstack.metadata }}\r\n```\r\n`ansible-playbook test.yml`\r\n```\r\n [WARNING]: provided hosts list is empty, only localhost is available\r\n\r\n\r\nPLAY [localhost] ***************************************************************\r\n\r\nTASK [setup] *******************************************************************\r\nok: [localhost]\r\n\r\nTASK [os_server] ***************************************************************\r\nchanged: [localhost]\r\n\r\nTASK [debug] *******************************************************************\r\nok: [localhost] => {\r\n    \"msg\": {}\r\n}\r\n\r\nPLAY RECAP *********************************************************************\r\nlocalhost                  : ok=3    changed=1    unreachable=0    failed=0   \r\n```\r\n\r\nAdd some metadata:\r\n```\r\n  - os_server:\r\n      flavor_ram: 1024\r\n      image: CentOS7\r\n      key: test-key\r\n      meta:\r\n        groups: 'test-group'\r\n      name: test-1\r\n    register: instance\r\n```\r\n\r\nRerun without this PR:\r\n```\r\nTASK [os_server] ***************************************************************\r\nok: [localhost]\r\n\r\nTASK [debug] *******************************************************************\r\nok: [localhost] => {\r\n    \"msg\": {}\r\n}\r\n\r\nPLAY RECAP *********************************************************************\r\nlocalhost                  : ok=3    changed=0    unreachable=0    failed=0   \r\n```\r\nRerun with this PR:\r\n```\r\nTASK [os_server] ***************************************************************\r\nchanged: [localhost]\r\n\r\nTASK [debug] *******************************************************************\r\nok: [localhost] => {\r\n    \"msg\": {\r\n        \"groups\": \"test-group\"\r\n    }\r\n}\r\n\r\nPLAY RECAP *********************************************************************\r\nlocalhost                  : ok=3    changed=1    unreachable=0    failed=0   \r\n```"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/266894377","html_url":"https://github.com/ansible/ansible/pull/19318#issuecomment-266894377","issue_url":"https://api.github.com/repos/ansible/ansible/issues/19318","id":266894377,"user":{"login":"manics","id":1644105,"avatar_url":"https://avatars.githubusercontent.com/u/1644105?v=3","gravatar_id":"","url":"https://api.github.com/users/manics","html_url":"https://github.com/manics","followers_url":"https://api.github.com/users/manics/followers","following_url":"https://api.github.com/users/manics/following{/other_user}","gists_url":"https://api.github.com/users/manics/gists{/gist_id}","starred_url":"https://api.github.com/users/manics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manics/subscriptions","organizations_url":"https://api.github.com/users/manics/orgs","repos_url":"https://api.github.com/users/manics/repos","events_url":"https://api.github.com/users/manics/events{/privacy}","received_events_url":"https://api.github.com/users/manics/received_events","type":"User","site_admin":false},"created_at":"2016-12-13T23:23:39Z","updated_at":"2016-12-13T23:23:39Z","body":"Migrated from https://github.com/ansible/ansible-modules-core/pull/5503"}}
{"actor":{"display_login":"manics"}}