From 98aba34aa1e00ca04eb8a1ca17c20dd4bc1f4ca5 Mon Sep 17 00:00:00 2001 From: Andy McCrae Date: Tue, 3 Mar 2015 11:50:01 +0000 Subject: [PATCH] Handler should only restart relevent swift services * Adjust the handler to include a "restart" handler for each of account, container, object and proxy service groups. * Add a variable in defaults listing program names for each swift service group. * Remove the over-arching "all swift program_names" variable. * Change the storage and proxy host tasks to call the appropriate * handler. Change-Id: I25adfa152fc7a3da83ca7c12d57977eec8b51d7b Closes-Bug: #1427601 --- playbooks/roles/os_swift/defaults/main.yml | 29 +++++++++-------- playbooks/roles/os_swift/handlers/main.yml | 31 +++++++++++++++++-- .../os_swift/tasks/swift_post_install.yml | 6 +++- .../os_swift/tasks/swift_proxy_hosts.yml | 2 +- .../tasks/swift_storage_hosts_account.yml | 4 +-- .../tasks/swift_storage_hosts_container.yml | 4 +-- .../swift_storage_hosts_object_server.yml | 4 +-- .../tasks/swift_upstart_common_init.yml | 10 +++--- 8 files changed, 61 insertions(+), 29 deletions(-) diff --git a/playbooks/roles/os_swift/defaults/main.yml b/playbooks/roles/os_swift/defaults/main.yml index 93e9ea8ebf..6c0b0a7a4c 100644 --- a/playbooks/roles/os_swift/defaults/main.yml +++ b/playbooks/roles/os_swift/defaults/main.yml @@ -127,21 +127,24 @@ swift_apt_packages: - python-dev - rsync -swift_program_names: - - swift-proxy-server - - swift-object-server - - swift-object-auditor - - swift-object-replicator - - swift-object-updater - - swift-object-server-replicator +swift_account_program_names: + - swift-account-server + - swift-account-auditor + - swift-account-replicator + - swift-account-reaper + +swift_container_program_names: - swift-container-server - swift-container-auditor - swift-container-replicator - swift-container-sync - swift-container-updater - - swift-container-server-replicator - - swift-account-server - - swift-account-auditor - - swift-account-replicator - - swift-account-reaper - - swift-account-server-replicator + +swift_object_program_names: + - swift-object-server + - swift-object-auditor + - swift-object-replicator + - swift-object-updater + +swift_proxy_program_names: + - swift-proxy-server diff --git a/playbooks/roles/os_swift/handlers/main.yml b/playbooks/roles/os_swift/handlers/main.yml index 30b7dea95f..97b662392a 100644 --- a/playbooks/roles/os_swift/handlers/main.yml +++ b/playbooks/roles/os_swift/handlers/main.yml @@ -13,13 +13,40 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Restart swift services +- name: Restart swift account services service: name: "{{ item }}" state: "restarted" pattern: "{{ item }}" register: service_restart - with_items: swift_program_names + with_items: swift_account_program_names + failed_when: false + +- name: Restart swift container services + service: + name: "{{ item }}" + state: "restarted" + pattern: "{{ item }}" + register: service_restart + with_items: swift_container_program_names + failed_when: false + +- name: Restart swift object services + service: + name: "{{ item }}" + state: "restarted" + pattern: "{{ item }}" + register: service_restart + with_items: swift_object_program_names + failed_when: false + +- name: Restart swift proxy services + service: + name: "{{ item }}" + state: "restarted" + pattern: "{{ item }}" + register: service_restart + with_items: swift_proxy_program_names failed_when: false - name: Restart service diff --git a/playbooks/roles/os_swift/tasks/swift_post_install.yml b/playbooks/roles/os_swift/tasks/swift_post_install.yml index e940d83d60..fc417c2930 100644 --- a/playbooks/roles/os_swift/tasks/swift_post_install.yml +++ b/playbooks/roles/os_swift/tasks/swift_post_install.yml @@ -23,7 +23,11 @@ - { src: "swift.conf.j2", dest: "/etc/swift/swift.conf" } - { src: "swift-rsyslog.conf.j2", dest: "/etc/rsyslog.d/49-swift.conf" } - { src: "swift-dispersion.conf.j2", dest: "/etc/swift/dispersion.conf" } - notify: Restart swift services + notify: + - Restart swift account services + - Restart swift container services + - Restart swift object services + - Restart swift proxy services tags: - swift-config - swift-post-install diff --git a/playbooks/roles/os_swift/tasks/swift_proxy_hosts.yml b/playbooks/roles/os_swift/tasks/swift_proxy_hosts.yml index 053314442c..921138992f 100644 --- a/playbooks/roles/os_swift/tasks/swift_proxy_hosts.yml +++ b/playbooks/roles/os_swift/tasks/swift_proxy_hosts.yml @@ -28,4 +28,4 @@ dest: "/etc/swift/proxy-server/proxy-server.conf" owner: "{{ swift_system_user_name }}" mode: "0644" - notify: Restart swift services + notify: Restart swift proxy services diff --git a/playbooks/roles/os_swift/tasks/swift_storage_hosts_account.yml b/playbooks/roles/os_swift/tasks/swift_storage_hosts_account.yml index 760d0aa784..62898c7191 100644 --- a/playbooks/roles/os_swift/tasks/swift_storage_hosts_account.yml +++ b/playbooks/roles/os_swift/tasks/swift_storage_hosts_account.yml @@ -75,7 +75,7 @@ mode: "0644" with_items: - { src: "account-server.conf.j2", dest: "/etc/swift/account-server/account-server.conf" } - notify: Restart swift services + notify: Restart swift account services # We only create the dedicated replicator configuration when using a dedicated replication_network - name: "Swift account server replicator configuration" @@ -90,4 +90,4 @@ when: > swift.replication_network is defined and swift.replication_network != swift.storage_network - notify: Restart swift services + notify: Restart swift account services diff --git a/playbooks/roles/os_swift/tasks/swift_storage_hosts_container.yml b/playbooks/roles/os_swift/tasks/swift_storage_hosts_container.yml index 2a3c22e79a..fe8d04d611 100644 --- a/playbooks/roles/os_swift/tasks/swift_storage_hosts_container.yml +++ b/playbooks/roles/os_swift/tasks/swift_storage_hosts_container.yml @@ -84,7 +84,7 @@ mode: "0644" with_items: - { src: "container-server.conf.j2", dest: "/etc/swift/container-server/container-server.conf" } - notify: Restart swift services + notify: Restart swift container services # We only create the dedicated replicator configuration when using a dedicated replication_network - name: "Swift container server configuration" @@ -99,4 +99,4 @@ when: > swift.replication_network is defined and swift.replication_network != swift.storage_network - notify: Restart swift services + notify: Restart swift container services diff --git a/playbooks/roles/os_swift/tasks/swift_storage_hosts_object_server.yml b/playbooks/roles/os_swift/tasks/swift_storage_hosts_object_server.yml index 7f3e747e39..9aa8d36e04 100644 --- a/playbooks/roles/os_swift/tasks/swift_storage_hosts_object_server.yml +++ b/playbooks/roles/os_swift/tasks/swift_storage_hosts_object_server.yml @@ -75,7 +75,7 @@ mode: "0644" with_items: - { src: "object-server.conf.j2", dest: "/etc/swift/object-server/object-server.conf" } - notify: Restart swift services + notify: Restart swift object services # We only create the dedicated replicator configuration when using a dedicated replication_network - name: "Swift object server configuration" @@ -90,4 +90,4 @@ when: > swift.replication_network is defined and swift.replication_network != swift.storage_network - notify: Restart swift services + notify: Restart swift object services diff --git a/playbooks/roles/os_swift/tasks/swift_upstart_common_init.yml b/playbooks/roles/os_swift/tasks/swift_upstart_common_init.yml index 57969fbf19..209c4ac783 100644 --- a/playbooks/roles/os_swift/tasks/swift_upstart_common_init.yml +++ b/playbooks/roles/os_swift/tasks/swift_upstart_common_init.yml @@ -20,8 +20,7 @@ mode: "0644" owner: "root" group: "root" - notify: - - Restart swift services + register: init_script tags: - upstart-init - swift-init @@ -29,8 +28,7 @@ - name: Reload init scripts shell: | initctl reload-configuration - notify: - - Restart swift services + when: init_script|changed tags: - upstart-init - swift-init @@ -39,8 +37,8 @@ service: name: "{{ program_name }}" enabled: "yes" - notify: - - Restart swift services + state: restarted + when: init_script|changed tags: - upstart-init - swift-init