#author("2020-05-28T13:41:49+09:00","default:tanak0to","tanak0to")
RIGHT:[[Linux 関係覚え書き]]

*Ansible インストール [#l31836de]
Ubuntu 18.04 LTS
 # apt update
 # apt install ansible

*設定 [#laea4499]
 ~/Ansible
 に inventory ファイル,Playbook ファイル,var ファイルのサンプルを作った.
 $ mkdir ~/Ansible
 $ cd ~/Ansible
 $ cp /etc/ansible/ansible.cfg .
 $ cp /etc/ansible/hosts inventory

 ~/Ansible/
 ├── ansible.cfg
 ├── group_vars
 │   ├── all.yml
 │   ├── nfs.yml
 │   ├── db.yml
 │   └── web.yml
 ├── inventory
 ├── pb_nfs_cmd.yml
 ├── pb_db_cmd.yml
 └── pb_web_cmd.yml


 % ansible-playbook -i inventory pb_web_cmd.yml

**ansible.cfg [#r8cf047f]
 [defaults]
 host_key_checking = False

**all.yml [#md672ae2]
 ansible_ssh_private_key_file: ~/.ssh/id_rsa
 ansible_python_interpreter: /usr/bin/python3

**inventory [#o72a5fea]
 [localhost]
 127.0.0.1 ansible_connection=local
  
 [nfs]
 nfs
 
 [db]
 db01
 
 [web]
 web01
 web02

**pb_web.yml [#ed22cb3f]
 - hosts: web
   gather_facts: no
   vars:
     sample_vars: TEST Message
   tasks:
     - shell: uptime
       register: result
 
     - debug:
         msg: "{{ result.stdout }}"
 
     - debug:
         msg: "{{ sample_vars }}"



トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS