Created
February 7, 2016 07:10
-
-
Save daisuke-morita/ecebc7f6da183f5d93a9 to your computer and use it in GitHub Desktop.
Phoenixアプリサーバーのプロビジョニング - ansible/roles/app/tasks/main.yml
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
--- | |
- 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