Linux 関係覚え書き

Ansible インストール

Ubuntu 18.04 LTS

# apt update
# apt install ansible

設定

~/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

[defaults]
host_key_checking = False

all.yml

ansible_ssh_private_key_file: ~/.ssh/id_rsa
ansible_python_interpreter: /usr/bin/python3

inventory

[localhost]
127.0.0.1 ansible_connection=local
 
[nfs]
nfs

[db]
db01

[web]
web01
web02

pb_web.yml

- hosts: web
  gather_facts: no
  vars:
    sample_vars: TEST Message
  tasks:
    - shell: uptime
      register: result

    - debug:
        msg: "{{ result.stdout }}"

    - debug:
        msg: "{{ sample_vars }}"

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2020-05-28 (木) 13:41:49