7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ansible サーバ管理メモ

Last updated at Posted at 2015-07-13

#Ansible によるサーバ管理のメモ

  • コントロール優先で ansible.cfg はカレントディレクトリに用意

#inventory

  • inventory/ に環境毎、グループ毎に分割して配置
  • Ansible の仕様により、 group_vars, host_vars を inventory 下に配置

#ansible

  • ssh

    導通前に ssh でサーバ接続し、コネクションを確認する
  • 導通

    ansible -i [inventory] [hostname] -m ping
  • fact 取得

    ansible -i [inventory] [hostname] -m setup
  • コマンド ( ex uname )

    ansible -i [inventory] [hostname] -a 'uname -a'

ansible-doc

  • module help ( ex yum )

    ansible-doc yum

ansible-playbook

  • 文法チェック

    ansible-playbook playbook/servers_local.yml --syntax-check
  • 対象ホストを確認する

    ansible-playbook playbook/servers_local.yml --list-hosts
  • 対象タスクを確認する

    ansible-playbook playbook/servers_local.yml --list-task
  • Dry run

    ansible-playbook playbook/servers_local.yml --check
  • step 実行

    ansible-playbook playbook/servers_local.yml --step
  • ホスト指定実行

    ansible-playbook playbook/servers_local.yml -l [hostname]
  • タグ指定実行

    ansible-playbook playbook/servers_local.yml --tags=XXX
  • 接続テスト (インベントリやホストの切り替え後に接続テストする)

    ansible-playbook playbook/ping.yml
7
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?