-
Notifications
You must be signed in to change notification settings - Fork 154
/
deploy.yml
54 lines (47 loc) · 1.57 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
- hosts: all
vars:
rbenv_root_path: /home/{{ ansible_user_id }}/.rbenv
rbenv_shims_path: "{{ rbenv_root_path }}/shims"
repo_url:
repo_name:
repo_key_path:
tasks:
- name: Copy custom git ssh key to /tmp/private_key (if provided)
when: repo_key_path is not none
copy:
src: "{{ repo_key_path }}"
dest: /tmp/private_key
mode: 0600
- name: Clone/pull project repo to ~/{{ repo_name }} user directory (using ssh-agent forwarding or https)
when: repo_key_path is none
git:
repo: "{{ repo_url }}"
dest: "~/{{ repo_name }}"
force: true
accept_hostkey: true
- name: Clone/pull project repo to ~/{{ repo_name }} user directory (using custom git ssh key)
when: repo_key_path is not none
git:
repo: "{{ repo_url }}"
dest: "~/{{ repo_name }}"
force: true
accept_hostkey: true
key_file: /tmp/private_key
- name: Delete custom git ssh key from /tmp/private_key (if provided)
when: repo_key_path is not none
file:
state: absent
path: /tmp/private_key
- name: Run bundle install
command: bundle install
args:
chdir: ~/{{ repo_name }}
environment:
PATH: "{{ rbenv_root_path }}/bin:{{ rbenv_root_path }}/shims:{{ ansible_env.PATH }}"
- name: Run whenever to update crontab
command: whenever --update-crontab
args:
chdir: ~/{{ repo_name }}
environment:
PATH: "{{ rbenv_root_path }}/bin:{{ rbenv_root_path }}/shims:{{ ansible_env.PATH }}"