{"action":"opened","number":12826,"pull_request":{"url":"https://api.github.com/repos/ansible/ansible/pulls/12826","id":48073818,"html_url":"https://github.com/ansible/ansible/pull/12826","diff_url":"https://github.com/ansible/ansible/pull/12826.diff","patch_url":"https://github.com/ansible/ansible/pull/12826.patch","issue_url":"https://api.github.com/repos/ansible/ansible/issues/12826","number":12826,"state":"open","locked":false,"title":"Add splitpart filter for template string splitting","user":{"login":"mhuxtable","id":5958122,"avatar_url":"https://avatars.githubusercontent.com/u/5958122?v=3","gravatar_id":"","url":"https://api.github.com/users/mhuxtable","html_url":"https://github.com/mhuxtable","followers_url":"https://api.github.com/users/mhuxtable/followers","following_url":"https://api.github.com/users/mhuxtable/following{/other_user}","gists_url":"https://api.github.com/users/mhuxtable/gists{/gist_id}","starred_url":"https://api.github.com/users/mhuxtable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhuxtable/subscriptions","organizations_url":"https://api.github.com/users/mhuxtable/orgs","repos_url":"https://api.github.com/users/mhuxtable/repos","events_url":"https://api.github.com/users/mhuxtable/events{/privacy}","received_events_url":"https://api.github.com/users/mhuxtable/received_events","type":"User","site_admin":false},"body":"This adds an additional Jinja filter for splitting delimited strings and returning an individual element by index number.\r\n\r\nI have added this (trivial) filter to address a need to split input data in a template. The data are delimited by colon characters (\":\"), and it seems prudent to split this natively in Ansible rather than rely on forking out to other commands in a shell environment.\r\n\r\nExample usage:\r\n```\r\n- hosts: localhost\r\n  vars:\r\n    to_split: my:example:colon:delimited:data\r\n  tasks:\r\n    - name: split data in variable to_split on a colon, returning element at index 3\r\n      debug: msg=\"{{ to_split | splitpart(3, ':') }}\"\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nusername-pc:ansible username$ ansible-playbook test.yml -c local\r\n [WARNING]: provided hosts list is empty, only localhost is available\r\n\r\n\r\nPLAY ***************************************************************************\r\n\r\nTASK [setup] *******************************************************************\r\nok: [localhost -> localhost]\r\n\r\nTASK [split data in variable to_split on a colon, returning element at index 3] \r\nok: [localhost -> localhost] => {\r\n    \"changed\": false, \r\n    \"msg\": \"delimited\"\r\n}\r\n\r\nPLAY RECAP *********************************************************************\r\nlocalhost                  : ok=2    changed=0    unreachable=0    failed=0   \r\n```","created_at":"2015-10-19T13:50:26Z","updated_at":"2015-10-19T13:50:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ansible/ansible/pulls/12826/commits","review_comments_url":"https://api.github.com/repos/ansible/ansible/pulls/12826/comments","review_comment_url":"https://api.github.com/repos/ansible/ansible/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/12826/comments","statuses_url":"https://api.github.com/repos/ansible/ansible/statuses/d7bbb4e43095db25b32860e2e9d8df334d2a89d5","head":{"label":"mhuxtable:splitpart-filter","ref":"splitpart-filter","sha":"d7bbb4e43095db25b32860e2e9d8df334d2a89d5","user":{"login":"mhuxtable","id":5958122,"avatar_url":"https://avatars.githubusercontent.com/u/5958122?v=3","gravatar_id":"","url":"https://api.github.com/users/mhuxtable","html_url":"https://github.com/mhuxtable","followers_url":"https://api.github.com/users/mhuxtable/followers","following_url":"https://api.github.com/users/mhuxtable/following{/other_user}","gists_url":"https://api.github.com/users/mhuxtable/gists{/gist_id}","starred_url":"https://api.github.com/users/mhuxtable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhuxtable/subscriptions","organizations_url":"https://api.github.com/users/mhuxtable/orgs","repos_url":"https://api.github.com/users/mhuxtable/repos","events_url":"https://api.github.com/users/mhuxtable/events{/privacy}","received_events_url":"https://api.github.com/users/mhuxtable/received_events","type":"User","site_admin":false},"repo":{"id":44533402,"name":"ansible","full_name":"mhuxtable/ansible","owner":{"login":"mhuxtable","id":5958122,"avatar_url":"https://avatars.githubusercontent.com/u/5958122?v=3","gravatar_id":"","url":"https://api.github.com/users/mhuxtable","html_url":"https://github.com/mhuxtable","followers_url":"https://api.github.com/users/mhuxtable/followers","following_url":"https://api.github.com/users/mhuxtable/following{/other_user}","gists_url":"https://api.github.com/users/mhuxtable/gists{/gist_id}","starred_url":"https://api.github.com/users/mhuxtable/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhuxtable/subscriptions","organizations_url":"https://api.github.com/users/mhuxtable/orgs","repos_url":"https://api.github.com/users/mhuxtable/repos","events_url":"https://api.github.com/users/mhuxtable/events{/privacy}","received_events_url":"https://api.github.com/users/mhuxtable/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mhuxtable/ansible","description":"Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.","fork":true,"url":"https://api.github.com/repos/mhuxtable/ansible","forks_url":"https://api.github.com/repos/mhuxtable/ansible/forks","keys_url":"https://api.github.com/repos/mhuxtable/ansible/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mhuxtable/ansible/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mhuxtable/ansible/teams","hooks_url":"https://api.github.com/repos/mhuxtable/ansible/hooks","issue_events_url":"https://api.github.com/repos/mhuxtable/ansible/issues/events{/number}","events_url":"https://api.github.com/repos/mhuxtable/ansible/events","assignees_url":"https://api.github.com/repos/mhuxtable/ansible/assignees{/user}","branches_url":"https://api.github.com/repos/mhuxtable/ansible/branches{/branch}","tags_url":"https://api.github.com/repos/mhuxtable/ansible/tags","blobs_url":"https://api.github.com/repos/mhuxtable/ansible/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mhuxtable/ansible/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mhuxtable/ansible/git/refs{/sha}","trees_url":"https://api.github.com/repos/mhuxtable/ansible/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mhuxtable/ansible/statuses/{sha}","languages_url":"https://api.github.com/repos/mhuxtable/ansible/languages","stargazers_url":"https://api.github.com/repos/mhuxtable/ansible/stargazers","contributors_url":"https://api.github.com/repos/mhuxtable/ansible/contributors","subscribers_url":"https://api.github.com/repos/mhuxtable/ansible/subscribers","subscription_url":"https://api.github.com/repos/mhuxtable/ansible/subscription","commits_url":"https://api.github.com/repos/mhuxtable/ansible/commits{/sha}","git_commits_url":"https://api.github.com/repos/mhuxtable/ansible/git/commits{/sha}","comments_url":"https://api.github.com/repos/mhuxtable/ansible/comments{/number}","issue_comment_url":"https://api.github.com/repos/mhuxtable/ansible/issues/comments{/number}","contents_url":"https://api.github.com/repos/mhuxtable/ansible/contents/{+path}","compare_url":"https://api.github.com/repos/mhuxtable/ansible/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mhuxtable/ansible/merges","archive_url":"https://api.github.com/repos/mhuxtable/ansible/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mhuxtable/ansible/downloads","issues_url":"https://api.github.com/repos/mhuxtable/ansible/issues{/number}","pulls_url":"https://api.github.com/repos/mhuxtable/ansible/pulls{/number}","milestones_url":"https://api.github.com/repos/mhuxtable/ansible/milestones{/number}","notifications_url":"https://api.github.com/repos/mhuxtable/ansible/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mhuxtable/ansible/labels{/name}","releases_url":"https://api.github.com/repos/mhuxtable/ansible/releases{/id}","created_at":"2015-10-19T12:36:01Z","updated_at":"2015-10-19T12:36:09Z","pushed_at":"2015-10-19T12:36:39Z","git_url":"git://github.com/mhuxtable/ansible.git","ssh_url":"git@github.com:mhuxtable/ansible.git","clone_url":"https://github.com/mhuxtable/ansible.git","svn_url":"https://github.com/mhuxtable/ansible","homepage":"http://ansible.com/","size":257271,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"devel"}},"base":{"label":"ansible:devel","ref":"devel","sha":"1280e2296c35a7752d7048e6424b600c94ec29de","user":{"login":"ansible","id":1507452,"avatar_url":"https://avatars.githubusercontent.com/u/1507452?v=3","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"repo":{"id":3638964,"name":"ansible","full_name":"ansible/ansible","owner":{"login":"ansible","id":1507452,"avatar_url":"https://avatars.githubusercontent.com/u/1507452?v=3","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ansible/ansible","description":"Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy. Avoid writing scripts or custom code to deploy and update your applications— automate in a language that approaches plain English, using SSH, with no agents to install on remote systems.","fork":false,"url":"https://api.github.com/repos/ansible/ansible","forks_url":"https://api.github.com/repos/ansible/ansible/forks","keys_url":"https://api.github.com/repos/ansible/ansible/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ansible/ansible/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ansible/ansible/teams","hooks_url":"https://api.github.com/repos/ansible/ansible/hooks","issue_events_url":"https://api.github.com/repos/ansible/ansible/issues/events{/number}","events_url":"https://api.github.com/repos/ansible/ansible/events","assignees_url":"https://api.github.com/repos/ansible/ansible/assignees{/user}","branches_url":"https://api.github.com/repos/ansible/ansible/branches{/branch}","tags_url":"https://api.github.com/repos/ansible/ansible/tags","blobs_url":"https://api.github.com/repos/ansible/ansible/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ansible/ansible/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ansible/ansible/git/refs{/sha}","trees_url":"https://api.github.com/repos/ansible/ansible/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ansible/ansible/statuses/{sha}","languages_url":"https://api.github.com/repos/ansible/ansible/languages","stargazers_url":"https://api.github.com/repos/ansible/ansible/stargazers","contributors_url":"https://api.github.com/repos/ansible/ansible/contributors","subscribers_url":"https://api.github.com/repos/ansible/ansible/subscribers","subscription_url":"https://api.github.com/repos/ansible/ansible/subscription","commits_url":"https://api.github.com/repos/ansible/ansible/commits{/sha}","git_commits_url":"https://api.github.com/repos/ansible/ansible/git/commits{/sha}","comments_url":"https://api.github.com/repos/ansible/ansible/comments{/number}","issue_comment_url":"https://api.github.com/repos/ansible/ansible/issues/comments{/number}","contents_url":"https://api.github.com/repos/ansible/ansible/contents/{+path}","compare_url":"https://api.github.com/repos/ansible/ansible/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ansible/ansible/merges","archive_url":"https://api.github.com/repos/ansible/ansible/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ansible/ansible/downloads","issues_url":"https://api.github.com/repos/ansible/ansible/issues{/number}","pulls_url":"https://api.github.com/repos/ansible/ansible/pulls{/number}","milestones_url":"https://api.github.com/repos/ansible/ansible/milestones{/number}","notifications_url":"https://api.github.com/repos/ansible/ansible/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ansible/ansible/labels{/name}","releases_url":"https://api.github.com/repos/ansible/ansible/releases{/id}","created_at":"2012-03-06T14:58:02Z","updated_at":"2015-10-19T11:43:37Z","pushed_at":"2015-10-19T12:22:32Z","git_url":"git://github.com/ansible/ansible.git","ssh_url":"git@github.com:ansible/ansible.git","clone_url":"https://github.com/ansible/ansible.git","svn_url":"https://github.com/ansible/ansible","homepage":"http://ansible.com/","size":257271,"stargazers_count":13253,"watchers_count":13253,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3951,"mirror_url":null,"open_issues_count":802,"forks":3951,"open_issues":802,"watchers":13253,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible/pulls/12826"},"html":{"href":"https://github.com/ansible/ansible/pull/12826"},"issue":{"href":"https://api.github.com/repos/ansible/ansible/issues/12826"},"comments":{"href":"https://api.github.com/repos/ansible/ansible/issues/12826/comments"},"review_comments":{"href":"https://api.github.com/repos/ansible/ansible/pulls/12826/comments"},"review_comment":{"href":"https://api.github.com/repos/ansible/ansible/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ansible/ansible/pulls/12826/commits"},"statuses":{"href":"https://api.github.com/repos/ansible/ansible/statuses/d7bbb4e43095db25b32860e2e9d8df334d2a89d5"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":7,"deletions":0,"changed_files":1}}