[root] cd /opt [root] git clone git://github.com/ansible/ansible.git –recursive [root] cd ./ansible [root] source ./hacking/env-setup [root] pip install paramiko PyYAML Jinja2 httplib2 six [root] make && make install
[root] cd /opt/ansible [root] git pull –rebase [root] git submodule update –init –recursive [root] make && make install
$ echo “127.0.0.1” > /ansible_hosts
$ export ANSIBLE_INVENTORY=/ansible_hosts
$ echo “export ANSIBLE_INVENTORY=~/ansible_hosts” » ~/.bashrc
$ ansible all -m ping $ ansible mt-scrapy -m ping Note: If you want to specify a different inventory file, specify it through “-i”. E.g.: $ ansible -i ~/ansible_hosts all -m ping
$ vim ~/ansible_hosts
# NOTES:
# 1) As a private key, you can add a normal ssh key (e.g., "id_rsa"), or a ".pem" key (used e.g. by Amazon AWS).
#
# 2) When adding new machines below, make sure to manually ssh into them the first time (for the trust to be established).
# E.g.:
# $ ssh -i ~/.ssh/precifica-NV-crawler.pem centos@172.16.0.215
# [localhost]
# 127.0.0.1
[mt-scrapy]
172.16.0.216 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
172.16.0.22 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
172.16.0.157 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
172.16.0.171 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
172.16.0.166 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
172.16.0.170 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
172.16.0.31 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
172.16.0.6 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
172.16.0.43 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
172.16.0.20 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
172.16.0.15 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
172.16.0.215 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
$ vim ~/ansible_hosts
# NOTES:
# 1) As a private key, you can add a normal ssh key (e.g., "id_rsa"), or a ".pem" key (used e.g. by Amazon AWS).
#
# 2) When adding new machines below, make sure to manually ssh into them the first time (for the trust to be established).
# E.g.:
# $ ssh -i ~/.ssh/precifica-NV-crawler.pem centos@172.16.0.215
#
# [localhost]
# 127.0.0.1
[mt-scrapy-active]
scrapy-americanas ansible_ssh_host=172.16.0.216 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
scrapy-extra ansible_ssh_host=172.16.0.22 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
scrapy-others01 ansible_ssh_host=172.16.0.157 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
scrapy-others02 ansible_ssh_host=172.16.0.171 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
scrapy-others03 ansible_ssh_host=172.16.0.166 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
scrapy-others04 ansible_ssh_host=172.16.0.170 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
scrapy-pneus01 ansible_ssh_host=172.16.0.31 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
scrapy-pneus02 ansible_ssh_host=172.16.0.6 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
scrapy-pontofrio ansible_ssh_host=172.16.0.43 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
scrapy-ricardo_eletro ansible_ssh_host=172.16.0.20 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
scrapy-shoptime ansible_ssh_host=172.16.0.15 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
scrapy-submarino ansible_ssh_host=172.16.0.215 ansible_connection=ssh ansible_ssh_private_key_file=/home/centos/.ssh/precifica-NV-crawler.pem
(Attention: single and double quotes matter on that case). Use exactly as below. $ ansible mt-scrapy -m shell -a ’echo $TERM' $ ansible mt-scrapy -m shell -a ‘sudo wc -l /opt/precifica/precifica-scrapy/scraped/*scraped.csv’ How to run commands as another user (e.g., a sudo one): $ ansible -b –become-user=engdeploy scrapy-submarino -m shell -a ‘cd /opt/precifica/precifica-scrapy && git reset –hard && git status’
$ ansible mt-scrapy -m copy -a “src=/etc/hosts dest=/tmp/hosts”
$ ansible mt-scrapy -m file -a “dest=/srv/foo/b.txt mode=600 owner=mdehaan group=mdehaan”
$ ansible mt-scrapy -m file -a “dest=/path/to/c mode=755 owner=mdehaan group=mdehaan state=directory”
$ ansible mt-scrapy -m file -a “dest=/path/to/c state=absent”