Skip to content

Commit

Permalink
Refactor playbook
Browse files Browse the repository at this point in the history
- Avoid unnecessary "changed" messages
- with_items is redundant for base Python packages
- Move restart pgsql to handlers
  • Loading branch information
berkerpeksag committed Sep 29, 2015
1 parent f452e9e commit b012100
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions provisioning/pythondotorg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@
- python-setuptools
- python-pip
- ruby
register: result
changed_when:
"'0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' not in result.stdout"

- name: Install base Python packages
pip: name={{ item }}
with_items:
- virtualenv
pip: name=virtualenv

- name: Install python-lxml deps
# TODO: for some reason apt: pkg=python-lxml state=build-dep doesn't work
command: apt-get -y build-dep python-lxml
register: result
changed_when: "result.rc != 0"

- name: Install base Ruby packages
sudo: yes
Expand Down Expand Up @@ -64,9 +67,7 @@
name={{ database.user }}
priv=ALL
state=present

- name: Restart postgresql
service: name=postgresql state=restarted enabled=yes
notify: Restart PostgreSQL

- name: Ensure python/pythondotorg is cloned
sudo: no
Expand Down Expand Up @@ -94,10 +95,18 @@
command: "bundler install"
args:
chdir: "{{ project.path }}"
register: result
changed_when: "result.rc != 0 or result.stderr != ''"

- name: Install database migrations
sudo: no
django_manage: command=migrate
app_path={{ project.path }}
virtualenv={{ project.virtualenv }}
settings={{ django.settings }}
register: result
changed_when: "'No migrations to apply.' not in result.out"

handlers:
- name: Restart PostgreSQL
service: name=postgresql state=restarted enabled=yes

0 comments on commit b012100

Please sign in to comment.