Skip to content

Commit 753ca13

Browse files
committed
Merge pull request #13 from smajda/ansible_kickoff
Initial ansible setup.
2 parents fe64620 + 239115b commit 753ca13

File tree

10 files changed

+79
-5
lines changed

10 files changed

+79
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.gondor
2+
.vagrant
23
*.pyc
34
pythonkc_site/pythonkc.sqlite
45
pythonkc_site/local_settings.py

README.markdown

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,29 @@
22

33
Files for the PythonKC.com website.
44

5-
## Development Quickstart
5+
## Development Quickstart Option 1 (vagrant)
6+
7+
```
8+
vagrant plugin install vagrant-hostmanager
9+
vagrant plugin install vagrant-vbguest
10+
vagrant up
11+
```
12+
13+
`vagrant up` will run `provision.sh` which runs ansible on the VM.
14+
15+
We've done this so you don't have to install ansible on your local machine.
16+
17+
If you'd prefer you can always ssh in and run/re-run the provisioner manually
18+
(the output is a little nicer this way):
19+
20+
```
21+
vagrant ssh
22+
cd ~/vagrant/ansible
23+
ansible-playbook vagrant.yml
24+
```
25+
26+
## Development Quickstart Option 2 (virtualenv)
27+
628
```
729
mkvirtualenv pythonkc
830
git clone git@github.com:pythonkc/pythonkc.com.git

ansible/ansible.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[defaults]
2+
hostfile = ./hosts
3+
transport = ssh

ansible/group_vars/all.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
example: true # TODO, put any common variables in here

ansible/group_vars/production.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
user: pythonkc

ansible/group_vars/vagrant.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
user: vagrant

ansible/hosts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[vagrant]
2+
localhost ansible_connection=local
3+
4+
# TODO
5+
#[production]
6+
#pythonkc.com

ansible/roles/base/tasks/main.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
- name: Update apt
3+
apt: update_cache=yes cache_valid_time=3600
4+
tags: apt
5+
6+
- name: Install some base packages
7+
apt: pkg="{{item}}" state=latest
8+
tags: apt
9+
with_items:
10+
- build-essential
11+
- python3
12+
- python3-dev
13+
- python3-pip
14+
- python3-software-properties
15+
16+
# What else should go in here?
17+
# vim + vim configuration for python?

ansible/vagrant.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
- hosts: vagrant
3+
sudo: yes
4+
5+
# you can have tasks right here
6+
tasks:
7+
- name: Say hello
8+
shell: echo `date` > /home/vagrant/hello.txt
9+
10+
# and you can have 'roles'
11+
roles:
12+
- role: base
13+
tags: base_role
14+

provision.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33

44
export DEBIAN_FRONTEND=noninteractive
55

6-
aptitude update
7-
aptitude dist-upgrade -y
8-
aptitude install -y python3 python3-dev python3-pip ansible
96
ln -sf /vagrant /home/vagrant/
10-
# TODO: Run Ansible playbooks
7+
8+
if [[ -z "$(which ansible)" ]]; then
9+
echo "Installing ansible"
10+
aptitude update
11+
aptitude install -y python3 python3-dev python3-pip ansible
12+
fi
13+
14+
cd /home/vagrant/vagrant/ansible
15+
ansible-playbook vagrant.yml

0 commit comments

Comments
 (0)