-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.yml
83 lines (68 loc) · 2.54 KB
/
main.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
# ROLE: first_deploy
# roles/first_deploy/tasks/main.yml
#
# Runs the first Capistrano managed deployment
# Usage:
# - { role: first_deploy, project_name: *required* }
#
# Does a minimal install of a codebase from development mode to bootstrap a capistrano deployment
# The codebase being deployed must be capified and have a config/deploy/localhost.rb stage file
- name: generate rails secret
command: openssl rand -hex 64
register: rails_secret
- name: create shared config files
become: yes
template: src={{ item }}.j2 dest=/opt/{{ project_name }}/shared/config/{{ item }} owner=deploy group=deploy backup=no
with_items:
- database.yml
- secrets.yml
- name: clone repo
git:
repo: https://github.com/curationexperts/{{ project_name }}.git
dest: /home/{{ ansible_ssh_user }}/{{ project_name }}
- name: install gems (bundle install)
shell: bundle install
args:
chdir: /home/{{ ansible_ssh_user }}/{{ project_name }}
- name: create deployment keypair for connection user
# Set up a keypair so the ansible user can connect as the capistrano deploy user
user:
name: "{{ ansible_ssh_user }}"
generate_ssh_key: yes
ssh_key_file: .ssh/id_rsa
- name: read public key
slurp:
src: /home/{{ ansible_ssh_user }}/.ssh/id_rsa.pub
register: public_key
- name: add public key to deploy user
become: yes
authorized_key:
user: deploy
key: "{{ public_key.content | b64decode }}"
- name: create apache vhosts file
become: yes
template: src=apache_vhost.j2 dest=/etc/apache2/sites-enabled/{{ project_name }}.conf owner=root group=root backup=no
- name: restart apache
become: true
service: name=apache2 state=restarted
- name: deploy to production directories with capistrano
shell: cap localhost deploy
args:
chdir: /home/{{ ansible_ssh_user }}/{{ project_name }}
- name: symlink schema from code to solr
become: yes
file: src=/opt/{{ project_name }}/current/solr/config/schema.xml dest=/var/solr/data/{{ project_name }}/conf/schema.xml state=link force=yes
- name: symlink solrconfig from code to solr
become: yes
file: src=/opt/{{ project_name }}/current/solr/config/solrconfig.xml dest=/var/solr/data/{{ project_name }}/conf/solrconfig.xml state=link force=yes
- name: restart solr
become: true
service: name=solr state=restarted
- name: restart apache
become: true
service: name=apache2 state=restarted
- name: ensure default admin set with capistrano
shell: cap localhost hyrax:ensure_default_admin_set
args:
chdir: /home/{{ ansible_ssh_user }}/{{ project_name }}