Skip to content

Instantly share code, notes, and snippets.

@sescobb27
Forked from mokevnin/Dockerfile
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sescobb27/7dc958c2a58d9edb2ef3 to your computer and use it in GitHub Desktop.
Save sescobb27/7dc958c2a58d9edb2ef3 to your computer and use it in GitHub Desktop.
- hosts: localhost
gather_facts: no
tasks:
- local_action:
module: slack
domain: hexlet.slack.com
token: {{ slack_token }}
msg: "deploy started: {{ rails_env }}:{{ hexlet_image_tag }}"
channel: "#operation"
username: "{{ ansible_ssh_user }}"
- hosts: appservers
gather_facts: no
tasks:
- shell: docker pull hexlet/hexlet-{{ rails_env }}:{{ hexlet_image_tag }}
become: yes
become_user: '{{ run_user }}'
- name: update hexlet version
become: yes
lineinfile:
regexp: "HEXLET_VERSION"
line: "HEXLET_VERSION={{ hexlet_image_tag }}"
dest: /etc/environment
backup: yes
state: present
- hosts: jobservers
gather_facts: no
tasks:
- become: yes
become_user: '{{ run_user }}'
run_once: yes
delegate_to: '{{ migration_server }}'
shell: >
docker run --rm
-e 'SECRET_KEY_BASE={{ secret_key_base }}'
-e 'DATABASE_URL={{ database_url }}'
-e 'RAILS_ENV={{ rails_env }}'
hexlet/hexlet-{{ rails_env }}:{{ hexlet_image_tag }}
rake db:migrate
- hosts: webservers
gather_facts: no
tasks:
- service: name=nginx state=running
become: yes
tags: nginx
- service: name=unicorn state=restarted
become: yes
tags: [unicorn, app]
- hosts: jobservers
gather_facts: no
tasks:
- service: name=activejob state=restarted
become: yes
tags: [activejob, app]
- hosts: localhost
gather_facts: no
tasks:
- name: "Send deploy hook to honeybadger"
local_action: shell cd .. && bundle exec honeybadger deploy --environment={{ rails_env }}
- local_action:
module: slack
domain: hexlet.slack.com
token: {{ slack_token }}
msg: "deploy completed ({{ rails_env }})"
channel: "#operation"
username: "{{ ansible_ssh_user }}"
# link_names: 0
# parse: 'none'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment