Skip to content
This repository has been archived by the owner on Apr 12, 2020. It is now read-only.

Commit

Permalink
more refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Dyachkov committed Feb 24, 2016
1 parent 515eb27 commit c8c74a0
Show file tree
Hide file tree
Showing 14 changed files with 300 additions and 423 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.vagrant/
/playbooks/pepyatka.vault
dev
/plugins/callback/*.pyc
15 changes: 15 additions & 0 deletions candy
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[target]
candy.freefeed.net

[pepyatka:children]
target

[nginx:children]
target

[staging:children]
target

[staging_secrets:children]
target

2 changes: 0 additions & 2 deletions group_vars/staging
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
---

pepyatka_ansible_branch: development
pepyatka_html_branch: temp-enable-signup
pepyatka_lite_branch: development
pepyatka_redis_host: pepyatka-micro.gfaoo9.0001.euw1.cache.amazonaws.com
pepyatka_s3_bucket: freefeed-storage-test
pepyatka_lite_hostname: nanopeppa.freefeed.net
freefeed_recaptcha_enabled: false
1 change: 1 addition & 0 deletions host_vars/candy.freefeed.net
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---

pepyatka_ansible_branch: add-candy-server
pepyatka_hostname: candy.freefeed.net
pepyatka_media_hostname: micropeppa-media.freefeed.net
pepyatka_statsd_prefix: candy
Expand Down
3 changes: 3 additions & 0 deletions host_vars/micropeppa.freefeed.net
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
---

pepyatka_hostname: micropeppa.freefeed.net
pepyatka_html_hostname: micropeppa.freefeed.net
pepyatka_media_hostname: micropeppa-media.freefeed.net
pepyatka_statsd_prefix: micropeppa
pepyatka_deploy_inventory: micropeppa
pepyatka_server_branch: development
pepyatka_html_branch: temp-enable-signup
pepyatka_lite_enabled: true
pepyatka_lite_hostname: nanopeppa.freefeed.net
freefeed_react_client_enabled: true
freefeed_react_client_branch: master
freefeed_react_client_hostname: george.freefeed.net
Expand Down
6 changes: 2 additions & 4 deletions playbooks/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
pip: name={{ item }} state=latest
with_items:
- dogapi
- httplib2
tags:
- bootstrap

- name: Install ansible
pip: name={{ item }} state=present
with_items:
- ansible
- httplib2
pip: name=ansible state=present version=1.9.4
tags:
- bootstrap

Expand Down
13 changes: 9 additions & 4 deletions roles/nginx/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---

pepyatka_html_repo: https://github.com/pepyatka/pepyatka-html.git
pepyatka_html_branch: development
www_user: www-data
www_group: www-data
pepyatka_hostname: localhost
pepyatka_server_host: localhost
pepyatka_server_instances:
- 3000
Expand All @@ -15,9 +12,17 @@ nginx_client_max_body_size: '10M'
nginx_use_proxy_protocol: False
nginx_proxy_protocol_real_ips: []
pepyatka_ga_account: "UA-XXXXXX"
pepyatka_lite_enabled: False
pepyatka_html_enabled: True
pepyatka_html_repo: https://github.com/pepyatka/pepyatka-html.git
pepyatka_html_branch: master
pepyatka_html_hostname: localhost
freefeed_react_client_enabled: False
freefeed_react_client_repo: https://github.com/freefeed/freefeed-react-client.git
freefeed_react_client_branch: master
freefeed_react_client_hostname: localhost
pepyatka_lite_enabled: False
pepyatka_lite_repo: https://github.com/freefeed/freefeed-lite.git
pepyatka_lite_branch: master
pepyatka_lite_hostname: localhost
pepyatka_local_storage_whoami_cache_key: whoamiCache
freefeed_recaptcha_sitekey: ""
164 changes: 164 additions & 0 deletions roles/nginx/tasks/ember.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
- name: Deploy pepyatka-html
git:
repo: "{{ pepyatka_html_repo }}"
update: yes
dest: /var/www/pepyatka-html
version: "{{ pepyatka_html_branch }}"
force: yes
register: pepyatka_html
tags:
- pepyatka
- nginx

- name: Save changelog in a file
shell: echo "{{ pepyatka_html.before }}...{{ pepyatka_html.after }}" > /tmp/pepyatka-html-changelog
when: pepyatka_html.before != pepyatka_html.after
tags: pepyatka

- name: Fetch pepyatka-html changelog
fetch:
src=/tmp/pepyatka-html-changelog
dest=pepyatka-html-changelog/{{ inventory_hostname }}
flat=yes
when: pepyatka_html.before != pepyatka_html.after
tags: pepyatka

- name: Fix server name in public/js/config.js
replace:
dest: /var/www/pepyatka-html/public/js/config.js
regexp: "host:.*"
replace: "host: \"{{ pepyatka_frontend_scheme }}://{{ pepyatka_html_hostname }}\","
tags:
- pepyatka
- nginx

- name: Fix siteName in public/js/config.js
replace:
dest: /var/www/pepyatka-html/public/js/config.js
regexp: "siteName:.*"
replace: "siteName: '{{ pepyatka_service_name }}',"
tags:
- pepyatka
- nginx

- name: Fix auth.cookieDomain in public/js/config.js
replace:
dest: /var/www/pepyatka-html/public/js/config.js
regexp: "cookieDomain:.*"
replace: "cookieDomain: '{{ pepyatka_auth_cookie_domain }}',"
tags:
- pepyatka
- nginx

- name: Fix auth.tokenPrefix in public/js/config.js
replace:
dest: /var/www/pepyatka-html/public/js/config.js
regexp: "tokenPrefix:.*"
replace: "tokenPrefix: '{{ pepyatka_auth_token_prefix }}'"
tags:
- pepyatka
- nginx

- name: Update version in public/index.html
replace:
dest: /var/www/pepyatka-html/public/index.html
regexp: "v=.*"
replace: "v={{ pepyatka_html_remote_version.stdout }}\""
when: pepyatka_html.before != pepyatka_html.after
tags:
- pepyatka
- nginx

- name: Update ga account in public/index.html
replace:
dest: /var/www/pepyatka-html/public/index.html
regexp: "UA.+'"
replace: "{{ pepyatka_ga_account }}'"
tags:
- pepyatka
- nginx

- name: Update server url in public/js/bookmarklet*.js
replace:
dest: "/var/www/pepyatka-html/public/js/{{ item }}"
regexp: "http://localhost:3333"
replace: "{{ pepyatka_frontend_scheme }}://{{ pepyatka_html_hostname }}"
with_items:
- bookmarklet.js
- bookmarklet.min.js
tags:
- pepyatka
- nginx

- name: Read bookmarklet.min.js
shell: cat /var/www/pepyatka-html/public/js/bookmarklet.min.js
register: bookmarklet_min_js_content
changed_when: false
tags:
- pepyatka
- nginx

- name: Populate BOOKMARKLET_PLACEHOLDER
replace:
dest: /var/www/pepyatka-html/public/js/app/layouts/authorizedLayout.handlebars
regexp: "BOOKMARKLET_PLACEHOLDER"
replace: "{{ bookmarklet_min_js_content.stdout }}"
tags:
- pepyatka
- nginx

- name: Cleanup local node_modules
file: path=/var/www/pepyatka-html/node_modules state=absent
when: pepyatka_html.before != pepyatka_html.after
tags:
- pepyatka
- nginx

- name: Install pepyatka-html dependencies
npm: path=/var/www/pepyatka-html state=latest
tags:
- pepyatka
- nginx

- name: Clean up dist
file: path=/var/www/pepyatka-html/dist state=absent
when: pepyatka_html.before != pepyatka_html.after
tags:
- pepyatka
- nginx

- name: Compile css
command: chdir=/var/www/pepyatka-html jake themes
tags:
- pepyatka
- nginx

- name: Compile js
command: chdir=/var/www/pepyatka-html jake compile
tags:
- pepyatka
- nginx

- name: Copy main.js
command: cp /var/www/pepyatka-html/dist/main.js /var/www/pepyatka-html/public/js/main.js
tags:
- pepyatka
- nginx

- name: Copy config.js
command: cp /var/www/pepyatka-html/dist/config.js /var/www/pepyatka-html/public/js/config.js
tags:
- pepyatka
- nginx

- name: Fix pepyatka-html permissions
file:
path: /var/www/pepyatka-html
owner: "{{ www_user }}"
group: "{{ www_group }}"
state: directory
recurse: yes
tags:
- pepyatka
- nginx

Loading

0 comments on commit c8c74a0

Please sign in to comment.