# Alternate example demonstrating variable overrides by installing a
# specific OpenSRF branch.
-# sudo ansible-playbook playbook.yml --extra-vars "osrf_git_branch=rel_2_5"
+# sudo ansible-playbook playbook.yml -e osrf_git_branch=rel_2_5
# Install with the sample locales defined in translations.yml
-# sudo ansible-playbook playbook.yml --extra-vars "translations=true"
+# sudo ansible-playbook playbook.yml -e translations=true
# Install with a different deployment user (named 'deploy') on a remote machine
# sudo ansible-playbook playbook.yml -e hosts=other.example.org -e deploy_user=deploy
=== extras
-Optional packages not strictly required for OpenSRF and Evergreen.
+Optional packages and configuration not strictly required for OpenSRF
+and Evergreen.
# Apache
-- name: Stop apache2
+- name: Stop Apache2
become: true
service: name=apache2 state=stopped
+- name: Stop Apache2 Websockets
+ become: true
+# TODO: Use ansible 2.2 service: use=systemd
+ shell: systemctl stop apache2-websockets
- name: Setup eg.conf
become: true
copy:
dest: /etc/apache2/apache2.conf
regexp: 'KeepAliveTimeout .*'
replace: 'KeepAliveTimeout 1'
-- name: Restarting Apache
- become: true
- service: name=apache2 state=started
-- name: Restarting Websockets
- become: true
-# service name=apache2ctl-websockets state=restarted FAILS
-# ansible 2.2 supports a use=systemd flag that would likley resolve
-# this, since this works: systemctl restart apache2-websockets
- shell: apache2ctl-websockets restart
-
+# Leave Apache's stopped until Evergreen services are started.
- name: Install Nginx
include: nginx.yml
when: use_nginx
+- name: Install Service Files
+ include: services.yml
+ when: use_service_files
- name: Starting Services
include: start.yml
when: start_services
--- /dev/null
+[Unit]
+Description=Evergreen Reporter
+After=opensrf.service
+BindsTo=opensrf.service
+
+[Service]
+User=opensrf
+Group=opensrf
+Type=forking
+Environment=PATH=/openils/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+#ExecStartPre=/bin/sleep 2
+
+# TODO: -c template variable
+ExecStart=/openils/bin/clark-kent.pl --daemon
+ExecStopPost=/bin/rm /tmp/reporter-LOCK
+
+#[Install]
+#WantedBy=multi-user.target
--- /dev/null
+# TODO: 'Before' and 'After' reflect a single-server setup.
+# Make these configurable for cases where certain services
+# (e.g. memcache) are not run on the same machine.
+
+[Unit]
+Description=Open Service Request Framework
+After=ejabberd.service memcached.service
+Before=apache2.service apache2-websockets.service
+Requries=memcached.service
+BindsTo=ejabberd.service
+
+[Service]
+User=opensrf
+Group=opensrf
+Type=oneshot
+RemainAfterExit=yes
+Environment=PATH=/openils/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+Environment=LD_LIBRARY_PATH=/openils/lib:/usr/local/lib:/usr/local/lib/dbd:$LD_LIBRARY_PATH
+#ExecStartPre=/bin/sleep 5
+ExecStart=/openils/bin/osrf_control -l --start-all
+#ExecStartPost=/bin/sleep 10
+#ExecStartPost=-/bin/systemctl restart apache2.service
+#ExecStartPost=-/bin/systemctl restart apache2-websockets.service
+ExecStop=/openils/bin/osrf_control -l --stop-all
+
+#[Install]
+#WantedBy=multi-user.target
+#Alias=opensrf.service
+
--- /dev/null
+- name: Install OpenSRF Service File
+ become: true
+ template:
+ src: extras/service-files/opensrf.service.j2
+ dest: /lib/systemd/system/opensrf.service
+ owner: root
+ group: root
+ mode: 0644
+- name: Install Evergreen Reporter Service File
+ become: true
+ template:
+ src: extras/service-files/evergreen-reporter.service.j2
+ dest: /lib/systemd/system/evergreen-reporter.service
+ owner: root
+ group: root
+ mode: 0644
+- name: Reload Systemd Configs
+ become: true
+ shell: systemctl daemon-reload
environment:
PATH: "{{ansible_env.PATH}}:{{eg_install_path}}/bin"
shell: osrf_control --localhost --restart-all
+ when: not use_service_files
+- name: Starting Services (systemd)
+ become: true
+# NOTE: ansible 2.2 adds a service: use=systemd flag
+ shell: systemctl restart opensrf.service
+ when: use_service_files
- name: Giving Services Time To Start...
pause: seconds=10
- name: Running Autogen
environment:
PATH: "{{ansible_env.PATH}}:{{eg_install_path}}/bin"
shell: autogen.sh
-- name: Reloading Apache
+- name: Restarting Apache
+ become: true
+ service: name=apache2 state=restarted
+- name: Restarting Websockets
become: true
- service: name=apache2 state=reloaded
+# service name=apache2ctl-websockets state=restarted FAILS
+# ansible 2.2 supports a use=systemd flag that would likley resolve
+# this, since this works: systemctl restart apache2-websockets
+ shell: systemctl restart apache2-websockets
+
remote_src: true
src: "{{repo_base}}/OpenSRF/examples/apache_24/websockets/apache2.conf"
dest: /etc/apache2-websockets/apache2.conf
+ - name: Reload Systemd Configs
+ become: true
+ shell: systemctl daemon-reload
when: websocketsconf.stat.isdir is not defined
# NOTE: restarting websockets here fails because the SSL cert is not yet in place
# Install and configure NGINX proxy
use_nginx: true
+# Install systemd service files and use them to stop/start services.
+# Disabled by default since EG documentation generally refers to
+# the osrf_control script instead.
+use_service_files: false
+
# Start Evergreen services when the install is complete.
start_services: true