Created
June 15, 2014 09:19
-
-
Save mountcedar/c964b2cb0331b9c52582 to your computer and use it in GitHub Desktop.
Rubyが苦手な人のためのインフラストラクチャ自動化ツールAnsible ref: http://qiita.com/mountcedar/items/fcc83b23d7e5f97529f5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip install ansible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mkdir ansible_test | |
$ cd ansible_test | |
$ vagrant box add ubuntu12.04_amd64 https://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box | |
$ vagrant init ubuntu12.04_amd64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PLAY [servers] **************************************************************** | |
GATHERING FACTS *************************************************************** | |
The authenticity of host '192.168.33.10 (192.168.33.10)' can't be established. | |
RSA key fingerprint is XXXXXXXXXXXXXX | |
Are you sure you want to continue connecting (yes/no)? yes | |
ok: [192.168.33.10] | |
TASK: [apt-get update] ******************************************************** | |
ok: [192.168.33.10] | |
TASK: [apt-get upgrade] ******************************************************* | |
changed: [192.168.33.10] | |
TASK: [apt-get dist-upgrade] ************************************************** | |
ok: [192.168.33.10] | |
TASK: [apt-get install git make python-dev python-setuptools libblas-dev gfortran g++ python-pip python-numpy python-scipy liblapack-dev] *** | |
changed: [192.168.33.10] => (item=git,make,python-dev,python-setuptools,libblas-dev,gfortran,g++,python-pip,python-numpy,python-scipy,liblapack-dev) | |
TASK: [pip install nose] ****************************************************** | |
changed: [192.168.33.10] | |
TASK: [pip install theano] **************************************************** | |
changed: [192.168.33.10] | |
TASK: [get deb package from cude, http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1204/x86_64/cuda-repo-ubuntu1204_6.0-37_amd64.deb] *** | |
changed: [192.168.33.10] | |
TASK: [dpkg install cuda repo] ************************************************ | |
changed: [192.168.33.10] | |
TASK: [apt-get update] ******************************************************** | |
ok: [192.168.33.10] | |
TASK: [apt-get install cuda] ************************************************** | |
changed: [192.168.33.10] | |
TASK: [add cuda path to environmental variable (1/2)] ************************* | |
changed: [192.168.33.10] | |
TASK: [add cuda path to environmental variable (2/2)] ************************* | |
changed: [192.168.33.10] | |
PLAY RECAP ******************************************************************** | |
192.168.33.10 : ok=13 changed=9 unreachable=0 failed=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ vagrant ssh | |
vagrant@vagrant-ubuntu-precise-64:~$ python | |
Python 2.7.3 (default, Feb 27 2014, 19:58:35) | |
[GCC 4.6.3] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import theano | |
>>> | |
vagrant@vagrant-ubuntu-precise-64:~$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: apt-get update | |
apt: update_cache=yes | |
- name: apt-get upgrade | |
apt: upgrade=yes | |
- name: apt-get dist-upgrade | |
apt: upgrade=dist | |
- name: apt-get install git | |
apt: name=git state=latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: apt-get install git make python-dev python-setuptools libblas-dev gfortran g++ python-pip python-numpy python-scipy liblapack-dev | |
apt: name={{ item }} state=latest | |
with_items: | |
- git | |
- make | |
- python-dev | |
- python-setuptools | |
- libblas-dev | |
- gfortran | |
- g++ | |
- python-pip | |
- python-numpy | |
- python-scipy | |
- liblapack-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: get deb package from cuda | |
get_url: url="http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1204/x86_64/cuda-repo-ubuntu1204_6.0-37_amd64.deb" dest="/home/vagrant" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: dpkg install cuda repo | |
command: dpkg -i /home/vagrant/cuda-repo-ubuntu1204_6.0-37_amd64.deb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: pip install nose | |
pip: name=nose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: pip install theano | |
command: /usr/bin/pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: add cuda path to environmental variable (1/2) | |
lineinfile: dest=/home/vagrant/.bashrc state=present line="export PATH=$PATH:/usr/local/cuda-6.0/bin:" insertafter=EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: add wsgi settings | |
lineinfile: | |
dest=/etc/apache2/httpd.conf | |
state=present | |
line={{ item }} | |
insertafter=EOF | |
with_items: | |
- "'WSGIScriptAlias / /var/www/hoge/wsgi.py'" | |
- "'WSGIPythonPath /var/www/hoge/'" | |
- "'<Directory /var/www/hoge/>'" | |
- "'<Files wsgi.py>'" | |
- "'Order deny,allow'" | |
- "'Allow from all'" | |
- "'</Files>'" | |
- "'</Directory>'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.vm.network :private_network, ip: "192.168.33.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Host 192.168.33.10 | |
User vagrant | |
IdentityFile /Users/<username>/.vagrant.d/insecure_private_key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[servers] | |
192.168.33.10 # ゲストOSのIPを指定する |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ansible -i hosts servers -m ping | |
192.168.33.10 | success >> { | |
"changed": false, | |
"ping": "pong" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ansible -i hosts servers -a 'pwd' | |
192.168.33.10 | success | rc=0 >> | |
/home/vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ansible-playbook -i hosts playbook_theano.yaml --syntax-check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ansible-playbook -i hosts playbook_theano.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: servers | |
sudo: true | |
user: vagrant | |
tasks: | |
- name: apt-get update | |
apt: update_cache=yes | |
- name: apt-get upgrade | |
apt: upgrade=yes | |
- name: apt-get dist-upgrade | |
apt: upgrade=dist | |
- name: apt-get install git make python-dev python-setuptools libblas-dev gfortran g++ python-pip python-numpy python-scipy liblapack-dev | |
apt: name={{ item }} state=latest | |
with_items: | |
- git | |
- make | |
- python-dev | |
- python-setuptools | |
- libblas-dev | |
- gfortran | |
- g++ | |
- python-pip | |
- python-numpy | |
- python-scipy | |
- liblapack-dev | |
- name: pip install nose | |
pip: name=nose | |
- name: pip install theano | |
command: /usr/bin/pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git | |
- name: get deb package from cuda, http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1204/x86_64/cuda-repo-ubuntu1204_6.0-37_amd64.deb | |
get_url: url="http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1204/x86_64/cuda-repo-ubuntu1204_6.0-37_amd64.deb" dest="/home/vagrant" | |
- name: dpkg install cuda repo | |
command: dpkg -i /home/vagrant/cuda-repo-ubuntu1204_6.0-37_amd64.deb | |
- name: apt-get update | |
apt: update_cache=yes | |
- name: apt-get install cuda | |
apt: name=cuda state=latest | |
- name: add cuda path to environmental variable (1/2) | |
lineinfile: dest=/home/vagrant/.bashrc state=present line="export PATH=$PATH:/usr/local/cuda-6.0/bin:" insertafter=EOF | |
- name: add cuda path to environmental variable (2/2) | |
lineinfile: dest=/home/vagrant/.bashrc state=present line="export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-6.0/lib64:" insertafter=EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment