{"id":1120,"date":"2015-01-11T07:47:08","date_gmt":"2015-01-11T07:47:08","guid":{"rendered":"http:\/\/kraftek.com\/blog\/?p=1120"},"modified":"2015-01-11T19:17:51","modified_gmt":"2015-01-11T19:17:51","slug":"ansible","status":"publish","type":"post","link":"\/blog\/index.php\/ansible\/","title":{"rendered":"Ansible"},"content":{"rendered":"<p>Install it in the master node<\/p>\n<pre>\r\n# apt-get install ansible\r\n<\/pre>\n<p>add a section to \/etc\/ansible\/hosts<\/p>\n<pre>\r\n[slaves]\r\nd510\r\nd610\r\n<\/pre>\n<p>Ping them (make sure you have ssh keys setup in authorized_keys)<\/p>\n<pre>\r\n# ansible -m ping -u root all\r\nd510 | success >> {\r\n    \"changed\": false,\r\n    \"ping\": \"pong\"\r\n}\r\n\r\nd610 | success >> {\r\n    \"changed\": false,\r\n    \"ping\": \"pong\"\r\n}\r\n<\/pre>\n<p>A first play file using apt to install some packages in the &#8220;slaves&#8221;<\/p>\n<pre>\r\n---\r\n- name : first play\r\n  hosts: slaves\r\n  user: root\r\n\r\n  tasks:\r\n\r\n#  - name: install gcc\r\n#    apt: pkg=gcc state=present\r\n#  - name: install nginx\r\n#    apt: pkg=nginx state=present\r\n\r\n  - name: install findx\r\n    copy: src=\/usr\/bin\/findx dest=\/usr\/bin\/findx owner=root group=root mode=755\r\n\r\n  - name: install common packages\r\n    action: apt pkg={{item}} state=installed\r\n    with_items:\r\n      - motion\r\n      - nginx\r\n<\/pre>\n<p>Running it&#8230;<\/p>\n<pre>\r\n# ansible-playbook play.yml\r\n\r\nPLAY [first play] *************************************************************\r\n\r\nGATHERING FACTS ***************************************************************\r\nok: [d510]\r\nok: [d610]\r\n\r\nTASK: [install findx] *********************************************************\r\nok: [d610]\r\nok: [d510]\r\n\r\nTASK: [install common packages] ***********************************************\r\nok: [d610] => (item=motion,nginx)\r\nok: [d510] => (item=motion,nginx)\r\n\r\nPLAY RECAP ********************************************************************\r\nd510                       : ok=3    changed=0    unreachable=0    failed=0\r\nd610                       : ok=3    changed=0    unreachable=0    failed=0\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Install it in the master node # apt-get install ansible add a section to \/etc\/ansible\/hosts [slaves] d510 d610 Ping them (make sure you have ssh keys setup in authorized_keys) # ansible -m ping -u root all d510 | success >> { &#8220;changed&#8221;: false, &#8220;ping&#8221;: &#8220;pong&#8221; } d610 | success >> { &#8220;changed&#8221;: false, &#8220;ping&#8221;: &#8220;pong&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1120","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1120"}],"version-history":[{"count":6,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1120\/revisions"}],"predecessor-version":[{"id":1126,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1120\/revisions\/1126"}],"wp:attachment":[{"href":"\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1120"},{"taxonomy":"post_tag","embeddable":true,"href":"\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}