first pass at using roles w/ localvm

pull/1/head
Raymond Yee 2015-06-03 07:05:27 -07:00
parent eb0f51f1b7
commit dd367e39ff
5 changed files with 101 additions and 83 deletions

2
vagrant/Vagrantfile vendored
View File

@ -118,7 +118,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# trying to mimic https://github.com/mozilla/fxa-dev/blob/b9b6f347c786428b347b82d38fb67e2c2fd1b827/vagrant/Vagrantfile
# but this doesn't work
override.vm.provision "ansible" do |ansible|
ansible.playbook = 'localvm.yml'
ansible.playbook = 'hello2.yml'
#ansible.start_at_task = 'remove all default enabled sites'
end

View File

@ -3,15 +3,12 @@
vars:
user: "{{ ansible_ssh_user }}"
sudo: yes
tasks:
pre_tasks:
- name: Hello server
shell: date > now.txt
- name: add ssh keys from public_key directory
authorized_key: user={{user}} key="{{item}}" state=present
with_items:
- https://github.com/rdhyee.keys
- https://github.com/eshellman.keys
sudo: yes
roles:
- role: mysql
#mysql_root_pw: "{{mysql_root_pw}}"
#mysql_regluit_pw: "{{mysql_regluit_pw}}"

View File

@ -12,85 +12,17 @@
apt: update_cache=yes
when: ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > 60*60*12
tasks:
roles:
# sudo add repo to get latest version of python 2.7
- name: add-apt-repository ppa:fkrull/deadsnakes-python2.7
apt_repository: repo='ppa:fkrull/deadsnakes-python2.7' state=present update_cache=true
- name: do apt-get update --fix-missing
command: apt-get update --fix-missing
- name: installing dependencies
apt: pkg={{ item }} update_cache=yes state=present
with_items:
- python2.7
- git-core
- apache2
- libapache2-mod-wsgi
- mysql-client
- python-virtualenv
- python-mysqldb
- redis-server
- python-lxml
- python-dev
- libmysqlclient-dev
- libxml2-dev
- libxslt1-dev
- python-setuptools
- postfix
tags: install
- name: make {{user}} group
group: name={{user}}
- name: make {{user}} user
user: name={{user}} shell=/bin/bash group={{user}} generate_ssh_key=yes
- name: install some python modules to use
#pip: name={{item}} virtualenv=/home/{{user}}/venv
pip: name={{item}}
with_items:
- PyGithub
- name: create /opt/regluit
file: path=/opt/regluit state=directory owner={{user}} group={{user}} mode=0745
- name: git config
command: "{{item}}"
with_items:
- git config --global user.name "Raymond Yee"
- git config --global user.email "rdhyee@gluejar.com"
- name: ssh-keygen
#command: pwd
command: ssh-keygen -b 2048 -t rsa -f /home/{{user}}/.ssh/id_rsa -P ""
sudo: no
args:
creates: /home/{{user}}/.ssh/id_rsa
- name: create deploy key for repo
action: github_deploy_key
sudo: no
args:
github_auth_key: "{{github_auth_key}}"
repo_name: Gluejar/regluit
key_name: localvm
key_path: /home/{{user}}/.ssh/id_rsa.pub
- name: postfix install
raw: DEBIAN_FRONTEND='noninteractive' apt-get install -y -q --force-yes postfix
- name: clone the regluit git repo into /opt/regluit
sudo: no
git: repo=ssh://git@github.com/Gluejar/regluit.git dest=/opt/regluit accept_hostkey=True force=yes version=sysadmin
# base setup
- role: common
# installing mysql
# https://github.com/bennojoy/mysql --> probably the right way
# how do you make use of other people's playbooks in the right way?
# http://stackoverflow.com/a/7740571/7782
post_tasks:
- name: mysql setup
raw: debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password password {{mysql_root_pw}}'
- raw: debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password_again password {{mysql_root_pw}}'

View File

@ -0,0 +1,71 @@
# sudo add repo to get latest version of python 2.7
- name: add-apt-repository ppa:fkrull/deadsnakes-python2.7
apt_repository: repo='ppa:fkrull/deadsnakes-python2.7' state=present update_cache=true
- name: do apt-get update --fix-missing
command: apt-get update --fix-missing
- name: installing dependencies
apt: pkg={{ item }} update_cache=yes state=present
with_items:
- python2.7
- git-core
- apache2
- libapache2-mod-wsgi
- mysql-client
- python-virtualenv
- python-mysqldb
- redis-server
- python-lxml
- python-dev
- libmysqlclient-dev
- libxml2-dev
- libxslt1-dev
- python-setuptools
- postfix
tags: install
- name: make {{user}} group
group: name={{user}}
- name: make {{user}} user
user: name={{user}} shell=/bin/bash group={{user}} generate_ssh_key=yes
- name: install some python modules to use
#pip: name={{item}} virtualenv=/home/{{user}}/venv
pip: name={{item}}
with_items:
- PyGithub
- name: create /opt/regluit
file: path=/opt/regluit state=directory owner={{user}} group={{user}} mode=0745
- name: git config
command: "{{item}}"
with_items:
- git config --global user.name "Raymond Yee"
- git config --global user.email "rdhyee@gluejar.com"
- name: ssh-keygen
#command: pwd
command: ssh-keygen -b 2048 -t rsa -f /home/{{user}}/.ssh/id_rsa -P ""
sudo: no
args:
creates: /home/{{user}}/.ssh/id_rsa
- name: create deploy key for repo
action: github_deploy_key
sudo: no
args:
github_auth_key: "{{github_auth_key}}"
repo_name: Gluejar/regluit
key_name: localvm
key_path: /home/{{user}}/.ssh/id_rsa.pub
- name: postfix install
raw: DEBIAN_FRONTEND='noninteractive' apt-get install -y -q --force-yes postfix
- name: clone the regluit git repo into /opt/regluit
sudo: no
git: repo=ssh://git@github.com/Gluejar/regluit.git dest=/opt/regluit accept_hostkey=True force=yes version=sysadmin

View File

@ -0,0 +1,18 @@
- name: mysql setup
raw: debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password password {{mysql_root_pw}}'
- raw: debconf-set-selections <<< 'mysql-server-5.5 mysql-server/root_password_again password {{mysql_root_pw}}'
- raw: apt-get -y install mysql-server
- name: Create regluit database
mysql_db: db=regluit state=present encoding=utf8 collation=utf8_bin login_user=root login_password={{mysql_root_pw}}
# GRANT ALL PRIVILEGES ON regluit.* TO 'regluit'@'localhost' WITH GRANT OPTION; (covered?)
- name: Create database user
mysql_user: >
user=regluit
password={{mysql_regluit_pw}}
host=localhost
priv=*.*:ALL
state=present
login_user=root
login_password={{mysql_root_pw}}