Fix swift init scripts w/o dedicated replication

When not using dedicated replication systemd still puts init scripts
down, which take a long time to restart/start. upstart scripts get
around this by setting blank scripts.

Now that we are using a service dict we can do better by defining an
"service_en" flag and not setting up scripts when the service isn't
enabled.

Additionally, the systemd tempfiles and init files were not using the
appropriate "program_binary" variable at all, this has been fixed.

Change-Id: Iae569bfe38a440fb09e56658b3a934799a8821e8
This commit is contained in:
Andy McCrae 2016-10-14 17:16:31 +01:00
parent e4f7da4a38
commit 033aa502e5
7 changed files with 15 additions and 11 deletions

View File

@ -296,6 +296,7 @@ swift_services:
program_name: "swift-account-replicator-server"
program_binary: "swift-account-server"
program_config_options: "/etc/swift/account-server/account-server-replicator.conf"
service_en: "{{ swift_dedicated_replication | bool }}"
swift-account-server:
group: swift_acc
program_name: "swift-account-server"
@ -317,6 +318,7 @@ swift_services:
program_name: "swift-container-replicator-server"
program_binary: "swift-container-server"
program_config_options: "/etc/swift/container-server/container-server-replicator.conf"
service_en: "{{ swift_dedicated_replication | bool }}"
swift-container-server:
group: swift_cont
program_name: "swift-container-server"
@ -346,6 +348,7 @@ swift_services:
program_name: "swift-object-replicator-server"
program_binary: "swift-object-server"
program_config_options: "/etc/swift/object-server/object-server-replicator.conf"
service_en: "{{ swift_dedicated_replication | bool }}"
swift-object-server:
group: swift_obj
program_name: "swift-object-server"

View File

@ -30,7 +30,9 @@
state: "restarted"
pattern: "{{ item.value.program_name }}"
with_dict: "{{ swift_services }}"
when: inventory_hostname in groups[item.value.group]
when:
- inventory_hostname in groups[item.value.group]
- "{{ item.value.service_en | default(true) }}"
- name: Restart rsyslog
service:

View File

@ -26,6 +26,8 @@
name: "{{ item.value.program_name }}"
enabled: "yes"
with_dict: "{{ swift_services }}"
when: inventory_hostname in groups[item.value.group]
when:
- inventory_hostname in groups[item.value.group]
- "{{ item.value.service_en | default(true) }}"
notify:
- Restart swift services

View File

@ -19,4 +19,6 @@
state: "started"
pattern: "{{ item.value.program_name }}"
with_dict: "{{ swift_services }}"
when: inventory_hostname in groups[item.value.group]
when:
- inventory_hostname in groups[item.value.group]
- "{{ item.value.service_en | default(true) }}"

View File

@ -12,7 +12,7 @@ Group={{ swift_system_group_name }}
{% if item.value.program_override is defined %}
ExecStart={{ item.value.program_override }} {{ item.value.program_config_options|default('') }}
{% else %}
ExecStart={{ swift_bin }}/{{ item.value.program_name }} {{ item.value.program_config_options|default('') }}
ExecStart={{ swift_bin }}/{{ item.value.program_binary | default(item.value.program_name) }} {{ item.value.program_config_options|default('') }}
{% endif %}
# Give a reasonable amount of time for the server to start up/shut down

View File

@ -1,4 +1,4 @@
# {{ ansible_managed }}
D /var/lock/{{ item.value.program_name }} 2755 {{ swift_system_user_name }} {{ swift_system_group_name }}
D /var/run/{{ item.value.program_name }} 2755 {{ swift_system_user_name }} {{ swift_system_group_name }}
D /var/lock/{{ item.value.program_binary | default(item.value.program_name) }} 2755 {{ swift_system_user_name }} {{ swift_system_group_name }}
D /var/run/{{ item.value.program_binary | default(item.value.program_name) }} 2755 {{ swift_system_user_name }} {{ swift_system_group_name }}

View File

@ -1,8 +1,4 @@
# {{ ansible_managed }}
{% if not swift_dedicated_replication and 'replicator-server' in item.value.program_name %}
# Blank script - dedicated replication network not in use
{% else %}
description "{{ item.value.program_name }}"
author "Kevin Carter <kevin.carter@rackspace.com>"
@ -41,4 +37,3 @@ exec start-stop-daemon --start \
--make-pidfile \
--pidfile /var/run/{{ item.value.program_binary | default(item.value.program_name) }}/{{ item.value.program_name }}.pid \
--exec "{{ item.value.program_override|default('$RUNBIN') }}" "{{ item.value.program_config_options|default('') }}"
{% endif %}