Skip to content

Instantly share code, notes, and snippets.

@harupong
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harupong/10450362 to your computer and use it in GitHub Desktop.
Save harupong/10450362 to your computer and use it in GitHub Desktop.
Ansible で遊ぼう

TODO

linode-cli 用の apt-repo 追加で失敗する

2014-04-13 17:30 くらいの ansible.log を確認してみよう

ansible-playbook の GATHERING FACTS で SSH エラーが出た場合の検知と対応方法を探す

2014-04-13 00:31:21,448 p=2608 u=ubuntu |  PLAY [all] ********************************************************************
2014-04-13 00:31:21,448 p=2608 u=ubuntu |  GATHERING FACTS ***************************************************************
2014-04-13 00:31:24,518 p=2608 u=ubuntu |  fatal: [106.186.18.73] => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
2014-04-13 00:31:24,519 p=2608 u=ubuntu |  TASK: [Install Ruby] **********************************************************
2014-04-13 00:31:24,534 p=2608 u=ubuntu |  FATAL: no hosts matched or all hosts have already failed -- aborting

2014-04-13 00:31:24,535 p=2608 u=ubuntu |  PLAY RECAP ********************************************************************
2014-04-13 00:31:24,536 p=2608 u=ubuntu |             to retry, use: --limit @/home/ubuntu/ripdiko.retry

2014-04-13 00:31:24,536 p=2608 u=ubuntu |  106.186.18.73              : ok=0    changed=0    unreachable=1    failed=0

grep のエラーコード使って検知し、./linode_ripdiko.sh を再実行するようにした。

linode-cli のインストール

https://github.com/linode/cli

Ansible を Control Machine にインストール

http://docs.ansible.com/intro_installation.html#id11

Ubuntuの場合

$ sudo apt-add-repository ppa:rquillo/ansible
$ sudo apt-get update
$ sudo apt-get install ansible

linode のインスタンスを起動して、インスタンスのIPアドレスを取得

linode create ripdiko --password $LINODE_PASSWORD
linode list --json | jq -r '.ripdiko.ips[0]' > .ansible.inventory

Ansible の Playbook を対象の Linode インスタンスに対して実行

http://yteraoka.github.io/ansible-tutorial/

ansible-playbook -i

ansible.cfg

sudo cp /etc/ansible/ansible.cfg ~/.ansible.cfg

以下を uncomment、かつ下の2つはパラメーターを追記

host_key_checking = False
log_path = /var/log/ansible.log
ssh_user = root
ssh_private_key_file = /home/ubuntu/.ssh/linode_id_rsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment