-
-
Save rgordeev/32c6308d2392b07437b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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