diff --git a/tripleo_ansible/roles/tripleo_timezone/tasks/configure.yml b/tripleo_ansible/roles/tripleo_timezone/tasks/configure.yml new file mode 100644 index 000000000..1f5c74acd --- /dev/null +++ b/tripleo_ansible/roles/tripleo_timezone/tasks/configure.yml @@ -0,0 +1,25 @@ +--- +# Copyright 2022 Red Hat, Inc. +# All Rights Reserved. +# +# 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. + + +- name: Set timezone + timezone: + name: "{{ tripleo_timezone }}" + register: _timezone_result + +- name: Set fact for timezone result + set_fact: + _timezone_result_changed: _timezone_result.changed diff --git a/tripleo_ansible/roles/tripleo_timezone/tasks/main.yml b/tripleo_ansible/roles/tripleo_timezone/tasks/main.yml index d9b9fdd52..3180b6e3e 100644 --- a/tripleo_ansible/roles/tripleo_timezone/tasks/main.yml +++ b/tripleo_ansible/roles/tripleo_timezone/tasks/main.yml @@ -15,21 +15,8 @@ # under the License. -# "tripleo_timezone" will search for and load any operating system variable file +- name: Configure timezone + import_tasks: configure.yml -- name: Set timezone - timezone: - name: "{{ tripleo_timezone }}" - register: _timezone_result - -- name: Restart time services - systemd: - name: "{{ time_svc }}" - state: restarted - loop_control: - loop_var: time_svc - loop: - - rsyslog - - crond - when: - - _timezone_result.changed +- name: Run timezone + import_tasks: run.yml diff --git a/tripleo_ansible/roles/tripleo_timezone/tasks/run.yml b/tripleo_ansible/roles/tripleo_timezone/tasks/run.yml new file mode 100644 index 000000000..88bbbfb4f --- /dev/null +++ b/tripleo_ansible/roles/tripleo_timezone/tasks/run.yml @@ -0,0 +1,28 @@ +--- +# Copyright 2022 Red Hat, Inc. +# All Rights Reserved. +# +# 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. + + +- name: Restart time services + systemd: + name: "{{ time_svc }}" + state: restarted + loop_control: + loop_var: time_svc + loop: + - rsyslog + - crond + when: + - _timezone_result_changed|default(false)