Use dictionary for service group mappings
Change the 'cinder_service_names' from a list to a dictionary mapping of services, groups that install those services, and any additional conditions around their installations. The init tasks have been updated to run once and loop through this mapping rather than being included multiple times and re-run against each host. This may potentially reduce role run times. Common variables shared by each service's template files have also been updated to use the service namespaced variables. Change-Id: Ifeb890cc733921a6f882e4d9cdb778e22c82e9c5
This commit is contained in:
parent
a2212b7d1d
commit
c84f90a298
@ -248,10 +248,15 @@ cinder_pip_packages:
|
|||||||
|
|
||||||
# Service Names
|
# Service Names
|
||||||
cinder_service_names:
|
cinder_service_names:
|
||||||
- cinder-api
|
cinder-api:
|
||||||
- cinder-scheduler
|
group: cinder_api
|
||||||
- cinder-volume
|
cinder-scheduler:
|
||||||
- cinder-backup
|
group: cinder_scheduler
|
||||||
|
cinder-volume:
|
||||||
|
group: cinder_volume
|
||||||
|
cinder-backup:
|
||||||
|
group: cinder_backup
|
||||||
|
condition: "{{ cinder_service_backup_program_enabled | bool }}"
|
||||||
|
|
||||||
# This variable is used by the repo_build process to determine
|
# This variable is used by the repo_build process to determine
|
||||||
# which host group to check for members of before building the
|
# which host group to check for members of before building the
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
|
|
||||||
- name: Restart cinder services
|
- name: Restart cinder services
|
||||||
service:
|
service:
|
||||||
name: "{{ item }}"
|
name: "{{ item.key }}"
|
||||||
state: restarted
|
state: restarted
|
||||||
pattern: "{{ item }}"
|
pattern: "{{ item.key }}"
|
||||||
with_items: "{{ cinder_service_names }}"
|
with_dict: "{{ cinder_service_names }}"
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
- name: Ensure tgt service restarted
|
- name: Ensure tgt service restarted
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
---
|
|
||||||
# Copyright 2014-2016, Rackspace US, Inc.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
- include: cinder_init_common.yml
|
|
||||||
vars:
|
|
||||||
program_name: "{{ cinder_service_program_name }}"
|
|
||||||
service_name: "{{ cinder_service_name }}"
|
|
||||||
system_user: "{{ cinder_system_user_name }}"
|
|
||||||
system_group: "{{ cinder_system_group_name }}"
|
|
||||||
service_home: "{{ cinder_system_home_folder }}"
|
|
||||||
when: >
|
|
||||||
inventory_hostname in groups['cinder_api']
|
|
||||||
|
|
||||||
- include: cinder_init_common.yml
|
|
||||||
vars:
|
|
||||||
program_name: "{{ cinder_service_scheduler_program_name }}"
|
|
||||||
service_name: "{{ cinder_service_name }}"
|
|
||||||
system_user: "{{ cinder_system_user_name }}"
|
|
||||||
system_group: "{{ cinder_system_group_name }}"
|
|
||||||
service_home: "{{ cinder_system_home_folder }}"
|
|
||||||
when: >
|
|
||||||
inventory_hostname in groups['cinder_scheduler']
|
|
||||||
|
|
||||||
- include: cinder_init_common.yml
|
|
||||||
vars:
|
|
||||||
program_name: "{{ cinder_service_volume_program_name }}"
|
|
||||||
service_name: "{{ cinder_service_name }}"
|
|
||||||
system_user: "{{ cinder_system_user_name }}"
|
|
||||||
system_group: "{{ cinder_system_group_name }}"
|
|
||||||
service_home: "{{ cinder_system_home_folder }}"
|
|
||||||
when: >
|
|
||||||
inventory_hostname in groups['cinder_volume']
|
|
||||||
|
|
||||||
- include: cinder_init_common.yml
|
|
||||||
vars:
|
|
||||||
program_name: "{{ cinder_service_backup_program_name }}"
|
|
||||||
service_name: "{{ cinder_service_name }}"
|
|
||||||
system_user: "{{ cinder_system_user_name }}"
|
|
||||||
system_group: "{{ cinder_system_group_name }}"
|
|
||||||
service_home: "{{ cinder_system_home_folder }}"
|
|
||||||
when: >
|
|
||||||
inventory_hostname in groups['cinder_backup'] and
|
|
||||||
cinder_service_backup_program_enabled == true
|
|
@ -24,7 +24,11 @@
|
|||||||
|
|
||||||
- name: Load service
|
- name: Load service
|
||||||
service:
|
service:
|
||||||
name: "{{ program_name }}"
|
name: "{{ item.key }}"
|
||||||
enabled: "yes"
|
enabled: "yes"
|
||||||
|
with_dict: "{{ cinder_service_names }}"
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- "{{ item.value.condition | default(true) }}"
|
||||||
notify:
|
notify:
|
||||||
- Restart cinder services
|
- Restart cinder services
|
||||||
|
@ -16,19 +16,27 @@
|
|||||||
|
|
||||||
- name: Create TEMP run dir
|
- name: Create TEMP run dir
|
||||||
file:
|
file:
|
||||||
path: "/var/run/{{ program_name }}"
|
path: "/var/run/{{ item.key }}"
|
||||||
state: directory
|
state: directory
|
||||||
owner: "{{ system_user }}"
|
owner: "{{ cinder_system_user_name }}"
|
||||||
group: "{{ system_group }}"
|
group: "{{ cinder_system_group_name }}"
|
||||||
mode: "02755"
|
mode: "02755"
|
||||||
|
with_dict: "{{ cinder_service_names }}"
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- "{{ item.value.condition | default(true) }}"
|
||||||
|
|
||||||
- name: Create TEMP lock dir
|
- name: Create TEMP lock dir
|
||||||
file:
|
file:
|
||||||
path: "/var/lock/{{ program_name }}"
|
path: "/var/lock/{{ item.key }}"
|
||||||
state: directory
|
state: directory
|
||||||
owner: "{{ system_user }}"
|
owner: "{{ cinder_system_user_name }}"
|
||||||
group: "{{ system_group }}"
|
group: "{{ cinder_system_group_name }}"
|
||||||
mode: "02755"
|
mode: "02755"
|
||||||
|
with_dict: "{{ cinder_service_names }}"
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- "{{ item.value.condition | default(true) }}"
|
||||||
|
|
||||||
- name: Create tempfile.d entry
|
- name: Create tempfile.d entry
|
||||||
template:
|
template:
|
||||||
@ -37,15 +45,23 @@
|
|||||||
mode: "0644"
|
mode: "0644"
|
||||||
owner: "root"
|
owner: "root"
|
||||||
group: "root"
|
group: "root"
|
||||||
|
with_dict: "{{ cinder_service_names }}"
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- "{{ item.value.condition | default(true) }}"
|
||||||
|
|
||||||
- name: Place the systemd init script
|
- name: Place the systemd init script
|
||||||
template:
|
template:
|
||||||
src: "cinder-systemd-init.j2"
|
src: "cinder-systemd-init.j2"
|
||||||
dest: "/etc/systemd/system/{{ program_name }}.service"
|
dest: "/etc/systemd/system/{{ item.key }}.service"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
owner: "root"
|
owner: "root"
|
||||||
group: "root"
|
group: "root"
|
||||||
register: systemd_init
|
register: systemd_init
|
||||||
|
with_dict: "{{ cinder_service_names }}"
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- "{{ item.value.condition | default(true) }}"
|
||||||
|
|
||||||
- name: Reload the systemd daemon
|
- name: Reload the systemd daemon
|
||||||
command: "systemctl daemon-reload"
|
command: "systemctl daemon-reload"
|
||||||
|
@ -16,11 +16,15 @@
|
|||||||
- name: Place the init script
|
- name: Place the init script
|
||||||
template:
|
template:
|
||||||
src: "cinder-upstart-init.j2"
|
src: "cinder-upstart-init.j2"
|
||||||
dest: "/etc/init/{{ program_name }}.conf"
|
dest: "/etc/init/{{ item.key }}.conf"
|
||||||
mode: "0644"
|
mode: "0644"
|
||||||
owner: "root"
|
owner: "root"
|
||||||
group: "root"
|
group: "root"
|
||||||
register: upstart_init
|
register: upstart_init
|
||||||
|
with_dict: "{{ cinder_service_names }}"
|
||||||
|
when:
|
||||||
|
- inventory_hostname in groups[item.value.group]
|
||||||
|
- "{{ item.value.condition | default(true) }}"
|
||||||
notify:
|
notify:
|
||||||
- Restart cinder services
|
- Restart cinder services
|
||||||
|
|
||||||
@ -31,10 +35,3 @@
|
|||||||
register: upstart_init
|
register: upstart_init
|
||||||
notify:
|
notify:
|
||||||
- Restart cinder services
|
- Restart cinder services
|
||||||
|
|
||||||
- name: Load service
|
|
||||||
service:
|
|
||||||
name: "{{ program_name }}"
|
|
||||||
enabled: "yes"
|
|
||||||
notify:
|
|
||||||
- Restart cinder services
|
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
tags:
|
tags:
|
||||||
- cinder-install
|
- cinder-install
|
||||||
|
|
||||||
- include: cinder_init.yml
|
- include: cinder_init_common.yml
|
||||||
tags:
|
tags:
|
||||||
- cinder-install
|
- cinder-install
|
||||||
|
|
||||||
|
@ -7,13 +7,13 @@ After=network.target
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
User={{ system_user }}
|
User={{ cinder_system_user_name }}
|
||||||
Group={{ system_group }}
|
Group={{ cinder_system_group_name }}
|
||||||
|
|
||||||
{% if program_override is defined %}
|
{% if program_override is defined %}
|
||||||
ExecStart={{ program_override }} {{ program_config_options|default('') }} --log-file=/var/log/cinder/{{ program_name }}.log
|
ExecStart={{ program_override }} {{ program_config_options|default('') }} --log-file=/var/log/cinder/{{ item.key }}.log
|
||||||
{% else %}
|
{% else %}
|
||||||
ExecStart={{ cinder_bin }}/{{ program_name }} {{ program_config_options|default('') }} --log-file=/var/log/cinder/{{ program_name }}.log
|
ExecStart={{ cinder_bin }}/{{ item.key }} {{ program_config_options|default('') }} --log-file=/var/log/cinder/{{ item.key }}.log
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
# Give a reasonable amount of time for the server to start up/shut down
|
# Give a reasonable amount of time for the server to start up/shut down
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# {{ ansible_managed }}
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
D /var/lock/{{ program_name }} 2755 {{ system_user }} {{ system_group }}
|
D /var/lock/{{ item.key }} 2755 {{ cinder_system_user_name }} {{ cinder_system_group_name }}
|
||||||
D /var/run/{{ program_name }} 2755 {{ system_user }} {{ system_group }}
|
D /var/run/{{ item.key }} 2755 {{ cinder_system_user_name }} {{ cinder_system_group_name }}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# {{ ansible_managed }}
|
# {{ ansible_managed }}
|
||||||
|
|
||||||
description "{{ program_name }}"
|
description "{{ item.key }}"
|
||||||
author "Kevin Carter <kevin.carter@rackspace.com>"
|
author "Kevin Carter <kevin.carter@rackspace.com>"
|
||||||
|
|
||||||
start on runlevel [2345]
|
start on runlevel [2345]
|
||||||
@ -10,18 +10,18 @@ respawn
|
|||||||
respawn limit 10 5
|
respawn limit 10 5
|
||||||
|
|
||||||
# Set the RUNBIN environment variable
|
# Set the RUNBIN environment variable
|
||||||
env RUNBIN="{{ cinder_bin }}/{{ program_name }}"
|
env RUNBIN="{{ cinder_bin }}/{{ item.key }}"
|
||||||
|
|
||||||
# Change directory to service users home
|
# Change directory to service users home
|
||||||
chdir "{{ service_home }}"
|
chdir "{{ cinder_system_home_folder }}"
|
||||||
|
|
||||||
# Pre start actions
|
# Pre start actions
|
||||||
pre-start script
|
pre-start script
|
||||||
mkdir -p "/var/run/{{ program_name }}"
|
mkdir -p "/var/run/{{ item.key }}"
|
||||||
chown {{ system_user }}:{{ system_group }} "/var/run/{{ program_name }}"
|
chown {{ cinder_system_user_name }}:{{ cinder_system_group_name }} "/var/run/{{ item.key }}"
|
||||||
|
|
||||||
mkdir -p "/var/lock/{{ program_name }}"
|
mkdir -p "/var/lock/{{ item.key }}"
|
||||||
chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_name }}"
|
chown {{ cinder_system_user_name }}:{{ cinder_system_group_name }} "/var/lock/{{ item.key }}"
|
||||||
|
|
||||||
. {{ cinder_bin }}/activate
|
. {{ cinder_bin }}/activate
|
||||||
|
|
||||||
@ -29,14 +29,14 @@ end script
|
|||||||
|
|
||||||
# Post stop actions
|
# Post stop actions
|
||||||
post-stop script
|
post-stop script
|
||||||
rm "/var/run/{{ program_name }}/{{ program_name }}.pid"
|
rm "/var/run/{{ item.key }}/{{ item.key }}.pid"
|
||||||
end script
|
end script
|
||||||
|
|
||||||
# Run the start up job
|
# Run the start up job
|
||||||
exec start-stop-daemon --start \
|
exec start-stop-daemon --start \
|
||||||
--chuid {{ system_user }} \
|
--chuid {{ cinder_system_user_name }} \
|
||||||
--make-pidfile \
|
--make-pidfile \
|
||||||
--pidfile /var/run/{{ program_name }}/{{ program_name }}.pid \
|
--pidfile /var/run/{{ item.key }}/{{ item.key }}.pid \
|
||||||
--exec "{{ program_override|default('$RUNBIN') }}" \
|
--exec "{{ program_override|default('$RUNBIN') }}" \
|
||||||
-- {{ program_config_options|default('') }} \
|
-- {{ program_config_options|default('') }} \
|
||||||
--log-file=/var/log/cinder/{{ program_name }}.log
|
--log-file=/var/log/cinder/{{ item.key }}.log
|
||||||
|
Loading…
x
Reference in New Issue
Block a user