Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions playbooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ansible-playbook -i playbooks/nodes -s playbooks/site.yaml
15 changes: 15 additions & 0 deletions playbooks/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
if [ ! -f $HOME/.ssh/id_rsa.pub ]; then
ssh-keygen
fi

DEFAULT_SSH_PUBKEY=`cat $HOME/.ssh/id_rsa.pub`

if [ ! -d $HOME/.ssh ]; then
mkdir -p $HOME/.ssh
fi

chmod 0700 $HOME/.ssh
echo $DEFAULT_SSH_PUBKEY >> $HOME/.ssh/authorized_keys
chmod 0600 $HOME/.ssh/authorized_keys
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这一部分的内容 在 https://docs.vagrantup.com/v2/boxes/base.htmlDEFAULT USER SETTINGS 创建box的时候就已经做过了. 还需要加么?


sudo apt-get install ansible
2 changes: 2 additions & 0 deletions playbooks/nodes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[all]
localhost
2 changes: 2 additions & 0 deletions playbooks/roles/beansdb/handlers/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: Start beansdb
command:
25 changes: 25 additions & 0 deletions playbooks/roles/beansdb/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- name: Check if beansdb exists
stat: path=/usr/local/bin/beansdb
register: beansdb_bin

- name: Clone beansdb repo
git: repo=https://github.com/douban/beansdb dest=/tmp/beansdb version=master
when: beansdb_bin.stat.exists == false

- name: Install beansdb
command: ./autogen.sh && ./configure && make && make install
when: beansdb_bin.stat.exists == false
args:
chdir: /tmp/beansdb

- name: Create /data/beansdb
file: path=/data/beansdb state=directory mode=0755

- name: Create /etc/beansdb
file: path=/etc/beansdb state=directory mode=0755

- name: Copy log config
copy: src=/tmp/beansdb/beansdb_log.conf dest=/etc/beansdb/log.conf

- name: Start beansdb
command: beansdb -p 7900 -H /data/beansdb -T 0 -d -L /etc/beansdb/log.conf
11 changes: 11 additions & 0 deletions playbooks/roles/common/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- name: Install build-essential
apt: pkg=build-essential state=installed

- name: Install dh-autoreconf
apt: pkg=dh-autoreconf state=installed

- name: Install g++
apt: pkg=g++ state=installed

- name: Install git
apt: pkg=git state=installed
2 changes: 2 additions & 0 deletions playbooks/roles/memcached/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: Install memcached
apt: pkg=memcached state=installed
8 changes: 8 additions & 0 deletions playbooks/roles/mysql/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- name: Install MySQL Client
apt: pkg=mysql-client state=installed

- name: Install MySQL Server
apt: pkg=mysql-server state=installed

- name: Install MySQL lib
apt: pkg=libmysqlclient-dev state=installed
2 changes: 2 additions & 0 deletions playbooks/roles/redis/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: Install redis
apt: pkg=redis-server state=installed
26 changes: 26 additions & 0 deletions playbooks/roles/web/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# should install first
- name: check virtualenv
stat: path=/vagrant/venv
register: venv_bin

- name: create virualenv
command: virtualenv venv
when: venv_bin.stat.exists == false
args:
chdir: /vagrant

- name: Install python pip
apt: pkg=python-pip state=installed

- name: Install python virtualenv
apt: pkg=python-virtualenv state=installed

- name: Install python dev
apt: pkg=python-dev state=installed

- name: Install libffi
apt: pkg=libffi-dev state=installed

- pip: name=cython virtualenv=/vagrant/venv
- pip: name=setuptools virtualenv=/vagrant/venv
- pip: requirements=/vagrant/requirements.txt virtualenv=/vagrant/venv
12 changes: 12 additions & 0 deletions playbooks/site.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

- name: Setup CODE dev env
hosts:
- all
roles:
- common
- mysql
- beansdb
- redis
- memcached
- web