{"action":"created","issue":{"url":"https://api.github.com/repos/ansible/ansible/issues/10274","repository_url":"https://api.github.com/repos/ansible/ansible","labels_url":"https://api.github.com/repos/ansible/ansible/issues/10274/labels{/name}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/10274/comments","events_url":"https://api.github.com/repos/ansible/ansible/issues/10274/events","html_url":"https://github.com/ansible/ansible/pull/10274","id":58053170,"number":10274,"title":"multi-file custom modules (with ModuleReplacer), outside /ansible/module...","user":{"login":"sirkubax","id":3442120,"avatar_url":"https://avatars.githubusercontent.com/u/3442120?v=3","gravatar_id":"","url":"https://api.github.com/users/sirkubax","html_url":"https://github.com/sirkubax","followers_url":"https://api.github.com/users/sirkubax/followers","following_url":"https://api.github.com/users/sirkubax/following{/other_user}","gists_url":"https://api.github.com/users/sirkubax/gists{/gist_id}","starred_url":"https://api.github.com/users/sirkubax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sirkubax/subscriptions","organizations_url":"https://api.github.com/users/sirkubax/orgs","repos_url":"https://api.github.com/users/sirkubax/repos","events_url":"https://api.github.com/users/sirkubax/events{/privacy}","received_events_url":"https://api.github.com/users/sirkubax/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ansible/ansible/labels/feature_pull_request","name":"feature_pull_request","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-02-18T10:54:54Z","updated_at":"2016-02-27T22:02:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ansible/ansible/pulls/10274","html_url":"https://github.com/ansible/ansible/pull/10274","diff_url":"https://github.com/ansible/ansible/pull/10274.diff","patch_url":"https://github.com/ansible/ansible/pull/10274.patch"},"body":"This change allows writing multi-file ansible modules (and store them outside ansible/module_utils/ directory - for easy ansible core upgrade).\r\nThe custom_modules can have external imports, that would be recognized by ModuleReplacer.\r\n\r\nThe idea is, that you can configure you custom modules directory (like other ansible vars):\r\nEXAMPLE:\r\n- via env: ANSIBLE_CUSTOM_MODULES\r\n- (or ansible.cfg) custom_modules = some_path/lib/modules/\r\n\r\nAnd place there Your files:\r\n\r\n```\r\nsome_path/lib/\r\n                   modules/\r\n                            conf.py\r\n                            tools.py\r\n                            web-service.py\r\n                            websrv -> web-service.py\r\n```\r\n\r\nThen just include 'ansible.module_custom' in Your custom module (mine -> websrv): \r\n```\r\nweb-service.py:\r\n\r\nfrom ansible.module_custom.tools import *\r\nfrom ansible.module_custom.conf import *\r\nimport time\r\n#and still You can import from ansible module_utils\r\n#from ansible.module_utils.basic import *\r\n\r\n#some code\r\n```\r\n\r\nand that would be merged by ModuleReplacer.\r\n\r\n-------------------\r\nInfo - in the ansible.cfg I have already 'library_path'\r\n\r\nansible.cfg\r\ncustom_modules = some_path/lib/modules/\r\nlibrary_path   = some_path/lib/modules/\r\n\r\nWe could use the same variable, but it would be wise to have this configuration separated."},"comment":{"url":"https://api.github.com/repos/ansible/ansible/issues/comments/189737030","html_url":"https://github.com/ansible/ansible/pull/10274#issuecomment-189737030","issue_url":"https://api.github.com/repos/ansible/ansible/issues/10274","id":189737030,"user":{"login":"defionscode","id":4664162,"avatar_url":"https://avatars.githubusercontent.com/u/4664162?v=3","gravatar_id":"","url":"https://api.github.com/users/defionscode","html_url":"https://github.com/defionscode","followers_url":"https://api.github.com/users/defionscode/followers","following_url":"https://api.github.com/users/defionscode/following{/other_user}","gists_url":"https://api.github.com/users/defionscode/gists{/gist_id}","starred_url":"https://api.github.com/users/defionscode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/defionscode/subscriptions","organizations_url":"https://api.github.com/users/defionscode/orgs","repos_url":"https://api.github.com/users/defionscode/repos","events_url":"https://api.github.com/users/defionscode/events{/privacy}","received_events_url":"https://api.github.com/users/defionscode/received_events","type":"User","site_admin":false},"created_at":"2016-02-27T22:02:36Z","updated_at":"2016-02-27T22:02:36Z","body":"It's being worked on internally at the moment."}}