Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Phoenixアプリサーバーのプロビジョニング - ansible/roles/app/tasks/main.yml
---
- name: Download package
command: aws s3 cp "{{ package_url }}" /tmp/app.tar.gz
environment:
AWS_ACCESS_KEY_ID: "{{ lookup('env','AWS_ACCESS_KEY_ID') }}"
AWS_SECRET_ACCESS_KEY: "{{ lookup('env','AWS_SECRET_ACCESS_KEY') }}"
- name: Make app directory
file: state=directory path={{ item }}
with_items:
- "{{ app_home }}"
- "{{ app_home }}/log"
- name: Install app
unarchive: src=/tmp/app.tar.gz dest={{ app_home }}
- name: Put app config
template: src=app.conf dest={{ app_home }}/
- name: Ensure app directory belongs to ubuntu
file: "state=directory path={{ app_home }} owner=ubuntu group=ubuntu recurse=true"
- name: Symlink log directory
file: src={{ app_home }}/log path=/var/log/example_app state=link
- name: Put upstart config
template: src=example_app.conf dest=/etc/init/
- name: Start and enable services
service: name={{ item }} state=started enabled=yes
with_items:
- example_app
- nginx
- name: Wait for app to start
wait_for: port={{ app_port }} delay=10
- name: Ensure app is running
uri:
url: http://localhost:{{ app_port }}/api/public/version
status_code: 200
timeout: 600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment