{"action":"created","comment":{"url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/pulls/comments/121956770","pull_request_review_id":44024898,"id":121956770,"diff_hunk":"@@ -0,0 +1,188 @@\n+# Ansible via Python ![alt text](https://cub.nobleprog.com/sites/hitramx/files/styles/height50_scale/public/category_image/cursos-de-ansible-en-mexico.png?itok=xPUrGNrA)\n+\n+**_Ansible is designed around the way people work and the way people work together_**\n+\n+## What is Ansible\n+\n+Ansible is simple IT engine for automation, it is designed for manage many\n+systems, rather than just one at a time. Ansible automates cloud provisioning,\n+configuration management, application deployment, intra-service\n+orchestration, and many other IT operations. It is easy to deploy due to using\n+no agents and no additional custom security infrastructure. We can define own\n+configuration management in simple YAML language, which is named\n+ansible-playbook. YAML is easier to read and write by humans than other common\n+data formats line XML or JSON. Futhermore, most programming languages contain\n+libraries which operate and work YAML.\n+\n+## Inventory\n+\n+Ansible works collaterally on many systems in your infrastructure, so it is\n+important to specify a roster to keep `hosts`. This list is named `inventory`,\n+which can be in one of many formats. For this example, the format is an\n+`INI-like` and is saved in `/etc/ansible/hosts`.\n+\n+```INI\n+mail.example.com\n+\n+[webservers]\n+foo.example.com\n+bar.example.com\n+\n+[dbservers]\n+one.example.com\n+two.example.com\n+three.example.com\n+```\n+\n+## Ansible Playbook\n+\n+Playbook is the way to direct systems, which is particularly powerful, compact\n+and easy to read and write. As we said configuration multi-system management is\n+formatted in YAML language. Ansible playbook consists of `plays`, which\n+contain `hosts` we would like to manage, and `tasks` we want to perform.\n+\n+```yaml\n+---\n+- hosts: webservers\n+  vars:\n+    http_port: 80\n+    max_clients: 200\n+  remote_user: root\n+  tasks:\n+  - name: ensure apache is at the latest version\n+    yum: name=httpd state=latest\n+  - name: write the apache config file\n+    template: src=/srv/httpd.j2 dest=/etc/httpd.conf\n+    notify:\n+    - restart apache\n+  - name: ensure apache is running (and enable it at boot)\n+    service: name=httpd state=started enabled=yes\n+  handlers:\n+    - name: restart apache\n+      service: name=httpd state=restarted\n+```\n+\n+### Ansible for Embedded Linux\n+\n+There is possibility to need build image with custom Linux-based system for\n+embedded with Ansible. In addition, we would like to run ansible-playbook via\n+python. It seems to be hard to implement. Nothing more simple! It is needed to\n+add recipe to image with ansible from\n+[Python Ansible package](https://github.com/OverC/meta-overc/blob/master/meta-cube/recipes-devtools/python/python-ansible_2.1.1.0.bb)\n+\n+You also need to have installed python, of course.\n+\n+#### Additional information\n+\n+For more information go to [Ansible Documentation](http://docs.ansible.com/ansible/)\n+\n+## Python API\n+\n+Python API is very powerful, so we can manage and run ansible-playbook drom\n+python level, there is possibility to controll nodes, write various plugins,\n+extend Ansible to respond to various python events and plug in inventory data\n+from external data sources.\n+\n+> Note: There is a permament structure to build python program which operates ansible\n+commands:\n+\n+First of all we have to import some modules needed to run ansible in python.\n+\n+- Let's describe some of them:\n+\n+\t- `json` module to convert output to json format\n+\t- `ansible` modules to manage e.g. inventory or plays","path":"source/_posts/2017-06-14-Ansible-via-python.markdown","position":94,"original_position":94,"commit_id":"09a9aee32177becafcd86d5e2e82b7b5581cf567","original_commit_id":"09a9aee32177becafcd86d5e2e82b7b5581cf567","user":{"login":"macpijan","id":19353650,"avatar_url":"https://avatars3.githubusercontent.com/u/19353650?v=3","gravatar_id":"","url":"https://api.github.com/users/macpijan","html_url":"https://github.com/macpijan","followers_url":"https://api.github.com/users/macpijan/followers","following_url":"https://api.github.com/users/macpijan/following{/other_user}","gists_url":"https://api.github.com/users/macpijan/gists{/gist_id}","starred_url":"https://api.github.com/users/macpijan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/macpijan/subscriptions","organizations_url":"https://api.github.com/users/macpijan/orgs","repos_url":"https://api.github.com/users/macpijan/repos","events_url":"https://api.github.com/users/macpijan/events{/privacy}","received_events_url":"https://api.github.com/users/macpijan/received_events","type":"User","site_admin":false},"body":"@Macias118 module","created_at":"2017-06-14T14:08:26Z","updated_at":"2017-06-14T14:21:49Z","html_url":"https://github.com/3mdeb/blog.3mdeb.com/pull/8#discussion_r121956770","pull_request_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/pulls/comments/121956770"},"html":{"href":"https://github.com/3mdeb/blog.3mdeb.com/pull/8#discussion_r121956770"},"pull_request":{"href":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/pulls/8","id":125585644,"html_url":"https://github.com/3mdeb/blog.3mdeb.com/pull/8","diff_url":"https://github.com/3mdeb/blog.3mdeb.com/pull/8.diff","patch_url":"https://github.com/3mdeb/blog.3mdeb.com/pull/8.patch","issue_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/issues/8","number":8,"state":"open","locked":false,"title":"2017-06-14-Ansible-via-python.markdown","user":{"login":"Macias118","id":23313498,"avatar_url":"https://avatars0.githubusercontent.com/u/23313498?v=3","gravatar_id":"","url":"https://api.github.com/users/Macias118","html_url":"https://github.com/Macias118","followers_url":"https://api.github.com/users/Macias118/followers","following_url":"https://api.github.com/users/Macias118/following{/other_user}","gists_url":"https://api.github.com/users/Macias118/gists{/gist_id}","starred_url":"https://api.github.com/users/Macias118/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Macias118/subscriptions","organizations_url":"https://api.github.com/users/Macias118/orgs","repos_url":"https://api.github.com/users/Macias118/repos","events_url":"https://api.github.com/users/Macias118/events{/privacy}","received_events_url":"https://api.github.com/users/Macias118/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-06-14T12:42:09Z","updated_at":"2017-06-14T14:21:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b8b38ffffa5704199149975c9d8412e8b839e2c8","assignee":{"login":"Macias118","id":23313498,"avatar_url":"https://avatars0.githubusercontent.com/u/23313498?v=3","gravatar_id":"","url":"https://api.github.com/users/Macias118","html_url":"https://github.com/Macias118","followers_url":"https://api.github.com/users/Macias118/followers","following_url":"https://api.github.com/users/Macias118/following{/other_user}","gists_url":"https://api.github.com/users/Macias118/gists{/gist_id}","starred_url":"https://api.github.com/users/Macias118/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Macias118/subscriptions","organizations_url":"https://api.github.com/users/Macias118/orgs","repos_url":"https://api.github.com/users/Macias118/repos","events_url":"https://api.github.com/users/Macias118/events{/privacy}","received_events_url":"https://api.github.com/users/Macias118/received_events","type":"User","site_admin":false},"assignees":[{"login":"Macias118","id":23313498,"avatar_url":"https://avatars0.githubusercontent.com/u/23313498?v=3","gravatar_id":"","url":"https://api.github.com/users/Macias118","html_url":"https://github.com/Macias118","followers_url":"https://api.github.com/users/Macias118/followers","following_url":"https://api.github.com/users/Macias118/following{/other_user}","gists_url":"https://api.github.com/users/Macias118/gists{/gist_id}","starred_url":"https://api.github.com/users/Macias118/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Macias118/subscriptions","organizations_url":"https://api.github.com/users/Macias118/orgs","repos_url":"https://api.github.com/users/Macias118/repos","events_url":"https://api.github.com/users/Macias118/events{/privacy}","received_events_url":"https://api.github.com/users/Macias118/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"mek-x","id":7389274,"avatar_url":"https://avatars2.githubusercontent.com/u/7389274?v=3","gravatar_id":"","url":"https://api.github.com/users/mek-x","html_url":"https://github.com/mek-x","followers_url":"https://api.github.com/users/mek-x/followers","following_url":"https://api.github.com/users/mek-x/following{/other_user}","gists_url":"https://api.github.com/users/mek-x/gists{/gist_id}","starred_url":"https://api.github.com/users/mek-x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mek-x/subscriptions","organizations_url":"https://api.github.com/users/mek-x/orgs","repos_url":"https://api.github.com/users/mek-x/repos","events_url":"https://api.github.com/users/mek-x/events{/privacy}","received_events_url":"https://api.github.com/users/mek-x/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/pulls/8/commits","review_comments_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/pulls/8/comments","review_comment_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/pulls/comments{/number}","comments_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/issues/8/comments","statuses_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/statuses/09a9aee32177becafcd86d5e2e82b7b5581cf567","head":{"label":"Macias118:ansible_python","ref":"ansible_python","sha":"09a9aee32177becafcd86d5e2e82b7b5581cf567","user":{"login":"Macias118","id":23313498,"avatar_url":"https://avatars0.githubusercontent.com/u/23313498?v=3","gravatar_id":"","url":"https://api.github.com/users/Macias118","html_url":"https://github.com/Macias118","followers_url":"https://api.github.com/users/Macias118/followers","following_url":"https://api.github.com/users/Macias118/following{/other_user}","gists_url":"https://api.github.com/users/Macias118/gists{/gist_id}","starred_url":"https://api.github.com/users/Macias118/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Macias118/subscriptions","organizations_url":"https://api.github.com/users/Macias118/orgs","repos_url":"https://api.github.com/users/Macias118/repos","events_url":"https://api.github.com/users/Macias118/events{/privacy}","received_events_url":"https://api.github.com/users/Macias118/received_events","type":"User","site_admin":false},"repo":{"id":94329001,"name":"blog.3mdeb.com","full_name":"Macias118/blog.3mdeb.com","owner":{"login":"Macias118","id":23313498,"avatar_url":"https://avatars0.githubusercontent.com/u/23313498?v=3","gravatar_id":"","url":"https://api.github.com/users/Macias118","html_url":"https://github.com/Macias118","followers_url":"https://api.github.com/users/Macias118/followers","following_url":"https://api.github.com/users/Macias118/following{/other_user}","gists_url":"https://api.github.com/users/Macias118/gists{/gist_id}","starred_url":"https://api.github.com/users/Macias118/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Macias118/subscriptions","organizations_url":"https://api.github.com/users/Macias118/orgs","repos_url":"https://api.github.com/users/Macias118/repos","events_url":"https://api.github.com/users/Macias118/events{/privacy}","received_events_url":"https://api.github.com/users/Macias118/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Macias118/blog.3mdeb.com","description":null,"fork":true,"url":"https://api.github.com/repos/Macias118/blog.3mdeb.com","forks_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/forks","keys_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/teams","hooks_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/hooks","issue_events_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/issues/events{/number}","events_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/events","assignees_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/assignees{/user}","branches_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/branches{/branch}","tags_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/tags","blobs_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/git/refs{/sha}","trees_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/statuses/{sha}","languages_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/languages","stargazers_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/stargazers","contributors_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/contributors","subscribers_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/subscribers","subscription_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/subscription","commits_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/commits{/sha}","git_commits_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/git/commits{/sha}","comments_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/comments{/number}","issue_comment_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/issues/comments{/number}","contents_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/contents/{+path}","compare_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/merges","archive_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/downloads","issues_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/issues{/number}","pulls_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/pulls{/number}","milestones_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/milestones{/number}","notifications_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/labels{/name}","releases_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/releases{/id}","deployments_url":"https://api.github.com/repos/Macias118/blog.3mdeb.com/deployments","created_at":"2017-06-14T12:33:47Z","updated_at":"2017-06-14T12:33:49Z","pushed_at":"2017-06-14T12:37:44Z","git_url":"git://github.com/Macias118/blog.3mdeb.com.git","ssh_url":"git@github.com:Macias118/blog.3mdeb.com.git","clone_url":"https://github.com/Macias118/blog.3mdeb.com.git","svn_url":"https://github.com/Macias118/blog.3mdeb.com","homepage":null,"size":59743,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"3mdeb:source","ref":"source","sha":"dd640757ad6462660e5cd05d2f02af857801048b","user":{"login":"3mdeb","id":17986768,"avatar_url":"https://avatars0.githubusercontent.com/u/17986768?v=3","gravatar_id":"","url":"https://api.github.com/users/3mdeb","html_url":"https://github.com/3mdeb","followers_url":"https://api.github.com/users/3mdeb/followers","following_url":"https://api.github.com/users/3mdeb/following{/other_user}","gists_url":"https://api.github.com/users/3mdeb/gists{/gist_id}","starred_url":"https://api.github.com/users/3mdeb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3mdeb/subscriptions","organizations_url":"https://api.github.com/users/3mdeb/orgs","repos_url":"https://api.github.com/users/3mdeb/repos","events_url":"https://api.github.com/users/3mdeb/events{/privacy}","received_events_url":"https://api.github.com/users/3mdeb/received_events","type":"Organization","site_admin":false},"repo":{"id":16118521,"name":"blog.3mdeb.com","full_name":"3mdeb/blog.3mdeb.com","owner":{"login":"3mdeb","id":17986768,"avatar_url":"https://avatars0.githubusercontent.com/u/17986768?v=3","gravatar_id":"","url":"https://api.github.com/users/3mdeb","html_url":"https://github.com/3mdeb","followers_url":"https://api.github.com/users/3mdeb/followers","following_url":"https://api.github.com/users/3mdeb/following{/other_user}","gists_url":"https://api.github.com/users/3mdeb/gists{/gist_id}","starred_url":"https://api.github.com/users/3mdeb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3mdeb/subscriptions","organizations_url":"https://api.github.com/users/3mdeb/orgs","repos_url":"https://api.github.com/users/3mdeb/repos","events_url":"https://api.github.com/users/3mdeb/events{/privacy}","received_events_url":"https://api.github.com/users/3mdeb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/3mdeb/blog.3mdeb.com","description":null,"fork":false,"url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com","forks_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/forks","keys_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/keys{/key_id}","collaborators_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/teams","hooks_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/hooks","issue_events_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/issues/events{/number}","events_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/events","assignees_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/assignees{/user}","branches_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/branches{/branch}","tags_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/tags","blobs_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/git/refs{/sha}","trees_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/git/trees{/sha}","statuses_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/statuses/{sha}","languages_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/languages","stargazers_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/stargazers","contributors_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/contributors","subscribers_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/subscribers","subscription_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/subscription","commits_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/commits{/sha}","git_commits_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/git/commits{/sha}","comments_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/comments{/number}","issue_comment_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/issues/comments{/number}","contents_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/contents/{+path}","compare_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/compare/{base}...{head}","merges_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/merges","archive_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/downloads","issues_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/issues{/number}","pulls_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/pulls{/number}","milestones_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/milestones{/number}","notifications_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/labels{/name}","releases_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/releases{/id}","deployments_url":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/deployments","created_at":"2014-01-21T20:49:56Z","updated_at":"2017-05-10T14:33:50Z","pushed_at":"2017-06-14T12:42:10Z","git_url":"git://github.com/3mdeb/blog.3mdeb.com.git","ssh_url":"git@github.com:3mdeb/blog.3mdeb.com.git","clone_url":"https://github.com/3mdeb/blog.3mdeb.com.git","svn_url":"https://github.com/3mdeb/blog.3mdeb.com","homepage":null,"size":59740,"stargazers_count":1,"watchers_count":1,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/pulls/8"},"html":{"href":"https://github.com/3mdeb/blog.3mdeb.com/pull/8"},"issue":{"href":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/issues/8"},"comments":{"href":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/3mdeb/blog.3mdeb.com/statuses/09a9aee32177becafcd86d5e2e82b7b5581cf567"}}}}
{"actor":{"display_login":"macpijan"}}