Skip to content

Instantly share code, notes, and snippets.

@bibliotechy
Created June 8, 2016 14:35
Show Gist options
  • Save bibliotechy/9efaf241a137a10807378fa9f957e501 to your computer and use it in GitHub Desktop.
Save bibliotechy/9efaf241a137a10807378fa9f957e501 to your computer and use it in GitHub Desktop.
Two options for how to do this - in the playbook, or in a local_action. Either way, the downloads directory needs to already exist in your playbook
---
# Complete Vivo server
- hosts: all
become: yes
roles:
- geerlingguy.mysql
- hosts: all
become: yes
roles:
- geerlingguy.apache
- hosts: all
become: yes
roles:
- williamyeh.oracle-java
- hosts: all
become: yes
environment:
- CATALINA_BASE: "/usr/share/tomcat"
- NAME: "tomcat"
roles:
- bertvv.tomcat
## USE A PLAY THAT JUST ACTS LOCALLY
- name: download the vivo src locally for resuse
hosts: 127.0.0.1
connection: local
tasks:
- name: download vivo source to the local download directory
get_url:
url: https://github.com/vivo-project/VIVO/releases/download/{{ vivo_version }}/vivo-{{ vivo_version }}.zip
dest: downloads/{{ vivo_version }}/vivo-{{ vivo_version }}.zip
- hosts: all
become: yes
environment:
- CATALINA_BASE: "/usr/share/tomcat"
- NAME: "tomcat"
tasks:
- user: name={{app_user}} state=present
become: yes
- include: tasks/devtools.yml
- include: tasks/ant.yml
- include: tasks/apache2.yml
- include: tasks/vivo.yml
## USE A LOCAL ACTION WITHOUT BECOME SINCE YOU ALREADY OWN THIS DIRECTORY
- name: download vivo source to the local download directory
local_action:
get_url:
url: https://github.com/vivo-project/VIVO/releases/download/{{ vivo_version }}/vivo-{{ vivo_version }}.zip
dest: downloads/{{ vivo_version }}/vivo-{{ vivo_version }}.zip
become: no
- name: checkout the vivo app code from source control
unarchive:
src: files/vivo-{{ vivo_version }}.zip
dest: /opt
copy: yes
owner: tomcat
group: tomcat
- name: Create Vivo build properties
command: cp "example.build.properties" "build.properties"
args:
chdir: "{{ vivo_build_path }}"
become_user: tomcat
- name: Configure Vivo build properties
lineinfile:
dest: "/opt/vivo-{{ vivo_version }}/build.properties"
regexp: "tomcat.home = /usr/local/tomcat"
line: "tomcat.home = {{ tomcat_home_path }}"
- name: Build Vivo
command: ant all
args:
chdir: "/opt/vivo-{{ vivo_version }}"
- name: Change Vivo Owner and Group
file:
path: "{{ vivo_home_path }}"
recurse: yes
owner: tomcat
group: tomcat
- command: cp example.runtime.properties runtime.properties
args:
chdir: "{{ vivo_home_path }}"
become_user: tomcat
- name: Set SMTP Server
replace:
dest: "{{ vivo_home_path }}/runtime.properties"
regexp: "smtp.mydomain.edu"
replace: "{{ smtp_server }}"
- name: Customize Vigro DB Username
replace:
dest: "{{ vivo_home_path }}/runtime.properties"
regexp: "vitrodbUsername"
replace: "{{ vitro_db_username }}"
- name: Set Vitro DB Password
replace:
dest: "{{ vivo_home_path }}/runtime.properties"
regexp: "vitrodbPassword"
replace: "{{ vitro_db_password }}"
- name: Set Vigro Domain Name
replace:
dest: "{{ vivo_home_path }}/runtime.properties"
regexp: "mydomain.edu"
replace: "{{ vivo_domain }}"
- name: Create application setup file
command: cp config/example.applicationSetup.n3 config/applicationSetup.n3
args:
chdir: "{{ vivo_home_path }}"
become_user: tomcat
- name: Create developer properties file
command: cp config/example.developer.properties config/developer.properties
args:
chdir: "{{ vivo_home_path }}"
become_user: tomcat
- name: Start up Tomcat
command: tomcat start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment