{"id":6758,"date":"2022-12-14T08:14:26","date_gmt":"2022-12-13T23:14:26","guid":{"rendered":"https:\/\/lab4ict.com\/system\/?p=6758"},"modified":"2022-12-17T11:37:55","modified_gmt":"2022-12-17T02:37:55","slug":"ansible%e3%81%a7%e7%ae%a1%e7%90%86%e5%af%be%e8%b1%a1%e3%81%aelinux%e3%82%b5%e3%83%bc%e3%83%90%e3%81%ab%e5%85%b1%e9%80%9a%e3%81%99%e3%82%8b%e8%a8%ad%e5%ae%9a%e3%82%92%e8%a1%8c%e3%81%86%ef%bc%81","status":"publish","type":"post","link":"https:\/\/lab4ict.com\/system\/archives\/6758","title":{"rendered":"Ansible\u3067\u7ba1\u7406\u5bfe\u8c61\u306eLinux\u30b5\u30fc\u30d0\u306b\u5171\u901a\u3059\u308b\u8a2d\u5b9a\u3092\u884c\u3046\uff01"},"content":{"rendered":"<p>Ansible\u3067\u7ba1\u7406\u5bfe\u8c61\u306eLinux\u30b5\u30fc\u30d0\u306b\u5171\u901a\u3059\u308b\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<h2>\u4f5c\u696d\u3092\u884c\u3046\u524d\u63d0\u3092\u78ba\u8a8d\u3059\u308b\uff01<\/h2>\n<p>\u4f5c\u696d\u3092\u884c\u3046\u524d\u63d0\u3068\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u4f5c\u696d\u304c\u5b8c\u4e86\u3057\u3001Ansible\u3067\u30d1\u30b9\u30ef\u30fc\u30c9\u5165\u529b\u306a\u3057\u3067\u63a5\u7d9a\u3067\u304d\u308b\u74b0\u5883\u304c\u6574\u3063\u3066\u3044\u308b\u3053\u3068\u3092\u524d\u63d0\u3068\u3057\u307e\u3059\u3002<br \/>\n<div class=\"sc_getpost\"><a class=\"clearfix\" href=\"https:\/\/lab4ict.com\/system\/archives\/6726\" ><div class=\"sc_getpost_thumb post-box-thumbnail__wrap\"><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODdhAQABAPAAAN3d3QAAACwAAAAAAQABAAACAkQBADs=\" width=\"150\" height=\"150\" alt=\"Ansible\u3067\u7ba1\u7406\u5bfe\u8c61\u306eLinux\u30b5\u30fc\u30d0\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3057\u3067\u63a5\u7d9a\u53ef\u80fd\u306b\u3059\u308b\uff01\" loading=\"lazy\" data-src=\"https:\/\/lab4ict.com\/system\/wp-content\/uploads\/2022\/12\/eyecatch_ansible_01-150x150.png\" class=\"lazyload\"><\/div><div class=\"title\">Ansible\u3067\u7ba1\u7406\u5bfe\u8c61\u306eLinux\u30b5\u30fc\u30d0\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u306a\u3057\u3067\u63a5\u7d9a\u53ef\u80fd\u306b\u3059\u308b\uff01<\/div><div class=\"substr\">Ansible\u3067\u7ba1\u7406\u3059\u308bLinux\u30b5\u30fc\u30d0\u306b\u5bfe\u3057\u3066\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u5165\u529b\u306a\u3057\u3067\u63a5\u7d9a\u3067\u304d\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u672c\u7a3f\u3067\u306f\u3001SSH\u63a5\u7d9a\u306b\u5bfe\u3057\u3066\u306f\u9375\u8a8d\u8a3c\u3092\u4f7f\u7528\u3057\u3001\u7ba1\u7406\u8005\u6a29\u9650\u306e\u4f7f\u7528\u306b\u95a2\u3057\u3066\u306f\u3001sudo\u306e\u8a2d\u5b9a\u3092\u5909\u66f4\u3057\u3066\u5b9f\u73fe\u3057\u307e\u3059\u3002 Ansible\u3067\u521d\u56de\u63a5\u7d9a\u3059\u308b\u524d\u63d0\u3092\u78ba\u8a8d\u3059\u308b\uff01 Ansible\u3067\u521d\u56de\u63a5\u7d9a\u3059\u308b\u305f\u3081\u306e\u524d\u63d0\u3092\u6574\u7406...<\/div><\/a><\/div>\n<h2>Linux\u30b5\u30fc\u30d0\u306b\u5171\u901a\u3057\u3066\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u8a2d\u5b9a\u5185\u5bb9\u3092\u6574\u7406\u3059\u308b\uff01<\/h2>\n<p>Linux\u30b5\u30fc\u30d0\u306b\u5171\u901a\u3057\u3066\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u8a2d\u5b9a\u5185\u5bb9\u3092\u6574\u7406\u3057\u307e\u3059\u3002\u672c\u7a3f\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u8ffd\u52a0\u30e6\u30fc\u30b6\u3092\u4f5c\u6210\u3059\u308b\u3002<\/li>\n<li>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u8ffd\u52a0\u3059\u308b\u3002\uff08bin,log\uff09<\/li>\n<li>hosts\u30d5\u30a1\u30a4\u30eb\u3092\u914d\u5e03\u3059\u308b\u3002<\/li>\n<li>\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002\uff08sysstat\u30d1\u30c3\u30b1\u30fc\u30b8\uff09<\/li>\n<\/ul>\n<h2>Playbook\u3092\u7528\u610f\u3059\u308b\uff01<\/h2>\n<p>\u4ee5\u4e0b\u306ePlaybook\u3092\u7528\u610f\u3057\u307e\u3057\u305f\u3002\u30e6\u30fc\u30b6\u4f5c\u6210\u6642\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u300cXXXXXXXXXX\u300d\u304c\u6697\u53f7\u5316\u3055\u308c\u3066\u3044\u306a\u3044\u306e\u306f\u3001\u4eca\u5f8c\u306e\u8ab2\u984c\u3067\u3059\u30fb\u30fb\u30fb\u3002Debian\u7cfb\u3068RHEL\u7cfb\u306e\u533a\u5225\u306f\u3001\u81ea\u52d5\u3067\u3082\u884c\u3048\u307e\u3059\u304c\u3001Inventory\u3067\u5206\u3051\u308b\u4ed5\u69d8\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n---\r\n- hosts: servers_linux\r\n  become: true\r\n  tasks: \r\n  - name: create users\r\n    ansible.builtin.user:\r\n      name: &quot;{{ item.name }}&quot;\r\n      password: &quot;{{ 'XXXXXXXXXX' | ansible.builtin.password_hash('sha512') }}&quot;\r\n      uid: &quot;{{ item.uid }}&quot;\r\n      shell: \/bin\/bash\r\n    loop:\r\n      - { name: 'usradm01', uid: 1001 }\r\n      - { name: 'usradm02', uid: 1002 }\r\n  - name: create directories usradmin bin\r\n    ansible.builtin.file:\r\n      path: \/home\/usradmin\/bin\r\n      mode: &quot;0755&quot;\r\n      state: directory\r\n      owner: usradmin\r\n      group: usradmin\r\n  - name: create directories usradmin log\r\n    ansible.builtin.file:\r\n      path: \/home\/usradmin\/bin\r\n      mode: &quot;0755&quot;\r\n      state: directory\r\n      owner: usradmin\r\n      group: usradmin\r\n  - name: transfer file \/etc\/hosts\r\n    ansible.builtin.copy:\r\n      src: \/home\/usradmin\/doc\/hosts\/hosts\r\n      dest: \/etc\/hosts\r\n      owner: root\r\n      group: root\r\n      mode: &quot;0644&quot;\r\n\r\n- hosts: servers_debian\r\n  become: true\r\n  tasks:\r\n  - name: update packages debian servers\r\n    ansible.builtin.apt:\r\n      update_cache: true\r\n  - name: install sysstat package debian servers\r\n    ansible.builtin.apt:\r\n      name:\r\n        - sysstat\r\n      state: present\r\n\r\n- hosts: servers_rhel\r\n  become: true\r\n  tasks:\r\n  - name: update packages rhel servers\r\n    ansible.builtin.dnf:\r\n      update_cache: true\r\n  - name: install sysstat package rhel servers\r\n    ansible.builtin.dnf:\r\n      name:\r\n        - sysstat\r\n      state: present\r\n<\/pre>\n<h2>Playbook\u3092\u5b9f\u884c\u3059\u308b\uff01<\/h2>\n<p>Playbook\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002Playbook\u3092\u76f4\u3057\u306a\u304c\u3089\u7e70\u308a\u8fd4\u3057\u5b9f\u884c\u3059\u308b\u3053\u3068\u3092\u60f3\u5b9a\u3057\u3066\u3001\u30b7\u30a7\u30eb\u5316\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ cat .\/setup_s2_servers_linux.sh\r\n#!\/bin\/bash\r\n\r\nINI_FILE=inventory.ini\r\nPLB_FILE=~setup_s2_servers_linux.yml\r\n\r\nansible-playbook -i $INI_FILE $PLB_FILE\r\n<\/pre>\n<h2>\u304a\u308f\u308a\u306b<\/h2>\n<p>\u672c\u6765\u3001\u30b5\u30fc\u30d0\u5171\u901a\u306e\u8a2d\u5b9a\u306f\u3001common\u306e\u30ed\u30fc\u30eb\u306a\u3069\u3092\u4f5c\u6210\u3057\u3066\u3001Playbook\u3092\u6574\u7406\u3057\u3066\u3044\u304f\u5185\u5bb9\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\u3002\u3053\u306e\u5f8c\u306f\u3001\u500b\u5225\u306e\u30b5\u30fc\u30d0\u306e\u8a2d\u5b9a\u3092\u884c\u3063\u3066\u3044\u304fPlaybook\u3092\u4f5c\u6210\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2>\u53c2\u8003\u60c5\u5831<\/h2>\n<ul>\n<li><a href=\"https:\/\/docs.ansible.com\/ansible\/latest\/index.html\" target=\"_blank\" rel=\"noopener\">Ansible Documentation<\/a><\/li>\n<\/ul>\n<h2>\u95a2\u9023\u8a18\u4e8b<\/h2>\n<div class=\"sc_getpost\"><a class=\"clearfix\" href=\"https:\/\/lab4ict.com\/system\/archives\/6710\" ><div class=\"sc_getpost_thumb post-box-thumbnail__wrap\"><img decoding=\"async\" src=\"data:image\/gif;base64,R0lGODdhAQABAPAAAN3d3QAAACwAAAAAAQABAAACAkQBADs=\" width=\"150\" height=\"150\" alt=\"\u3010\u8a18\u4e8b\u4e00\u89a7\u3011Ansible\u3067\u69cb\u6210\u7ba1\u7406\u3092\u884c\u3046\uff01\" loading=\"lazy\" data-src=\"https:\/\/lab4ict.com\/system\/wp-content\/uploads\/2022\/12\/eyecatch_ansible_01-150x150.png\" class=\"lazyload\"><\/div><div class=\"title\">\u3010\u8a18\u4e8b\u4e00\u89a7\u3011Ansible\u3067\u69cb\u6210\u7ba1\u7406\u3092\u884c\u3046\uff01<\/div><div class=\"substr\">Ansible\u3067\u30b7\u30b9\u30c6\u30e0\u306e\u69cb\u6210\u7ba1\u7406\u3092\u884c\u3046\u305f\u3081\u306e\u8a18\u4e8b\u4e00\u89a7\u3092\u63b2\u8f09\u3057\u307e\u3059\u3002...<\/div><\/a><\/div>\n<h2>Ansible\u66f8\u7c4d\uff08Amazon\uff09<\/h2>\n<h3>Ansible\u5b9f\u8df5\u30ac\u30a4\u30c9 \u7b2c3\u7248 impress top gear\u30b7\u30ea\u30fc\u30ba<\/h3>\n<p><iframe style=\"width: 120px; height: 240px;\" sandbox=\"allow-popups allow-scripts allow-modals allow-forms allow-same-origin\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"\/\/rcm-fe.amazon-adsystem.com\/e\/cm?lt1=_blank&amp;bc1=000000&amp;IS2=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=infotecr-22&amp;language=ja_JP&amp;o=9&amp;p=8&amp;l=as4&amp;m=amazon&amp;f=ifr&amp;ref=as_ss_li_til&amp;asins=B07YXYM94G&amp;linkId=c592827d0a9befa45003dc1710db5e20\"><\/iframe><\/p>\n<h3>Ansible\u30af\u30c3\u30af\u30d6\u30c3\u30af impress top gear\u30b7\u30ea\u30fc\u30ba<\/h3>\n<p><iframe style=\"width: 120px; height: 240px;\" sandbox=\"allow-popups allow-scripts allow-modals allow-forms allow-same-origin\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"\/\/rcm-fe.amazon-adsystem.com\/e\/cm?lt1=_blank&amp;bc1=000000&amp;IS2=1&amp;bg1=FFFFFF&amp;fc1=000000&amp;lc1=0000FF&amp;t=infotecr-22&amp;language=ja_JP&amp;o=9&amp;p=8&amp;l=as4&amp;m=amazon&amp;f=ifr&amp;ref=as_ss_li_til&amp;asins=B09V4HW2LW&amp;linkId=57f8d97a138faaedd2db76907303fa17\"><\/iframe><\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ansible\u3067\u7ba1\u7406\u5bfe\u8c61\u306eLinux\u30b5\u30fc\u30d0\u306b\u5171\u901a\u3059\u308b\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002 \u4f5c\u696d\u3092\u884c\u3046\u524d\u63d0\u3092\u78ba\u8a8d\u3059\u308b\uff01 \u4f5c\u696d\u3092\u884c\u3046\u524d\u63d0\u3068\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u4f5c\u696d\u304c\u5b8c\u4e86\u3057\u3001Ansible\u3067\u30d1\u30b9\u30ef\u30fc\u30c9\u5165\u529b\u306a\u3057\u3067\u63a5\u7d9a\u3067\u304d\u308b\u74b0\u5883\u304c\u6574\u3063\u3066\u3044\u308b\u3053\u3068\u3092\u524d\u63d0\u3068\u3057\u307e\u3059\u3002 Linux\u30b5\u30fc\u30d0\u2026<\/p>\n","protected":false},"author":1,"featured_media":6881,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[157],"tags":[],"class_list":["post-6758","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ansible"],"_links":{"self":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/6758","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/comments?post=6758"}],"version-history":[{"count":0,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/posts\/6758\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/media\/6881"}],"wp:attachment":[{"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/media?parent=6758"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/categories?post=6758"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lab4ict.com\/system\/wp-json\/wp\/v2\/tags?post=6758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}