直到使用Ansible通过ec2.py进行ping测试
安装
# yum install python-boto.noarch
# yum install python-argparse.noarch
# mkdir ~/.ansible
# cd ~/.ansible
# curl -k -LO https://raw.github.com/ansible/ansible/# devel/plugins/inventory/ec2.ini
# curl -k -LO https://raw.github.com/ansible/ansible/devel/plugins/inventory/ec2.py
# chmod +x ~/.ansible/ec2.py
.bash_profile (重要文件,用于配置用户的shell环境)
export AWS_ACCESS_KEY_ID='YOURACCESSKEYID'
export AWS_SECRET_ACCESS_KEY='YOURSECRETACCESSKEY'
export EC2_INI_PATH=~/.ansible/ec2.ini
# . .bash_profile
平
在安全组中允许端口22。
# ansible ec2 -i ~/.ansible/ec2.py -u ec2-user -m ping
1.2.3.4 | success >> {
"changed": false,
"ping": "pong"
}