tech_memo / linux / ansible


tech_memo/linux

konwn_hostsに未登録ホストに接続する際に、登録の質問をskipする

  • defaultだと、未登録ホストへの接続は、以下のように、yes/noが聞かれる
    [root@testserver07 ansible]# ansible all -m ping -k
    SSH password:
    
    paramiko: The authenticity of host 'testserver11' can't be established.
    The ssh-rsa key fingerprint is ea5f4143e3a6bd9b7dcd7d839256f98b.
    Are you sure you want to continue connecting (yes/no)?
  • /etc/ansible/ansible.cfgに以下を設定することで、上記を回避できる
    host_key_checking = False

ユーザ作成時のパスワード指定

  • ハッシュ化する必要がある。下記はpythonでハッシュ化する例
    [root@testserver07 setup]# python -c 'import crypt; print crypt.crypt("password", "salt")'
    sa3tHJ3/KuYvI
  • 上記値をymlで指定する
    - user: name=<user> password=sa3tHJ3/KuYvI

ansible module詳細

best practice ディレクトリ階層

rolesの使い方