Help us understand the problem. What is going on with this article?

ansibleの勉強を初めてみた

More than 1 year has passed since last update.

ansibleメモ

イベントリーファイル

  • 資材を配置するサーバを指定できる
  • []で括ることで、サーバグループを作成する可能
server1.sample.com
server2.sample.com

[mail]
server3.sample.com
server4.sample.com

[db]
server5.sample.com
server6.sample.com

web  ansible_host=server1.company.com ansible_connection=ssh   ansible_user=root
db   ansible_host=server2.company.com ansible_connection=winrm   ansible_user=admin
mail ansible_host=server3.company.com ansible_connection=ssh   ansible_ssh_pass=P@#
web2 ansible_host=server4.company.com ansible_connection=winrm

localhost ansible_connection=localhost

パラメータ例
ansible_connection - ssh/winrm/localhost
ansible_port - 22/5986
ansible_user - root/administrator
ansible_ssh_pass - Password
  • インベントリーファイル作成
[osboxes@osboxes test-project]$ cat inventory.txt
target1 ansible_host=192.168.11.30 ansible_ssh_pass=osboxes.org

[osboxes@osboxes test-project]$ ansible target1 -m ping -i inventory.txt
target1 | FAILED! => {
    "msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host."
}

ssh接続をしたことないサーバに接続する場合には、上記のようなエラーが出るみたい
そのため、ansibleから接続する前に、一度sshコマンドでサーバに接続する

  • 便利メモ

サービスの起動もできる
serviceコマンド

テキストファイルの書き換えも可能
lineinfileコマンド

ドメインネームサーバへの追加
vars: dns_server

コマンドのループもできる
with_items:
-
-

  • ansible roles

include
vars_files:
- variables.yml

tasks:
- include: tasks.yml

playAbleでいろいろ確認できるみたい

力尽きたのであとで書き直そ

gogogonkun
毎日分からないことだらけの駆け出しSEです。
perches
東京を拠点とした初心者向けのプログラミングサークルです。年6回ほどハッカソンを主催しています。
https://perches.github.io
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした