{"action":"opened","number":27961,"pull_request":{"url":"https://api.github.com/repos/ansible/ansible/pulls/27961","id":134906126,"html_url":"https://github.com/ansible/ansible/pull/27961","diff_url":"https://github.com/ansible/ansible/pull/27961.diff","patch_url":"https://github.com/ansible/ansible/pull/27961.patch","issue_url":"https://api.github.com/repos/ansible/ansible/issues/27961","number":27961,"state":"open","locked":false,"title":"Fixes: #20986 blockinfile create undelying directory when create=true","user":{"login":"giovannisciortino","id":30353557,"avatar_url":"https://avatars3.githubusercontent.com/u/30353557?v=4","gravatar_id":"","url":"https://api.github.com/users/giovannisciortino","html_url":"https://github.com/giovannisciortino","followers_url":"https://api.github.com/users/giovannisciortino/followers","following_url":"https://api.github.com/users/giovannisciortino/following{/other_user}","gists_url":"https://api.github.com/users/giovannisciortino/gists{/gist_id}","starred_url":"https://api.github.com/users/giovannisciortino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giovannisciortino/subscriptions","organizations_url":"https://api.github.com/users/giovannisciortino/orgs","repos_url":"https://api.github.com/users/giovannisciortino/repos","events_url":"https://api.github.com/users/giovannisciortino/events{/privacy}","received_events_url":"https://api.github.com/users/giovannisciortino/received_events","type":"User","site_admin":false},"body":"##### SUMMARY\r\nWith this change the module blockinfile executed (with create=true) on a file with not existent undelying directory create the directory before creating the file. Now it has the same behavior of the module lineinfile.\r\n\r\n##### ISSUE TYPE\r\n - Bugfix Pull Request\r\n\r\n##### COMPONENT NAME\r\nblockinfile\r\n\r\n##### ANSIBLE VERSION\r\n$  ./build/scripts-2.7/ansible --version\r\nansible 2.4.0\r\n  config file = /etc/ansible/ansible.cfg\r\n  configured module search path = [u'/home/g/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']\r\n  ansible python module location = /home/g/PycharmProjects/ansible/build/lib/ansible\r\n  executable location = ./build/scripts-2.7/ansible\r\n  python version = 2.7.13 (default, May 10 2017, 20:04:28) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]\r\n\r\n\r\n##### ADDITIONAL INFORMATION\r\nThe line added in blockinfile have the same style/position/structure of the similar [code](https://github.com/ansible/ansible/blob/bf54a0c3e54ab2c2ed4e50c7b2c0ef5837fd69fc/lib/ansible/modules/files/lineinfile.py#L238) of lineinfile module \r\n\r\nBEFORE\r\n```\r\n$  ./build/scripts-2.7/ansible localhost -m blockinfile -a 'dest=/tmp/ansible/.blockinfile/test state=present create=yes block=blah'An exception occurred during task execution. To see the full traceback, use -vvv. The error was: OSError: [Errno 2] No such file or directory\r\nlocalhost | FAILED! => {\r\n    \"changed\": false, \r\n    \"failed\": true, \r\n    \"msg\": \"Could not replace file: /tmp/tmpB3oG0Y to /tmp/ansible/.blockinfile/test: [Errno 2] No such file or directory\"\r\n}\r\n```\r\n\r\nAFTER\r\n```\r\n$  ./build/scripts-2.7/ansible localhost -m blockinfile -a 'dest=/tmp/ansible/.blockinfile/test state=present create=yes block=blah'\r\nlocalhost | SUCCESS => {\r\n    \"changed\": true, \r\n    \"failed\": false, \r\n    \"msg\": \"File created\"\r\n}\r\n```\r\n","created_at":"2017-08-09T14:24:40Z","updated_at":"2017-08-09T14:24:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/ansible/ansible/pulls/27961/commits","review_comments_url":"https://api.github.com/repos/ansible/ansible/pulls/27961/comments","review_comment_url":"https://api.github.com/repos/ansible/ansible/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ansible/ansible/issues/27961/comments","statuses_url":"https://api.github.com/repos/ansible/ansible/statuses/fabb713fd2dbd0a72c27639bfe53d1c374b174b9","head":{"label":"giovannisciortino:pull-issue-20986","ref":"pull-issue-20986","sha":"fabb713fd2dbd0a72c27639bfe53d1c374b174b9","user":{"login":"giovannisciortino","id":30353557,"avatar_url":"https://avatars3.githubusercontent.com/u/30353557?v=4","gravatar_id":"","url":"https://api.github.com/users/giovannisciortino","html_url":"https://github.com/giovannisciortino","followers_url":"https://api.github.com/users/giovannisciortino/followers","following_url":"https://api.github.com/users/giovannisciortino/following{/other_user}","gists_url":"https://api.github.com/users/giovannisciortino/gists{/gist_id}","starred_url":"https://api.github.com/users/giovannisciortino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giovannisciortino/subscriptions","organizations_url":"https://api.github.com/users/giovannisciortino/orgs","repos_url":"https://api.github.com/users/giovannisciortino/repos","events_url":"https://api.github.com/users/giovannisciortino/events{/privacy}","received_events_url":"https://api.github.com/users/giovannisciortino/received_events","type":"User","site_admin":false},"repo":{"id":98640643,"name":"ansible","full_name":"giovannisciortino/ansible","owner":{"login":"giovannisciortino","id":30353557,"avatar_url":"https://avatars3.githubusercontent.com/u/30353557?v=4","gravatar_id":"","url":"https://api.github.com/users/giovannisciortino","html_url":"https://github.com/giovannisciortino","followers_url":"https://api.github.com/users/giovannisciortino/followers","following_url":"https://api.github.com/users/giovannisciortino/following{/other_user}","gists_url":"https://api.github.com/users/giovannisciortino/gists{/gist_id}","starred_url":"https://api.github.com/users/giovannisciortino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/giovannisciortino/subscriptions","organizations_url":"https://api.github.com/users/giovannisciortino/orgs","repos_url":"https://api.github.com/users/giovannisciortino/repos","events_url":"https://api.github.com/users/giovannisciortino/events{/privacy}","received_events_url":"https://api.github.com/users/giovannisciortino/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/giovannisciortino/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/giovannisciortino/ansible","forks_url":"https://api.github.com/repos/giovannisciortino/ansible/forks","keys_url":"https://api.github.com/repos/giovannisciortino/ansible/keys{/key_id}","collaborators_url":"https://api.github.com/repos/giovannisciortino/ansible/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/giovannisciortino/ansible/teams","hooks_url":"https://api.github.com/repos/giovannisciortino/ansible/hooks","issue_events_url":"https://api.github.com/repos/giovannisciortino/ansible/issues/events{/number}","events_url":"https://api.github.com/repos/giovannisciortino/ansible/events","assignees_url":"https://api.github.com/repos/giovannisciortino/ansible/assignees{/user}","branches_url":"https://api.github.com/repos/giovannisciortino/ansible/branches{/branch}","tags_url":"https://api.github.com/repos/giovannisciortino/ansible/tags","blobs_url":"https://api.github.com/repos/giovannisciortino/ansible/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/giovannisciortino/ansible/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/giovannisciortino/ansible/git/refs{/sha}","trees_url":"https://api.github.com/repos/giovannisciortino/ansible/git/trees{/sha}","statuses_url":"https://api.github.com/repos/giovannisciortino/ansible/statuses/{sha}","languages_url":"https://api.github.com/repos/giovannisciortino/ansible/languages","stargazers_url":"https://api.github.com/repos/giovannisciortino/ansible/stargazers","contributors_url":"https://api.github.com/repos/giovannisciortino/ansible/contributors","subscribers_url":"https://api.github.com/repos/giovannisciortino/ansible/subscribers","subscription_url":"https://api.github.com/repos/giovannisciortino/ansible/subscription","commits_url":"https://api.github.com/repos/giovannisciortino/ansible/commits{/sha}","git_commits_url":"https://api.github.com/repos/giovannisciortino/ansible/git/commits{/sha}","comments_url":"https://api.github.com/repos/giovannisciortino/ansible/comments{/number}","issue_comment_url":"https://api.github.com/repos/giovannisciortino/ansible/issues/comments{/number}","contents_url":"https://api.github.com/repos/giovannisciortino/ansible/contents/{+path}","compare_url":"https://api.github.com/repos/giovannisciortino/ansible/compare/{base}...{head}","merges_url":"https://api.github.com/repos/giovannisciortino/ansible/merges","archive_url":"https://api.github.com/repos/giovannisciortino/ansible/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/giovannisciortino/ansible/downloads","issues_url":"https://api.github.com/repos/giovannisciortino/ansible/issues{/number}","pulls_url":"https://api.github.com/repos/giovannisciortino/ansible/pulls{/number}","milestones_url":"https://api.github.com/repos/giovannisciortino/ansible/milestones{/number}","notifications_url":"https://api.github.com/repos/giovannisciortino/ansible/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/giovannisciortino/ansible/labels{/name}","releases_url":"https://api.github.com/repos/giovannisciortino/ansible/releases{/id}","deployments_url":"https://api.github.com/repos/giovannisciortino/ansible/deployments","created_at":"2017-07-28T10:51:42Z","updated_at":"2017-07-28T10:52:05Z","pushed_at":"2017-08-09T14:04:06Z","git_url":"git://github.com/giovannisciortino/ansible.git","ssh_url":"git@github.com:giovannisciortino/ansible.git","clone_url":"https://github.com/giovannisciortino/ansible.git","svn_url":"https://github.com/giovannisciortino/ansible","homepage":"http://ansible.com/","size":77338,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"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":"52a8ed55eea54a5077de962ae57d2253e1bb847e","user":{"login":"ansible","id":1507452,"avatar_url":"https://avatars2.githubusercontent.com/u/1507452?v=4","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://avatars2.githubusercontent.com/u/1507452?v=4","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}","deployments_url":"https://api.github.com/repos/ansible/ansible/deployments","created_at":"2012-03-06T14:58:02Z","updated_at":"2017-08-09T13:32:01Z","pushed_at":"2017-08-09T14:16:14Z","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":85760,"stargazers_count":24677,"watchers_count":24677,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8544,"mirror_url":null,"open_issues_count":3537,"forks":8544,"open_issues":3537,"watchers":24677,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible/pulls/27961"},"html":{"href":"https://github.com/ansible/ansible/pull/27961"},"issue":{"href":"https://api.github.com/repos/ansible/ansible/issues/27961"},"comments":{"href":"https://api.github.com/repos/ansible/ansible/issues/27961/comments"},"review_comments":{"href":"https://api.github.com/repos/ansible/ansible/pulls/27961/comments"},"review_comment":{"href":"https://api.github.com/repos/ansible/ansible/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ansible/ansible/pulls/27961/commits"},"statuses":{"href":"https://api.github.com/repos/ansible/ansible/statuses/fabb713fd2dbd0a72c27639bfe53d1c374b174b9"}},"merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":3,"deletions":0,"changed_files":1}}
{"actor":{"display_login":"giovannisciortino"}}