Linux/Ubuntu/Ansible
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
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 }}"
終了行:
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 }}"
ページ名: