Fixes to allow services startup after reboot

This change introduces small fixes required for system services
to start up after reboot of server.

Change-Id: I038b16c330422c8aa703c4dd0736920f979a10ed
This commit is contained in:
Andrey Shestakov 2016-12-23 16:16:10 +02:00
parent e490f27ada
commit e56a4ac690
6 changed files with 28 additions and 31 deletions

View File

@ -35,7 +35,7 @@
# NOTE(sean-k-mooney) only the RabbitMQ server and MySQL db are started
# during bootstrapping. all other services are started in the Start phase.
- name: "Start database service"
service: name={{ mysql_service_name }} state=started
service: name={{ mysql_service_name }} state=started enabled=yes
- name: "RabbitMQ - Testing if hostname is defined in /etc/hosts"
command: grep -i "{{ ansible_hostname }}" /etc/hosts
ignore_errors: yes
@ -56,7 +56,7 @@
- epmd
when: ansible_os_family == 'Suse'
- name: "Start rabbitmq-server"
service: name=rabbitmq-server state=started
service: name=rabbitmq-server state=started enabled=yes
# NOTE(cinerama): on some systems, rabbit may not be ready when we want to
# make changes to users if we don't wait first
- name: "Wait for rabbitmq"

View File

@ -17,3 +17,4 @@
service:
name=ironic-inspector
state=restarted
enabled=yes

View File

@ -18,20 +18,20 @@
when: init_template == 'systemd_template.j2'
- name: "Start database service"
service: name={{ mysql_service_name }} state=started
service: name={{ mysql_service_name }} state=started enabled=yes
- name: "Start rabbitmq-server"
service: name=rabbitmq-server state=started
service: name=rabbitmq-server state=started enabled=yes
- name: "start ironic-inspector"
include: inspector_start.yml
when: enable_inspector | bool == true
- name: "Start ironic-conductor"
service: name=ironic-conductor state=started
service: name=ironic-conductor state=started enabled=yes
- name: "Start ironic-api"
service: name=ironic-api state=started
service: name=ironic-api state=started enabled=yes
- name: "Start ironic-conductor"
service: name=ironic-conductor state=restarted
@ -47,13 +47,13 @@
when: "{{ testing | bool == true and include_dhcp_server | bool == true }}"
- name: "Ensure services are running with current config"
service: name={{ item }} state=restarted
service: name={{ item }} state=restarted enabled=yes
with_items:
- xinetd
- nginx
- name: "Ensure dnsmasq is running with current config"
service: name={{ item }} state=restarted
service: name={{ item }} state=restarted enabled=yes
with_items:
- dnsmasq
when: "{{ include_dhcp_server | bool == true }}"

View File

@ -31,10 +31,10 @@
# NOTE(sean-k-mooney) only the RabbitMQ server and MySQL db are started
# during bootstrapping. all other services are started in the Start phase.
- name: "Start database service"
service: name={{ mysql_service_name }} state=started
service: name={{ mysql_service_name }} state=started enabled=yes
- name: "Start rabbitmq-server"
service: name=rabbitmq-server state=started
service: name=rabbitmq-server state=started enabled=yes
# NOTE(cinerama): on some systems, rabbit may not be ready when we want to
# make changes to users if we don't wait first
@ -208,14 +208,6 @@
group: "{{ nginx_user }}" # TODO(TheJulia): Split webserver user/group.
mode: 0755
- name: "Ensure /run/uwsgi exists"
file:
name: "/run/uwsgi"
state: directory
owner: "{{ nginx_user }}"
group: "{{ nginx_user }}" # TODO(TheJulia): Split webserver user/group.
mode: 0775
- name: "Place keystone public uwsgi config"
template:
src: keystone-public.ini.j2
@ -271,4 +263,13 @@
owner: "root"
group: "root"
with_items:
- { service_path: "{{ uwsgi_install_prefix.stdout | default('') }}", service_name: 'uwsgi', username: "{{nginx_user}}", args: '--master --emperor /etc/uwsgi/apps-enabled'}
- { service_path: "{{ uwsgi_install_prefix.stdout | default('') }}",
service_name: 'uwsgi',
username: "{{ nginx_user }}",
exec_start_pre: "/usr/bin/install -m 755 -o {{ nginx_user }} -g {{ nginx_user }} -d /run/uwsgi",
args: '--master --emperor /etc/uwsgi/apps-enabled'}
# NOTE(ashestakov) https://github.com/ansible/ansible-modules-core/issues/3764
- name: "Remove uwsgi sysvinit init script"
command: update-rc.d -f uwsgi remove
ignore_errors: yes

View File

@ -15,18 +15,8 @@
command: systemctl daemon-reload
when: init_template == 'systemd_template.j2'
- name: "Ensure required services are started"
service: name={{ item }} state=started
- name: "Ensure services are running with current config"
service: name={{ item }} state=restarted enabled=yes
with_items:
- nginx
- uwsgi
# In the event that this server was already running,
# we need to HUP the service to help ensure that it
# has the latest configuration. We do this because we
# cannot trust what service returns as each init system
# behaves differently.
- name: "Send services a reload signal"
service: name={{ item }} state=reloaded
with_items:
- nginx

View File

@ -2,6 +2,11 @@
Description={{ item.service_name }} service
[Service]
Restart=on-failure
PermissionsStartOnly=true
{% if item.exec_start_pre %}
ExecStartPre={{ item.exec_start_pre }}
{% endif %}
ExecStart={{ item.service_path }}/{{ item.service_name }} {{ item.args }}
User={{ item.username }}