Fix linters and metadata

With update of ansible-lint to version >=6.0.0 a lot of new
linters were added, that enabled by default. In order to comply
with linter rules we're applying changes to the role.

With that we also update metdata to reflect current state.

Depends-On: https://review.opendev.org/c/openstack/ansible-role-systemd_service/+/888223
Change-Id: I671cc35a055b35fb249ad3054c45ec65f2b54ab4
This commit is contained in:
Dmitriy Rabotyagov 2023-07-14 13:08:30 +02:00 committed by Dmitriy Rabotyagov
parent 2820fcc1d6
commit 8413941eaa
12 changed files with 139 additions and 68 deletions

View File

@ -21,7 +21,11 @@ cinder_package_state: "{{ package_state | default('latest') }}"
# for the service setup. The host must already have
# clouds.yaml properly configured.
cinder_service_setup_host: "{{ openstack_service_setup_host | default('localhost') }}"
cinder_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((cinder_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}"
cinder_service_setup_host_python_interpreter: >-
{{
openstack_service_setup_host_python_interpreter | default(
(cinder_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable']))
}}
# Set installation method.
cinder_install_method: "{{ service_install_method | default('source') }}"
@ -29,7 +33,8 @@ cinder_venv_python_executable: "{{ openstack_venv_python_executable | default('p
cinder_git_repo: https://opendev.org/openstack/cinder
cinder_git_install_branch: master
cinder_upper_constraints_url: "{{ requirements_git_url | default('https://releases.openstack.org/constraints/upper/' ~ requirements_git_install_branch | default('master')) }}"
cinder_upper_constraints_url: >-
{{ requirements_git_url | default('https://releases.openstack.org/constraints/upper/' ~ requirements_git_install_branch | default('master')) }}
cinder_git_constraints:
- "--constraint {{ cinder_upper_constraints_url }}"
@ -64,7 +69,11 @@ cinder_fatal_deprecations: False
## Database info
cinder_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}"
cinder_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((cinder_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}"
cinder_db_setup_python_interpreter: >-
{{
openstack_db_setup_python_interpreter | default(
(cinder_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable']))
}}
cinder_galera_address: "{{ galera_address | default('127.0.0.1') }}"
cinder_galera_user: cinder
cinder_galera_database: cinder
@ -230,7 +239,8 @@ cinder_swift_catalog_info: "object-store:swift:internalURL"
## Cap the maximun number of threads / workers when a user value is unspecified.
cinder_osapi_volume_workers_max: 16
cinder_osapi_volume_workers: "{{ [[(ansible_facts['processor_vcpus']//ansible_facts['processor_threads_per_core'])|default(1), 1] | max * 2, cinder_osapi_volume_workers_max] | min }}"
cinder_osapi_volume_workers: >-
{{ [[(ansible_facts['processor_vcpus'] // ansible_facts['processor_threads_per_core']) | default(1), 1] | max * 2, cinder_osapi_volume_workers_max] | min }}
## Cinder iscsi
cinder_target_helper_mapping:
@ -306,7 +316,14 @@ cinder_active_active_cluster_name: ceph
# "volume:delete": ""
# Comma separated list of Glance API servers
cinder_glance_api_servers: "{{ (glance_service_internalurl | default('http://localhost')) | urlsplit('scheme') ~ '://' ~ (glance_service_internalurl | default('http://localhost')) | urlsplit('netloc') }}"
cinder_glance_api_servers: >-
{{
(
glance_service_internalurl | default('http://localhost')
) | urlsplit('scheme') ~ '://' ~ (
glance_service_internalurl | default('http://localhost')
) | urlsplit('netloc')
}}
cinder_service_in_ldap: "{{ service_ldap_backend_enabled | default(False) }}"
@ -408,8 +425,6 @@ cinder_environment_overrides:
Service:
Environment: "PATH={{ cinder_bin }}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
_UUID_regex: "[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}"
cinder_memcached_servers: "{{ memcached_servers }}"
###

View File

@ -18,19 +18,21 @@ galaxy_info:
description: Installation and setup of cinder
company: Rackspace
license: Apache2
min_ansible_version: 2.2
role_name: os_cinder
namespace: openstack
min_ansible_version: "2.10"
platforms:
- name: Debian
versions:
- buster
- bullseye
- name: Ubuntu
versions:
- bionic
- focal
- jammy
- name: EL
versions:
- 8
categories:
- "9"
galaxy_tags:
- cloud
- python
- cinder

View File

@ -40,11 +40,15 @@
shell: |
. {{ ansible_facts['env']['HOME'] }}/openrc
CLI_OPTIONS="{{ ((keystone_service_adminuri_insecure | bool) or (keystone_service_internaluri_insecure | bool)) | ternary('--insecure', '') }}"
if ! {{ cinder_service_setup_host_python_interpreter | dirname }}/openstack ${CLI_OPTIONS} volume type show "{{ item.key }}"; then
{{ cinder_service_setup_host_python_interpreter | dirname }}/openstack ${CLI_OPTIONS} volume type create --property volume_backend_name="{{ item.value.volume_backend_name }}" {% if not (item.value.public | default(True)) | bool %} --private {% endif %} "{{ item.key }}"
if ! {{ __cinder_python_interpreter_dirname }}/openstack ${CLI_OPTIONS} volume type show "{{ item.key }}"; then
{{ __cinder_python_interpreter_dirname }}/openstack ${CLI_OPTIONS} volume type create \
--property volume_backend_name="{{ item.value.volume_backend_name }}" \
{% if not (item.value.public | default(True)) | bool %} --private {% endif %} "{{ item.key }}"
fi
args:
executable: /bin/bash
vars:
__cinder_python_interpreter_dirname: "{{ cinder_service_setup_host_python_interpreter | dirname }}"
with_dict: "{{ _cinder_backends | default({}) }}"
delegate_to: "{{ cinder_service_setup_host }}"
changed_when: false
@ -54,17 +58,23 @@
. {{ ansible_facts['env']['HOME'] }}/openrc
CLI_OPTIONS="{{ ((keystone_service_adminuri_insecure | bool) or (keystone_service_internaluri_insecure | bool)) | ternary('--insecure', '') }}"
{% for evtype in item.value.extra_volume_types %}
if ! {{ cinder_service_setup_host_python_interpreter | dirname }}/openstack ${CLI_OPTIONS} volume type show "{{ evtype }}"; then
{{ cinder_service_setup_host_python_interpreter | dirname }}/openstack ${CLI_OPTIONS} volume type create --property volume_backend_name="{{ item.value.volume_backend_name }}" {% if not (item.value.public | default(True)) | bool %} --private {% endif %} "{{ evtype }}"
if ! {{ __cinder_python_interpreter_dirname }}/openstack ${CLI_OPTIONS} volume type show "{{ evtype }}"; then
{{ __cinder_python_interpreter_dirname }}/openstack ${CLI_OPTIONS} volume type create \
--property volume_backend_name="{{ item.value.volume_backend_name }}" \
{% if not (item.value.public | default(True)) | bool %} --private {% endif %} "{{ evtype }}"
fi
{% endfor %}
args:
executable: /bin/bash
vars:
__cinder_python_interpreter_dirname: "{{ cinder_service_setup_host_python_interpreter | dirname }}"
changed_when: false
with_dict: "{{ _cinder_backends | default({}) }}"
delegate_to: "{{ cinder_service_setup_host }}"
when: item.value.extra_volume_types is defined
- import_tasks: cinder_qos.yml
- name: Importing cinder_qos tasks
import_tasks: cinder_qos.yml
when: cinder_qos_specs is defined
tags:
- cinder-qos

View File

@ -22,8 +22,9 @@
section: cinder
option: "need_db_sync"
state: absent
mode: "0644"
- name: refresh local facts
- name: Refresh local facts
setup:
filter: ansible_local
gather_subset: "!all"

View File

@ -29,6 +29,7 @@
- name: Check if all cinder services are up
shell: "{{ cinder_bin }}/cinder-manage service list | /usr/bin/awk '{ if(NR>1) print $5 }' | /bin/egrep -vq ':-)'"
register: failed_cinder_services
changed_when: false
ignore_errors: True
- name: Fail if any cinder service is down
@ -53,6 +54,7 @@
section: cinder
option: need_online_data_migrations
value: False
mode: "0644"
with_items: "{{ groups[cinder_services['cinder-api']['group']] }}"
when:
- not data_migrations is skipped

View File

@ -19,6 +19,7 @@
section: "cinder"
option: "install_method"
value: "{{ cinder_install_method }}"
mode: "0644"
- name: Refresh local facts to ensure the cinder section is present
setup:
@ -51,10 +52,10 @@
systemd_tempd_prefix: openstack
systemd_slice_name: "{{ cinder_system_slice_name }}"
systemd_lock_dir: "{{ cinder_lock_dir }}"
systemd_CPUAccounting: true
systemd_BlockIOAccounting: true
systemd_MemoryAccounting: true
systemd_TasksAccounting: true
systemd_service_cpu_accounting: true
systemd_service_block_io_accounting: true
systemd_service_memory_accounting: true
systemd_service_tasks_accounting: true
systemd_services: "{{ filtered_cinder_services }}"
tags:
- cinder-config
@ -69,6 +70,7 @@
section: cinder
option: venv_tag
value: "{{ cinder_venv_tag }}"
mode: "0644"
- name: Set the upgrade facts
ini_file:
@ -76,10 +78,11 @@
section: cinder
option: "{{ item }}"
value: true
mode: "0644"
with_items:
- "need_online_data_migrations"
- "need_service_restart"
when:
(install_packages is changed) or
- (install_packages is changed) or
('need_online_data_migrations' not in ansible_local['openstack_ansible']['cinder']) or
('need_service_restart' not in ansible_local['openstack_ansible']['cinder'])

View File

@ -14,7 +14,7 @@
# limitations under the License.
- name: Discover lvm devices
shell: |
shell: >-
/sbin/pvdisplay | awk '/PV\ Name/ {print $3}' | sed 's/\/dev\///g'
register: lvm_devices
changed_when: lvm_devices.rc != 0
@ -24,6 +24,7 @@
file:
state: "directory"
path: "/etc/lvm"
mode: "0755"
when: lvm_devices.rc == 0
- name: Drop lvm Config
@ -33,4 +34,5 @@
owner: "root"
group: "root"
backup: "yes"
mode: "0644"
when: lvm_devices.rc == 0

View File

@ -21,6 +21,7 @@
state: "directory"
owner: "root"
group: "root"
mode: "0750"
- name: Generate cinder config
openstack.config_template.config_template:
@ -160,6 +161,7 @@
template:
src: nfs_shares.j2
dest: "{{ item.value.nfs_shares_config }}"
mode: "0644"
with_dict: "{{ cinder_backends | default({}) }}"
when:
- "cinder_services['cinder-volume']['group'] in group_names"

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: create the system group
- name: Create the system group
group:
name: "{{ cinder_system_group_name }}"
gid: "{{ cinder_system_group_gid | default(omit) }}"

View File

@ -17,12 +17,14 @@
shell: |
. {{ ansible_facts['env']['HOME'] }}/openrc
CLI_OPTIONS="{{ ((keystone_service_adminuri_insecure | bool) or (keystone_service_internaluri_insecure | bool)) | ternary('--insecure', '') }}"
{{ cinder_service_setup_host_python_interpreter | dirname }}/openstack ${CLI_OPTIONS} volume qos list --format value --column Name | grep -x {{ item.name }} || \
{{ cinder_service_setup_host_python_interpreter | dirname }}/openstack ${CLI_OPTIONS} volume qos create {{ item.name }} \
{{ __cinder_python_interpreter_dirname }}/openstack ${CLI_OPTIONS} volume qos list --format value --column Name | grep -x {{ item.name }} || \
{{ __cinder_python_interpreter_dirname }}/openstack ${CLI_OPTIONS} volume qos create {{ item.name }} \
--consumer {{ item.options.consumer }}\
{% for k, v in item.options.items() %} --property {{ k }}={{ v }}{% endfor %}
args:
executable: /bin/bash
vars:
__cinder_python_interpreter_dirname: "{{ cinder_service_setup_host_python_interpreter | dirname }}"
with_items: "{{ cinder_qos_specs }}"
delegate_to: "{{ cinder_service_setup_host }}"
changed_when: false
@ -34,13 +36,16 @@
. {{ ansible_facts['env']['HOME'] }}/openrc
CLI_OPTIONS="{{ ((keystone_service_adminuri_insecure | bool) or (keystone_service_internaluri_insecure | bool)) | ternary('--insecure', '') }}"
{% for vtype in item.cinder_volume_types %}
if {{ cinder_service_setup_host_python_interpreter | dirname }}/openstack ${CLI_OPTIONS} volume type show "{{ vtype }}"; then
{{ cinder_service_setup_host_python_interpreter | dirname }}/openstack ${CLI_OPTIONS} volume qos associate {{ item.name }} {{ vtype }}
if {{ __cinder_python_interpreter_dirname }}/openstack ${CLI_OPTIONS} volume type show "{{ vtype }}"; then
{{ __cinder_python_interpreter_dirname }}/openstack ${CLI_OPTIONS} volume qos associate {{ item.name }} {{ vtype }}
fi
{% endfor %}
args:
executable: /bin/bash
vars:
__cinder_python_interpreter_dirname: "{{ cinder_service_setup_host_python_interpreter | dirname }}"
with_items: "{{ cinder_qos_specs }}"
changed_when: false
delegate_to: "{{ cinder_service_setup_host }}"
when:
- item.cinder_volume_types is defined

View File

@ -43,7 +43,8 @@
tags:
- always
- include_role:
- name: Including osa.db_setup role
include_role:
name: openstack.osa.db_setup
apply:
tags:
@ -64,7 +65,8 @@
tags:
- always
- include_role:
- name: Including osa.mq_setup role
include_role:
name: openstack.osa.mq_setup
apply:
tags:
@ -86,18 +88,21 @@
tags:
- always
- import_tasks: cinder_lvm_config.yml
- name: Importing cinder_lvm_config tasks
import_tasks: cinder_lvm_config.yml
when:
- "cinder_services['cinder-volume']['group'] in group_names"
- "cinder_backend_lvm_inuse | bool"
tags:
- cinder-config
- import_tasks: cinder_pre_install.yml
- name: Importing cinder_pre_install tasks
import_tasks: cinder_pre_install.yml
tags:
- cinder-install
- import_tasks: cinder_install.yml
- name: Importing cinder_install tasks
import_tasks: cinder_install.yml
tags:
- cinder-install
@ -121,14 +126,15 @@
tags:
- always
- name: refresh local facts
- name: Refresh local facts
setup:
filter: ansible_local
gather_subset: "!all"
tags:
- cinder-config
- include_tasks: cinder_cleanup_old_facts.yml
- name: Including cinder_cleanup_old_facts tasks
include_tasks: cinder_cleanup_old_facts.yml
args:
apply:
tags:
@ -140,7 +146,8 @@
tags:
- always
- import_tasks: cinder_post_install.yml
- name: Importing cinder_post_install tasks
import_tasks: cinder_post_install.yml
tags:
- cinder-config
@ -155,7 +162,11 @@
systemd_services:
- service_name: "cinder-volume-usage-audit"
execstarts:
- '/bin/bash -c "{{ cinder_bin }}/cinder-volume-usage-audit --start_time \"$$(date\s+%%Y-%%m-%%d\\\s%%H:00:00\s-d\s-1{{ cinder_volume_usage_audit }})\" --end_time \"$$(date\s+%%Y-%%m-%%d\\\s%%H:00:00)\" {{ (cinder_volume_usage_audit_send_actions_enabled | bool) | ternary( "--send_actions", "--nosend_actions" ) }}"'
- >-
/bin/bash -c "{{ cinder_bin }}/cinder-volume-usage-audit --start_time \"$$(date\s+%%Y-%%m-%%d\\\s%%H:00:00\s-d\s-1{{ cinder_volume_usage_audit }})\"
--end_time \"$$(date\s+%%Y-%%m-%%d\\\s%%H:00:00)\" {{
(cinder_volume_usage_audit_send_actions_enabled | bool) | ternary('--send_actions', '--nosend_actions')
}}"
timer:
state: "{{ ((cinder_services['cinder-volume']['group'] in group_names) and (cinder_ceilometer_enabled | bool)) | ternary('started', 'stopped') }}"
options:
@ -165,7 +176,8 @@
tags:
- cinder-config
- import_tasks: cinder_db_sync.yml
- name: Importing cinder_db_sync tasks
import_tasks: cinder_db_sync.yml
when:
- _cinder_is_first_api_play_host
tags:
@ -181,7 +193,8 @@
- cinder-config
- uwsgi
- include_role:
- name: Including osa.service_setup role
include_role:
name: openstack.osa.service_setup
apply:
tags:
@ -236,13 +249,15 @@
- name: Flush handlers
meta: flush_handlers
- import_tasks: cinder_db_post_setup.yml
- name: Importing cinder_db_post_setup tasks
import_tasks: cinder_db_post_setup.yml
when:
- "_cinder_is_last_play_host"
tags:
- cinder-config
- import_tasks: cinder_backends.yml
- name: Importing cinder_backends tasks
import_tasks: cinder_backends.yml
when:
- "groups[cinder_services['cinder-volume']['group']] | length > 0"
- "_cinder_is_last_play_host"

View File

@ -13,9 +13,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
_cinder_is_first_api_play_host: "{{ (cinder_services['cinder-api']['group'] in group_names and inventory_hostname == (groups[cinder_services['cinder-api']['group']] | intersect(ansible_play_hosts)) | first) | bool }}"
_cinder_is_first_play_host: "{{ (cinder_services['cinder-scheduler']['group'] in group_names and inventory_hostname == (groups[cinder_services['cinder-scheduler']['group']] | intersect(ansible_play_hosts)) | first) | bool }}"
_cinder_is_last_play_host: "{{ (cinder_services['cinder-api']['group'] in group_names and inventory_hostname == (groups[cinder_services['cinder-api']['group']] | intersect(ansible_play_hosts)) | last) | bool }}"
_cinder_is_first_api_play_host: >-
{{
(cinder_services['cinder-api']['group'] in group_names and
inventory_hostname == (groups[cinder_services['cinder-api']['group']] | intersect(ansible_play_hosts)) | first) | bool
}}
_cinder_is_first_play_host: >-
{{
(cinder_services['cinder-scheduler']['group'] in group_names and
inventory_hostname == (groups[cinder_services['cinder-scheduler']['group']] | intersect(ansible_play_hosts)) | first) | bool
}}
_cinder_is_last_play_host: >-
{{
(cinder_services['cinder-api']['group'] in group_names and
inventory_hostname == (groups[cinder_services['cinder-api']['group']] | intersect(ansible_play_hosts)) | last) | bool
}}
_cinder_rootwrap_conf_overrides:
DEFAULT:
@ -136,4 +148,6 @@ _cinder_coordination_url: >-
groups[cinder_coordination_group]
| map('extract', hostvars, 'ansible_host')
| list | join(':' ~ cinder_coordination_port ~ ',')
}}:{{ cinder_coordination_port }}?namespace={{ cinder_coordination_namespace }}{% if cinder_coordination_client_ssl | bool %}&use_ssl=True&verify_certs={{ cinder_coordination_verify_cert | bool }}{% endif %}
}}:{{ cinder_coordination_port -}}
?namespace={{ cinder_coordination_namespace }}{% if cinder_coordination_client_ssl | bool -%}
&use_ssl=True&verify_certs={{ cinder_coordination_verify_cert | bool }}{% endif %}