Include init_systemd taskfile once

Instead of providing vars to and including the keystone_init_systemd for
each keystone uwsgi program, loop over those program names within the
tasks.

This also prevents the /etc/tmpfiles.d/keystone.conf file from being
overwritten twice on every run.

Change-Id: I00dc80db7f6672fb26af0ec2301b3a4ea451844d
This commit is contained in:
Jimmy McCrory 2017-07-05 17:00:24 -07:00
parent 6241f5e6c6
commit 1b8a085b79
4 changed files with 24 additions and 28 deletions

View File

@ -13,16 +13,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Create Keystone TEMP dirs
- name: Create TEMP run dir
file:
path: "{{ item.path }}/{{ program_name }}"
path: "/var/run/{{ item }}"
state: directory
owner: "{{ system_user }}"
group: "{{ system_group }}"
owner: "{{ keystone_system_user_name }}"
group: "{{ keystone_system_group_name }}"
mode: "02755"
with_items:
- { path: "/var/run" }
- { path: "/var/lock" }
with_items: "{{ keystone_wsgi_program_names }}"
- name: Create TEMP lock dir
file:
path: "/var/lock/{{ item }}"
state: directory
owner: "{{ keystone_system_user_name }}"
group: "{{ keystone_system_group_name }}"
mode: "02755"
with_items: "{{ keystone_wsgi_program_names }}"
- name: Create tempfile.d entry
template:
@ -38,12 +45,13 @@
- name: Place the systemd init script
config_template:
src: "keystone-uwsgi_systemd-init.j2"
dest: "/etc/systemd/system/{{ program_name }}.service"
dest: "/etc/systemd/system/{{ item }}.service"
mode: "0644"
owner: "root"
group: "root"
config_overrides: "{{ keystone_uwsgi_init_overrides }}"
config_type: "ini"
with_items: "{{ keystone_wsgi_program_names }}"
notify:
- Restart uWSGI
- Restart web server

View File

@ -30,17 +30,3 @@
- Restart uWSGI
- include: "keystone_init_{{ ansible_service_mgr }}.yml"
vars:
program_name: "{{ keystone_wsgi_public_program_name }}"
service_name: "{{ keystone_wsgi_public_program_name }}"
system_user: "{{ keystone_system_user_name }}"
system_group: "{{ keystone_system_group_name }}"
service_home: "{{ keystone_system_user_home }}"
- include: "keystone_init_{{ ansible_service_mgr }}.yml"
vars:
program_name: "{{ keystone_wsgi_admin_program_name }}"
service_name: "{{ keystone_wsgi_admin_program_name }}"
system_user: "{{ keystone_system_user_name }}"
system_group: "{{ keystone_system_group_name }}"
service_home: "{{ keystone_system_user_home }}"

View File

@ -1,4 +1,6 @@
# {{ ansible_managed }}
D /var/lock/{{ program_name }} 2755 {{ system_user }} {{ system_group }}
D /var/run/{{ program_name }} 2755 {{ system_user }} {{ system_group }}
{% for program_name in keystone_wsgi_program_names %}
D /var/lock/{{ program_name }} 2755 {{ keystone_system_user_name }} {{ keystone_system_group_name }}
D /var/run/{{ program_name }} 2755 {{ keystone_system_user_name }} {{ keystone_system_group_name }}
{% endfor %}

View File

@ -7,13 +7,13 @@ After=network.target
[Service]
Type=simple
User={{ system_user }}
Group={{ system_group }}
User={{ keystone_system_user_name }}
Group={{ keystone_system_group_name }}
{% if program_override is defined %}
ExecStart={{ program_override }} --ini /etc/uwsgi/{{ program_name }}.ini --logto /var/log/keystone/{{ program_name }}.log {{ program_config_options|default('') }}
ExecStart={{ program_override }} --ini /etc/uwsgi/{{ item }}.ini --logto /var/log/keystone/{{ item }}.log {{ program_config_options|default('') }}
{% else %}
ExecStart={{ keystone_bin }}/uwsgi --ini /etc/uwsgi/{{ program_name }}.ini --logto /var/log/keystone/{{ program_name }}.log {{ program_config_options|default('') }}
ExecStart={{ keystone_bin }}/uwsgi --ini /etc/uwsgi/{{ item }}.ini --logto /var/log/keystone/{{ item }}.log {{ program_config_options|default('') }}
{% endif %}
# Give a reasonable amount of time for the server to start up/shut down