Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b012100

Browse files
committed
Refactor playbook
- Avoid unnecessary "changed" messages - with_items is redundant for base Python packages - Move restart pgsql to handlers
1 parent f452e9e commit b012100

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

provisioning/pythondotorg.yml

+15-6
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@
2525
- python-setuptools
2626
- python-pip
2727
- ruby
28+
register: result
29+
changed_when:
30+
"'0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.' not in result.stdout"
2831

2932
- name: Install base Python packages
30-
pip: name={{ item }}
31-
with_items:
32-
- virtualenv
33+
pip: name=virtualenv
3334

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

3841
- name: Install base Ruby packages
3942
sudo: yes
@@ -64,9 +67,7 @@
6467
name={{ database.user }}
6568
priv=ALL
6669
state=present
67-
68-
- name: Restart postgresql
69-
service: name=postgresql state=restarted enabled=yes
70+
notify: Restart PostgreSQL
7071

7172
- name: Ensure python/pythondotorg is cloned
7273
sudo: no
@@ -94,10 +95,18 @@
9495
command: "bundler install"
9596
args:
9697
chdir: "{{ project.path }}"
98+
register: result
99+
changed_when: "result.rc != 0 or result.stderr != ''"
97100

98101
- name: Install database migrations
99102
sudo: no
100103
django_manage: command=migrate
101104
app_path={{ project.path }}
102105
virtualenv={{ project.virtualenv }}
103106
settings={{ django.settings }}
107+
register: result
108+
changed_when: "'No migrations to apply.' not in result.out"
109+
110+
handlers:
111+
- name: Restart PostgreSQL
112+
service: name=postgresql state=restarted enabled=yes

0 commit comments

Comments
 (0)