Revert Supervisor-driven service management for core services.

This commit is contained in:
Buster Silver 2017-06-07 09:49:39 -05:00
parent c8bc27a7ef
commit dff432e774
15 changed files with 28 additions and 133 deletions

View File

@ -25,6 +25,7 @@
- mariadb
- ufw
- composer
- services
- azuracast-db
- { role: azuracast-cron, when: testing_mode == false }
- { role: azuracast-build, when: testing_mode == false and app_env == 'development' }

View File

@ -1,5 +0,0 @@
---
- name: restart influxdb
supervisorctl:
name: 'core:influxdb'
state: restarted

View File

@ -22,21 +22,15 @@
with_items:
- influxdb
- name: Disable service initialization for influxdb
- name: Restart InfluxDB
become: true
service: name=influxdb enabled=no state=stopped
service: name=influxdb enabled=yes state=restarted
ignore_errors: true
- name: restart influxdb
supervisorctl:
name: 'core:influxdb'
state: restarted
- name: Pause to allow InfluxDB to spin up
pause: seconds=15
when: influx_installed.changed
#- name: Pause to allow InfluxDB to spin up
# pause: seconds=15
# when: influx_installed.changed
- name: Create 'stations' database
influxdb_database:
hostname: "localhost"

View File

@ -1,9 +1,4 @@
---
- name: restart mysql
supervisorctl:
name: 'core:mysql'
state: restarted
- name: send mysql notification
debug:
msg: "The MySQL 'azuracast'@'localhost' account has been created. Its password is: {{ mysql_user_password }}"

View File

@ -34,27 +34,14 @@
- name: Add configuration
template: src=my.cnf.j2 dest=/etc/mysql/conf.d/my.cnf owner=root group=root mode=0644
notify: restart mysql
- name: Disable service initialization for mariadb
become: true
service: name=mysql enabled=no state=stopped
ignore_errors: true
- name: Restart MySQL
supervisorctl:
name: 'core:mysql'
state: restarted
- name: Start and enable service
service: name=mysql state=started enabled=yes
- name: Add empty root .my.cnf (if none exists)
become: true
template: src=root_empty_my.cnf.j2 dest=/root/.my.cnf owner=root group=root mode=0600
# - name: MySQL Root Account Fix (Ubuntu 16.04)
# become: true
# shell: "cat {{ util_base }}/xenial_mysql_fix.sql | mysql --defaults-extra-file=/root/.my.cnf -NB"
# when: ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'xenial'
- name: Remove anonymous users
command: 'mysql --defaults-extra-file=/root/.my.cnf -ne "{{ item }}"'
with_items:
@ -85,12 +72,6 @@
state: present
notify: send mysql notification
#- name: Reload privilege tables
# command: 'mysql -ne "{{ item }}"'
# with_items:
# - "FLUSH PRIVILEGES"
# changed_when: False
- name: Add .my.cnf
become: true
template: src=user_my.cnf.j2 dest="{{ app_base }}/.my.cnf" owner=azuracast group=www-data mode=0644 force=yes

View File

@ -1,5 +0,0 @@
---
- name: restart nginx
supervisorctl:
name: 'core:nginx'
state: restarted

View File

@ -12,7 +12,6 @@
command: openssl req -new -nodes -x509 -subj "/C=US/ST=Texas/L=Austin/O=IT/CN=${ansible_fqdn}" -days 3650 -keyout /etc/nginx/ssl/server.key -out /etc/nginx/ssl/server.crt -extensions v3_ca
args:
creates: /etc/nginx/ssl/server.crt
notify: restart nginx
- name: Remove default nginx site symlink
become: true
@ -23,7 +22,6 @@
- name: Add app-specific nginx site
become: true
template: src=default.j2 dest=/etc/nginx/sites-available/00-azuracast
notify: restart nginx
- name: Link app-specific nginx site
become: true
@ -38,10 +36,4 @@
dest: /etc/nginx/nginx.conf
regexp: 'sendfile on;'
replace: 'sendfile off;'
when: app_env == "development"
- name: Disable service initialization for nginx
become: true
service: name=nginx enabled=no state=stopped
ignore_errors: true
notify: restart nginx
when: app_env == "development"

View File

@ -1,5 +0,0 @@
---
- name: restart php-fpm
supervisorctl:
name: 'core:php7-fpm'
state: restarted

View File

@ -66,7 +66,6 @@
- name: Configure PHP FPM Pool
template: src=fpmpool.j2 dest=/etc/php/7.1/fpm/pool.d/www.conf force=true
notify: restart php-fpm
- name: Configure php-fpm php.ini
ini_file:
@ -78,7 +77,6 @@
- { option: 'post_max_size', value: "50M" }
- { option: 'short_open_tag', value: "On" }
- { option: 'upload_max_filesize', value: "25M" }
notify: restart php-fpm
- name: Configure php-cli php.ini
ini_file:
@ -87,9 +85,4 @@
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- { option: 'short_open_tag', value: "On" }
- name: Disable service initialization for php-fpm
become: true
service: name=php7.1-fpm enabled=no state=stopped
ignore_errors: true
- { option: 'short_open_tag', value: "On" }

View File

@ -1,25 +0,0 @@
---
- name: Add key for ppa python repository
apt_key: keyserver=keyserver.ubuntu.com id=DB82666C state=present
become: yes
- name: Add ppa python repository
apt_repository: repo='deb http://ppa.launchpad.net/fkrull/deadsnakes-python2.7/ubuntu {{ ansible_distribution_release }} main' state=present update_cache=yes
become: yes
register: python_ppa_added
- name: Update apt
become: true
apt: update_cache=yes
when: python_ppa_added.changed
- name: Ensure python2.7 latest is installed
apt:
pkg: python2.7
state: latest
install_recommends: no
become: yes
register: python_latest_installed
- fail: msg="Python was just upgraded on this system. Run ./install.sh again to continue."
when: python_latest_installed.changed

View File

@ -0,0 +1,12 @@
---
- name: Enable and restart all core services
service:
name: "{{ item }}"
enabled: yes
state: restarted
with_items:
- "influxdb"
- "mysql"
- "php7.1-fpm"
- "nginx"
- "supervisor"

View File

@ -1,3 +0,0 @@
---
- name: restart supervisord
service: name=supervisor enabled=yes state=restarted

View File

@ -9,14 +9,16 @@
template: src=supervisord.conf.j2 dest=/etc/supervisor/supervisord.conf force=yes
register: supervisord_conf
- name: Add core supervisord configuration
- name: Remove old core supervisord configuration
become: true
template: src=core.conf.j2 dest=/etc/supervisor/conf.d/core.conf force=yes
file:
path: /etc/supervisor/conf.d/core.conf
state: absent
register: supervisord_core
- name: Kill legacy radio processes (if upgrading from older version)
become: true
command: killall -9 icecast2 sc_serv liquidsoap
command: killall -q -9 icecast2 sc_serv liquidsoap
ignore_errors: True
when: supervisord_install.changed

View File

@ -1,31 +0,0 @@
[group:core]
programs=php7-fpm,mysql,nginx,influxdb
[program:php7-fpm]
command=/usr/sbin/php-fpm7.1 -F --fpm-config /etc/php/7.1/fpm/php-fpm.conf -c /etc/php/7.1/fpm/
autostart=true
autorestart=true
priority=5
[program:mysql]
command=/usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306
autostart=true
autorestart=true
stdout_events_enabled=true
stderr_events_enabled=true
[program:nginx]
command=/usr/sbin/nginx -g 'daemon off;'
autostart=true
autorestart=true
priority=10
stdout_events_enabled=true
stderr_events_enabled=true
[program:influxdb]
command=/usr/bin/influxd -config /etc/influxdb/influxdb.conf
autostart=true
autorestart=true
priority=10
stdout_events_enabled=true
stderr_events_enabled=true

View File

@ -14,12 +14,11 @@
- init
- azuracast-config
- { role: azuracast-radio, when: update_revision|int < 8 }
- { role: supervisord, when: update_revision|int < 13 }
- { role: nginx, when: update_revision|int < 10 }
- { role: php, when: update_revision|int < 10 }
- { role: supervisord, when: update_revision|int < 11 }
- { role: influxdb, when: update_revision|int < 10 }
- { role: ufw, when: update_revision|int < 12 }
- { role: services, when: update_revision|int < 13 }
- { role: azuracast-cron, when: update_revision|int < 2 }
- azuracast-update