投稿

ラベル(python)が付いた投稿を表示しています

ansible による pyramid 環境構築

ansible を使ってみたいということで。 Chef とかといったような構成管理ツールです。Python 製ですが Python の知識はいらず、yaml 形式のシンプルにかけるものです。 チュートリアル http://yteraoka.github.io/ansible-tutorial/ を上から自分の環境に合わせて実行してみました。Ubuntu なので yum でなく apt モジュールになります。 インストールされている前提。pip からインストールできたはずです。 疎通確認 ansible で接続するには、host 名が書かれた hosts ファイルが必要です。 カレントディレクトリを優先して読んでくれるので、そこに作成。 .ssh/config に設定してある Host も使用可能。 echo hostname > hosts 下記のコマンドで、今作った hosts ファイルを指定してちゃんと相手に接続できるか確認します。 % ansible -i hosts hostname -m ping devops | success >> { "changed": false, "ping": "pong" } 接続成功。 コマンドを実行してみる。 ansible -i hosts hostname -a 'uname -r' devops | success | rc=0 >> 3.2.0-29-generic できた。 試しに vim を install してみます。 % ansible -i hosts devops -m apt -s -a name=vim devops | success >> { "changed": false } install 済みなので失敗。 Playbook playbook を書いてみます。言語に依存しないシンプルなファイルらしい。 まずインベントリファイルでグループを定義。 % cat hosts [pyramid] hostname playbook の作成。 --- - hosts:...

heroku / Django

イメージ
heroku に登録 登録すらしてなかった。登録から。 heroku のサイト へ行って、 メールアドレス入力 メールが届くのでそこにあるURL からログイン password 入力 登録 で登録完了。 toolbelt を install 登録後の dashboard か、 ここ から Heroku toolbelt を入手。 Heroku login % ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/Users/user/.ssh/id_rsa): /Users/user/.ssh/heroku Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/user/.ssh/heroku. Your public key has been saved in /Users/user/.ssh/heroku.pub. The key fingerprint is: (略) The key's randomart image is: +--[ RSA 2048]----+ (略) +-----------------+ 鍵を作る。 heroku login コマンドでログインする。 公開鍵も登録。 %heroku login Enter your Heroku credentials. Email: mailaddress Password (typing will be hidden): Found the following SSH public keys: 1) heroku.pub Which would you like to use with your Heroku account? 1 秘密鍵を登録。Host は heroku.com じゃないといけない。 % vim ~/.ssh/config Host heroku.com Hostname ...

Django memo

Django のチュートリアルをやっていく過程でいろいろとメモ。 プロジェクトの作成 % django-admin.py startproject testprj を実行すると、 % cd testproj % ls __init__.py settings.py urls.py wsgi.py 中にこんな感じのができる。 testprj/settings.py の中に database に関する記述をする。 今回は PostgreSQL を使うので、改良。デフォルトは SQLite3 になっている。 DATABASES 'default' ENGINE 'django.db.backends.postgresql_psycopg2' 見たいに書き換え。

Ubuntu 12.04 for python 3

Ubuntu 12.04 で Python3.2 使いたいと思ったけれど、Ubuntu で Python 3.2 を探してもソースコードからコンパイルしか無い……って悩んでいたが、普通にありました。 sudo apt-get install python3 でインストールできます。 % python3.2 Python 3.2.3 (default, May 3 2012, 15:51:42) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 参考 http://askubuntu.com/questions/134747/how-do-i-run-python-3-2-3