Browse Source

Merge "Switch from handlers to tasks"

changes/00/744200/4
Zuul 1 week ago
committed by Gerrit Code Review
parent
commit
0984ed35fb
17 changed files with 161 additions and 290 deletions
  1. +0
    -31
      tripleo_ansible/roles/tripleo_cellv2/handlers/main.yml
  2. +22
    -3
      tripleo_ansible/roles/tripleo_cellv2/tasks/add_internalapi_hosts_entries.yml
  3. +0
    -26
      tripleo_ansible/roles/tripleo_container_image_prepare/handlers/main.yml
  4. +14
    -4
      tripleo_ansible/roles/tripleo_container_image_prepare/tasks/main.yml
  5. +0
    -79
      tripleo_ansible/roles/tripleo_firewall/handlers/main.yml
  6. +55
    -2
      tripleo_ansible/roles/tripleo_firewall/tasks/main.yml
  7. +0
    -27
      tripleo_ansible/roles/tripleo_kernel/handlers/main.yml
  8. +17
    -8
      tripleo_ansible/roles/tripleo_kernel/tasks/main.yml
  9. +0
    -21
      tripleo_ansible/roles/tripleo_module_load/handlers/main.yml
  10. +9
    -2
      tripleo_ansible/roles/tripleo_module_load/tasks/main.yml
  11. +0
    -27
      tripleo_ansible/roles/tripleo_ptp/handlers/main.yml
  12. +10
    -2
      tripleo_ansible/roles/tripleo_ptp/tasks/tripleo_phc2sys.yml
  13. +12
    -6
      tripleo_ansible/roles/tripleo_ptp/tasks/tripleo_ptp.yml
  14. +0
    -24
      tripleo_ansible/roles/tripleo_timezone/handlers/main.yml
  15. +12
    -4
      tripleo_ansible/roles/tripleo_timezone/tasks/main.yml
  16. +0
    -21
      tripleo_ansible/roles/tuned/handlers/main.yml
  17. +10
    -3
      tripleo_ansible/roles/tuned/tasks/tuned_install.yml

+ 0
- 31
tripleo_ansible/roles/tripleo_cellv2/handlers/main.yml View File

@@ -1,31 +0,0 @@
---
# Copyright 2019 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: nova restart podman
become: true
systemd:
name: "{{ item }}"
state: restarted
with_items:
- tripleo_nova_api
- tripleo_nova_conductor
- tripleo_nova_scheduler
when: tripleo_cellv2_containercli == "podman"

- name: nova restart docker
become: true
command: docker restart nova_api nova_scheduler nova_conductor
when: tripleo_cellv2_containercli == "docker"

+ 22
- 3
tripleo_ansible/roles/tripleo_cellv2/tasks/add_internalapi_hosts_entries.yml View File

@@ -30,9 +30,28 @@
- hostvars[item]['internal_api_hostname'] is defined
with_items: "{{ tripleo_cellv2_cellcontroller_group }}"
register: hosts_result
notify:
- nova restart podman
- nova restart docker
tags:
- hosts
- create

- name: Restart nova services
become: true
block:
- name: nova restart podman
systemd:
name: "{{ item }}"
state: restarted
with_items:
- tripleo_nova_api
- tripleo_nova_conductor
- tripleo_nova_scheduler
when: tripleo_cellv2_containercli == "podman"

- name: nova restart docker
command: docker restart nova_api nova_scheduler nova_conductor
when: tripleo_cellv2_containercli == "docker"
when:
- hosts_result.changed
tags:
- hosts
- create

+ 0
- 26
tripleo_ansible/roles/tripleo_container_image_prepare/handlers/main.yml View File

@@ -1,26 +0,0 @@
---
# Copyright 2019 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: Delete param file
command: "rm -rf '{{ prepare_param.path }}'"
check_mode: false
become: true

- name: Delete role file
command: "rm -rf '{{ role_data.path }}'"
check_mode: false
become: true

+ 14
- 4
tripleo_ansible/roles/tripleo_container_image_prepare/tasks/main.yml View File

@@ -25,8 +25,6 @@
suffix: -prepare-param
register: prepare_param
check_mode: false
notify:
- Delete param file

- name: Write ContainerImagePrepare parameter file
copy:
@@ -39,8 +37,6 @@
suffix: -role-data
register: role_data
check_mode: false
notify:
- Delete role file

- name: Write role data file
copy:
@@ -62,5 +58,19 @@
when:
- (tripleo_container_image_prepare_content | dict2items | length) > 0
- (tripleo_container_image_prepare_roles | length) > 0
always:
- name: Delete param file
command: "rm -rf '{{ prepare_param.path }}'"
when:
- prepare_param is defined
- prepare_param.changed
check_mode: false

- name: Delete role file
command: "rm -rf '{{ role_data.path }}'"
when:
- role_data is defined
- role_data.changed
check_mode: false
tags:
- container_image_prepare

+ 0
- 79
tripleo_ansible/roles/tripleo_firewall/handlers/main.yml View File

@@ -1,79 +0,0 @@
---
# Copyright 2019 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: Save firewall rules ipv4
command: /usr/libexec/iptables/iptables.init save
become: true
listen: Save firewall rules

- name: Save firewall rules ipv6
command: /usr/libexec/iptables/ip6tables.init save
become: true
listen: Save firewall rules

- name: Enable iptables service (and do a daemon-reload systemd)
systemd:
daemon_reload: true
enabled: true
name: "{{ item }}"
state: started
loop:
- iptables.service
- ip6tables.service
become: true
listen: Save firewall rules

- name: Enable tripleo-iptables service (and do a daemon-reload systemd)
systemd:
daemon_reload: true
enabled: true
name: "{{ item }}"
state: started
loop:
- tripleo-iptables.service
- tripleo-ip6tables.service
failed_when: false
become: true
listen: Save firewall rules

- name: Stop and disable firewalld
systemd:
enabled: false
name: "firewalld.service"
state: stopped
failed_when: false
become: true
listen: Save firewall rules

- name: Find non-persistent rules
command: egrep -l 'comment.*(neutron-|ironic-inspector)' /etc/sysconfig/iptables* /etc/sysconfig/ip6tables*
failed_when: false
changed_when: false
register: neutron_rules
become: true
listen: Save firewall rules

- name: Remove non-persistent line(s)
lineinfile:
path: "{{ item }}"
state: absent
regexp: '^((?!.*comment)(?=.*(ironic-inspector|neutron-)))'
when:
- item.find('v=' ~ '^/') == -1
loop: "{{ neutron_rules.stdout_lines }}"
become: true
listen: Save firewall rules

+ 55
- 2
tripleo_ansible/roles/tripleo_firewall/tasks/main.yml View File

@@ -56,5 +56,58 @@
- name: Manage firewall rules
tripleo_iptables:
tripleo_rules: "{{ firewall_rules_sorted }}"
notify:
- Save firewall rules
register: _iptables_result

- name: Firewall save block
when:
- _iptables_result.changed
become: true
block:
- name: Save firewall rules ipv4
command: /usr/libexec/iptables/iptables.init save

- name: Save firewall rules ipv6
command: /usr/libexec/iptables/ip6tables.init save

- name: Enable iptables service (and do a daemon-reload systemd)
systemd:
daemon_reload: true
enabled: true
name: "{{ item }}"
state: started
loop:
- iptables.service
- ip6tables.service

- name: Enable tripleo-iptables service (and do a daemon-reload systemd)
systemd:
daemon_reload: true
enabled: true
name: "{{ item }}"
state: started
loop:
- tripleo-iptables.service
- tripleo-ip6tables.service
failed_when: false

- name: Stop and disable firewalld
systemd:
enabled: false
name: "firewalld.service"
state: stopped
failed_when: false

- name: Find non-persistent rules
command: egrep -l 'comment.*(neutron-|ironic-inspector)' /etc/sysconfig/iptables* /etc/sysconfig/ip6tables*
failed_when: false
changed_when: false
register: neutron_rules

- name: Remove non-persistent line(s)
lineinfile:
path: "{{ item }}"
state: absent
regexp: '^((?!.*comment)(?=.*(ironic-inspector|neutron-)))'
when:
- item.find('v=' ~ '^/') == -1
loop: "{{ neutron_rules.stdout_lines }}"

+ 0
- 27
tripleo_ansible/roles/tripleo_kernel/handlers/main.yml View File

@@ -1,27 +0,0 @@
---
# Copyright 2019 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: Sysctl reload
become: true
systemd:
name: systemd-sysctl.service
state: restarted

- name: Modules reload
become: true
systemd:
name: systemd-modules-load.service
state: restarted

+ 17
- 8
tripleo_ansible/roles/tripleo_kernel/tasks/main.yml View File

@@ -25,7 +25,7 @@
name: "{{ item.key }}"
state: "{{ item.opt.state | default('present') }}"
loop: "{{ tripleo_kernel_extra_packages | dict2items(key_name='key', value_name='opt') }}"
notify: Modules reload
register: _install_packages_result

- name: Remove dracut-config-generic
package:
@@ -49,10 +49,14 @@
owner: root
group: root
setype: etc_t
notify: Modules reload
register: _modprobe_result

- name: Run handlers to load new modules
meta: flush_handlers
- name: Modules reload
systemd:
name: systemd-modules-load.service
state: restarted
when:
- _install_packages_result.changed or _modprobe_result.changed

- name: Set default sysctl options
template:
@@ -62,8 +66,7 @@
owner: root
group: root
setype: etc_t
notify:
- Sysctl reload
register: _default_sysctl_result

- name: Set extra sysctl options
sysctl:
@@ -74,5 +77,11 @@
sysctl_file: "/etc/sysctl.d/99-tripleo.conf"
reload: false
loop: "{{ tripleo_kernel_sysctl_extra_settings | dict2items(key_name='key', value_name='opt') }}"
notify:
- Sysctl reload
register: _extra_sysctl_result

- name: Sysctl reload
systemd:
name: systemd-sysctl.service
state: restarted
when:
- _extra_sysctl_result.changed or _default_sysctl_result.changed

+ 0
- 21
tripleo_ansible/roles/tripleo_module_load/handlers/main.yml View File

@@ -1,21 +0,0 @@
---
# Copyright 2019 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: Modules reload
become: true
systemd:
name: systemd-modules-load.service
state: restarted

+ 9
- 2
tripleo_ansible/roles/tripleo_module_load/tasks/main.yml View File

@@ -43,8 +43,7 @@
loop: "{{ tripleo_modules }}"
loop_control:
label: "{{ item.name }}"
notify:
- Modules reload
register: _tripleo_modules_add
when:
- (item.state | default('present')) == 'present'

@@ -55,6 +54,7 @@
loop: "{{ tripleo_modules }}"
loop_control:
label: "{{ item.name }}"
register: _tripleo_modules_remove
when:
- (item.state | default('present')) == 'absent'

@@ -67,3 +67,10 @@
loop: "{{ tripleo_modules }}"
loop_control:
label: "{{ item.name }}"

- name: Modules reload
systemd:
name: systemd-modules-load.service
state: restarted
when:
- _tripleo_modules_add.changed or _tripleo_modules_remove.changed

+ 0
- 27
tripleo_ansible/roles/tripleo_ptp/handlers/main.yml View File

@@ -1,27 +0,0 @@
---
# Copyright 2019 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: Enable and start the ptp service
systemd:
name: ptp4l
state: started
enabled: true

- name: Enable and start the phc2sys service
systemd:
name: phc2sys
state: restarted
enabled: true

+ 10
- 2
tripleo_ansible/roles/tripleo_ptp/tasks/tripleo_phc2sys.yml View File

@@ -35,5 +35,13 @@
dest: /etc/sysconfig/phc2sys
when:
- tripleo_phc_interface
notify:
- Enable and start the phc2sys service
register: _ptp_phc2sys_sysconfig_result

- name: Enable and start the phc2sys service
become: true
systemd:
name: phc2sys
state: restarted
enabled: true
when:
- _ptp_phc2sys_sysconfig_result.changed

+ 12
- 6
tripleo_ansible/roles/tripleo_ptp/tasks/tripleo_ptp.yml View File

@@ -19,8 +19,7 @@
package:
name: "{{ tripleo_ptp_packages }}"
state: present
notify:
- Enable and start the ptp service
register: _ptp_install_result

- name: Collect only facts returned by facter
setup:
@@ -60,13 +59,20 @@
template:
src: "ptp4l.conf.j2"
dest: /etc/ptp4l.conf
notify:
- Enable and start the ptp service
register: _ptp_config_result

- name: Create ptp service config
copy:
content: |-
OPTIONS="-f /etc/ptp4l.conf"
dest: /etc/sysconfig/ptp4l
notify:
- Enable and start the ptp service
register: _ptp_sysconfig_result

- name: Enable and start the ptp service
become: true
systemd:
name: ptp4l
state: restarted
enabled: true
when:
- _ptp_install_result.changed or _ptp_config_result.changed or _ptp_sysconfig_result.changed

+ 0
- 24
tripleo_ansible/roles/tripleo_timezone/handlers/main.yml View File

@@ -1,24 +0,0 @@
---
# Copyright 2019 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: "{{ item }}"
state: restarted
with_items:
- rsyslog
- crond

+ 12
- 4
tripleo_ansible/roles/tripleo_timezone/tasks/main.yml View File

@@ -20,8 +20,16 @@
- name: Set timezone
timezone:
name: "{{ tripleo_timezone }}"
notify:
- Restart time services
register: _timezone_result

- name: Force all notified handlers to run at this point
meta: flush_handlers
- name: Restart time services
systemd:
name: "{{ time_svc }}"
state: restarted
loop_control:
loop_var: time_svc
loop:
- rsyslog
- crond
when:
- _timezone_result.changed

+ 0
- 21
tripleo_ansible/roles/tuned/handlers/main.yml View File

@@ -1,21 +0,0 @@
---
# Copyright 2019 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 tuned
systemd:
name: tuned
state: restarted
enabled: true

+ 10
- 3
tripleo_ansible/roles/tuned/tasks/tuned_install.yml View File

@@ -16,10 +16,17 @@


- name: Install tuned
become: true
package:
name: "{{ tuned_system_packages }}"
state: present
notify: Restart tuned
register: _tuned_install_result

- name: Flush handlers
meta: flush_handlers
- name: Restart tuned
become: true
systemd:
name: tuned
state: restarted
enabled: true
when:
- _tuned_install_result.changed

Loading…
Cancel
Save