{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/42243","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/42243/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/42243/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/42243/events","html_url":"https://github.com/ansible/ansible/issues/42243","id":337865871,"node_id":"MDU6SXNzdWUzMzc4NjU4NzE=","number":42243,"title":"k8s module ignores namespace parameter when creating template","user":{"login":"frestr","id":7038699,"node_id":"MDQ6VXNlcjcwMzg2OTk=","avatar_url":"https://avatars3.githubusercontent.com/u/7038699?v=4","gravatar_id":"","url":"https://api.github.com/users/frestr","html_url":"https://github.com/frestr","followers_url":"https://api.github.com/users/frestr/followers","following_url":"https://api.github.com/users/frestr/following{/other_user}","gists_url":"https://api.github.com/users/frestr/gists{/gist_id}","starred_url":"https://api.github.com/users/frestr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frestr/subscriptions","organizations_url":"https://api.github.com/users/frestr/orgs","repos_url":"https://api.github.com/users/frestr/repos","events_url":"https://api.github.com/users/frestr/events{/privacy}","received_events_url":"https://api.github.com/users/frestr/received_events","type":"User","site_admin":false},"labels":[{"id":835286067,"node_id":"MDU6TGFiZWw4MzUyODYwNjc=","url":"https://api.github.com/repos/ansible/ansible/labels/affects_2.6","name":"affects_2.6","color":"ededed","default":false},{"id":785271699,"node_id":"MDU6TGFiZWw3ODUyNzE2OTk=","url":"https://api.github.com/repos/ansible/ansible/labels/bug","name":"bug","color":"fbca04","default":true},{"id":496359346,"node_id":"MDU6TGFiZWw0OTYzNTkzNDY=","url":"https://api.github.com/repos/ansible/ansible/labels/module","name":"module","color":"1d76db","default":false},{"id":636327968,"node_id":"MDU6TGFiZWw2MzYzMjc5Njg=","url":"https://api.github.com/repos/ansible/ansible/labels/support:community","name":"support:community","color":"ededed","default":false},{"id":942378949,"node_id":"MDU6TGFiZWw5NDIzNzg5NDk=","url":"https://api.github.com/repos/ansible/ansible/labels/traceback","name":"traceback","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-07-03T11:51:11Z","updated_at":"2018-07-11T17:58:31Z","closed_at":null,"author_association":"NONE","body":"<!---\r\nVerify first that your issue/request is not already reported on GitHub.\r\nTHIS FORM WILL BE READ BY A MACHINE, COMPLETE ALL SECTIONS AS DESCRIBED.\r\nAlso test if the latest release, and devel branch are affected too.\r\nALWAYS add information AFTER (OUTSIDE) these html comments.\r\nOtherwise it may end up being automatically closed by our bot. -->\r\n\r\n##### SUMMARY\r\n<!--- Explain the problem briefly -->\r\n\r\nThe namespace parameter in the k8s module is ignored when trying to create a template in OpenShift.\r\n\r\nThis is mostly an issue when the resource definition is in a separate file, as the namespace has to be manually changed in the template config for each deployment.\r\n\r\n##### ISSUE TYPE\r\n - Bug Report\r\n\r\n##### COMPONENT NAME\r\n<!--- Insert, BELOW THIS COMMENT, the name of the module, plugin, task or feature.\r\nDo not include extra details here, e.g. \"vyos_command\" not \"the network module vyos_command\" or the full path-->\r\n\r\nk8s\r\n\r\n##### ANSIBLE VERSION\r\n<!--- Paste, BELOW THIS COMMENT, verbatim output from \"ansible --version\" between quotes below -->\r\n```\r\nansible 2.6.0                                                                                                        \r\n  config file = /etc/ansible/ansible.cfg                                                                             \r\n  configured module search path = [u'/home/frestr01/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible                                    \r\n  executable location = /usr/local/bin/ansible                                                                       \r\n  python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]                                      \r\n```\r\n\r\n##### CONFIGURATION\r\n<!--- If using Ansible 2.4 or above, paste, BELOW THIS COMMENT, the results of \"ansible-config dump --only-changed\"\r\nOtherwise, mention any settings you have changed/added/removed in ansible.cfg\r\n(or using the ANSIBLE_* environment variables).-->\r\n\r\nDEFAULT_STDOUT_CALLBACK(env: ANSIBLE_STDOUT_CALLBACK) = debug\r\n\r\n##### OS / ENVIRONMENT\r\n<!--- Mention, BELOW THIS COMMENT, the OS you are running Ansible from, and the OS you are\r\nmanaging, or say \"N/A\" for anything that is not platform-specific.\r\nAlso mention the specific version of what you are trying to control,\r\ne.g. if this is a network bug the version of firmware on the network device.-->\r\n\r\nUbuntu 16.04\r\nOpenShift 3.9.0\r\n\r\n##### STEPS TO REPRODUCE\r\n<!--- For bugs, show exactly how to reproduce the problem, using a minimal test-case.\r\nFor new features, show how the feature would be used. -->\r\n\r\n<!--- Paste example playbooks or commands between quotes below -->\r\n```yaml\r\n---\r\n- name: \"Create template\"\r\n  hosts: localhost\r\n\r\n  tasks:\r\n    - k8s:\r\n        state: present\r\n        namespace: test-ns\r\n        definition:\r\n          apiVersion: v1\r\n          kind: Template\r\n          metadata:\r\n            name: test\r\n```\r\n\r\n<!--- You can also paste gist.github.com links for larger files -->\r\n\r\n##### EXPECTED RESULTS\r\n<!--- What did you expect to happen when running the steps above? -->\r\n\r\nThe test template is created in the test-ns namespace.\r\n\r\n##### ACTUAL RESULTS\r\n<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->\r\n\r\nThe error `ValueError: Namespace is required for v1.Template` is generated.\r\n\r\nThe result is the same if using the resource_definition parameter instead of definition in the playbook.\r\n\r\nIf the namespace parameter is inside the definition, the template creation succeeds. Thus, it seems like k8s doesn't add the specified namespace to the template.\r\n\r\n\r\n<!--- Paste verbatim command output between quotes below -->\r\n```\r\nansible-playbook 2.6.0\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = [u'/home/frestr01/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible\r\n  executable location = /usr/local/bin/ansible-playbook\r\n  python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]\r\nUsing /etc/ansible/ansible.cfg as config file\r\nParsed /etc/ansible/hosts inventory source with ini plugin\r\n [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match\r\n'all'\r\n\r\n\r\nPLAYBOOK: test.yml ****************************************************************************************************\r\n1 plays in test.yml\r\n\r\nPLAY [Create template] ************************************************************************************************\r\n\r\nTASK [Gathering Facts] ************************************************************************************************\r\ntask path: /home/frestr01/Documents/ans_k8s_bug_reproduce/test.yml:2\r\n<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: frestr01\r\n<127.0.0.1> EXEC /bin/sh -c 'echo ~frestr01 && sleep 0'\r\n<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p \"` echo /home/frestr01/.ansible/tmp/ansible-tmp-1530618157.54-77764\r\n151602697 `\" && echo ansible-tmp-1530618157.54-77764151602697=\"` echo /home/frestr01/.ansible/tmp/ansible-tmp-153061815\r\n7.54-77764151602697 `\" ) && sleep 0'\r\nUsing module file /usr/local/lib/python2.7/dist-packages/ansible/modules/system/setup.py\r\n<127.0.0.1> PUT /home/frestr01/.ansible/tmp/ansible-local-8978cVmQq7/tmpYqNggF TO /home/frestr01/.ansible/tmp/ansible-t\r\nmp-1530618157.54-77764151602697/setup.py\r\n<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/frestr01/.ansible/tmp/ansible-tmp-1530618157.54-77764151602697/ /home/fres\r\ntr01/.ansible/tmp/ansible-tmp-1530618157.54-77764151602697/setup.py && sleep 0'\r\n<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/frestr01/.ansible/tmp/ansible-tmp-1530618157.54-77764151602697/setup\r\n.py && sleep 0'\r\n<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/frestr01/.ansible/tmp/ansible-tmp-1530618157.54-77764151602697/ > /dev/null\r\n 2>&1 && sleep 0'\r\nok: [localhost]\r\nMETA: ran handlers\r\n\r\nTASK [k8s] ************************************************************************************************************\r\ntask path: /home/frestr01/Documents/ans_k8s_bug_reproduce/test.yml:6\r\n<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: frestr01\r\n<127.0.0.1> EXEC /bin/sh -c 'echo ~frestr01 && sleep 0'\r\n<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p \"` echo /home/frestr01/.ansible/tmp/ansible-tmp-1530618160.08-16423\r\n9037550164 `\" && echo ansible-tmp-1530618160.08-164239037550164=\"` echo /home/frestr01/.ansible/tmp/ansible-tmp-1530618\r\n160.08-164239037550164 `\" ) && sleep 0'\r\nUsing module file /usr/local/lib/python2.7/dist-packages/ansible/modules/clustering/k8s/k8s.py\r\n<127.0.0.1> PUT /home/frestr01/.ansible/tmp/ansible-local-8978cVmQq7/tmp5VvXqz TO /home/frestr01/.ansible/tmp/ansible-t\r\nmp-1530618160.08-164239037550164/k8s.py\r\n<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/frestr01/.ansible/tmp/ansible-tmp-1530618160.08-164239037550164/ /home/fre\r\nstr01/.ansible/tmp/ansible-tmp-1530618160.08-164239037550164/k8s.py && sleep 0'\r\n<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/frestr01/.ansible/tmp/ansible-tmp-1530618160.08-164239037550164/k8s.\r\npy && sleep 0'\r\n<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/frestr01/.ansible/tmp/ansible-tmp-1530618160.08-164239037550164/ > /dev/nul\r\nl 2>&1 && sleep 0'\r\nThe full traceback is:\r\nTraceback (most recent call last):\r\n  File \"/tmp/ansible_CUZWXz/ansible_module_k8s.py\", line 165, in <module>\r\n    main()\r\n  File \"/tmp/ansible_CUZWXz/ansible_module_k8s.py\", line 161, in main\r\n    KubernetesRawModule().execute_module()\r\n  File \"/tmp/ansible_CUZWXz/ansible_modlib.zip/ansible/module_utils/k8s/raw.py\", line 80, in execute_module\r\n  File \"/tmp/ansible_CUZWXz/ansible_modlib.zip/ansible/module_utils/k8s/raw.py\", line 138, in perform_action\r\n  File \"/usr/local/lib/python2.7/dist-packages/openshift/dynamic/client.py\", line 31, in inner\r\n    resp = func(self, resource, *args, **kwargs)\r\n  File \"/usr/local/lib/python2.7/dist-packages/openshift/dynamic/client.py\", line 159, in create\r\n    namespace = self.ensure_namespace(resource, namespace, body)\r\n  File \"/usr/local/lib/python2.7/dist-packages/openshift/dynamic/client.py\", line 142, in ensure_namespace\r\n    raise ValueError(\"Namespace is required for {}.{}\".format(resource.group_version, resource.kind))\r\nValueError: Namespace is required for v1.Template\r\n\r\nfatal: [localhost]: FAILED! => {\r\n    \"changed\": false, \r\n    \"rc\": 1\r\n}\r\n\r\nMSG:\r\n\r\nMODULE FAILURE\r\n\r\n\r\nMODULE_STDERR:\r\n\r\nTraceback (most recent call last):\r\n  File \"/tmp/ansible_CUZWXz/ansible_module_k8s.py\", line 165, in <module>\r\n    main()\r\n  File \"/tmp/ansible_CUZWXz/ansible_module_k8s.py\", line 161, in main\r\n    KubernetesRawModule().execute_module()\r\n  File \"/tmp/ansible_CUZWXz/ansible_modlib.zip/ansible/module_utils/k8s/raw.py\", line 80, in execute_module\r\n  File \"/tmp/ansible_CUZWXz/ansible_modlib.zip/ansible/module_utils/k8s/raw.py\", line 138, in perform_action\r\n  File \"/usr/local/lib/python2.7/dist-packages/openshift/dynamic/client.py\", line 31, in inner\r\n    resp = func(self, resource, *args, **kwargs)\r\n  File \"/usr/local/lib/python2.7/dist-packages/openshift/dynamic/client.py\", line 159, in create\r\n    namespace = self.ensure_namespace(resource, namespace, body)\r\n  File \"/usr/local/lib/python2.7/dist-packages/openshift/dynamic/client.py\", line 142, in ensure_namespace\r\n    raise ValueError(\"Namespace is required for {}.{}\".format(resource.group_version, resource.kind))\r\nValueError: Namespace is required for v1.Template\r\n\r\n\r\n        to retry, use: --limit @/home/frestr01/Documents/ans_k8s_bug_reproduce/test.retry\r\n\r\nPLAY RECAP ************************************************************************************************************\r\nlocalhost                  : ok=1    changed=0    unreachable=0    failed=1   \r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/404258204","html_url":"https://github.com/ansible/ansible/issues/42243#issuecomment-404258204","issue_url":"https://api.github.com/repos/ansible/ansible/issues/42243","id":404258204,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNDI1ODIwNA==","user":{"login":"ansibot","id":6585283,"node_id":"MDQ6VXNlcjY1ODUyODM=","avatar_url":"https://avatars0.githubusercontent.com/u/6585283?v=4","gravatar_id":"","url":"https://api.github.com/users/ansibot","html_url":"https://github.com/ansibot","followers_url":"https://api.github.com/users/ansibot/followers","following_url":"https://api.github.com/users/ansibot/following{/other_user}","gists_url":"https://api.github.com/users/ansibot/gists{/gist_id}","starred_url":"https://api.github.com/users/ansibot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansibot/subscriptions","organizations_url":"https://api.github.com/users/ansibot/orgs","repos_url":"https://api.github.com/users/ansibot/repos","events_url":"https://api.github.com/users/ansibot/events{/privacy}","received_events_url":"https://api.github.com/users/ansibot/received_events","type":"User","site_admin":false},"created_at":"2018-07-11T17:58:30Z","updated_at":"2018-07-11T17:58:30Z","author_association":"CONTRIBUTOR","body":"cc @willthames\n[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)\n<!--- boilerplate: notify --->"}}
{"actor":{"display_login":"ansibot"}}