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: I6bbb97cd2f1daac42269a335014eb6cf7f28d24e
This commit is contained in:
Dmitriy Rabotyagov 2023-07-17 11:45:20 +02:00
parent 96a262b26b
commit 99c6fb2835
16 changed files with 137 additions and 64 deletions

View File

@ -23,7 +23,11 @@ debug: False
# for the service setup. The host must already have
# clouds.yaml properly configured.
swift_service_setup_host: "{{ openstack_service_setup_host | default('localhost') }}"
swift_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((swift_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}"
swift_service_setup_host_python_interpreter: >-
{{
openstack_service_setup_host_python_interpreter | default(
(swift_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable']))
}}
# Set the package install state for distribution packages
# Options are 'present' and 'latest'
@ -37,7 +41,8 @@ swift_venv_python_executable: "{{ openstack_venv_python_executable | default('py
swift_git_repo: https://opendev.org/openstack/swift
swift_git_install_branch: master
swift_upper_constraints_url: "{{ requirements_git_url | default('https://releases.openstack.org/constraints/upper/' ~ requirements_git_install_branch | default('master')) }}"
swift_upper_constraints_url: >-
{{ requirements_git_url | default('https://releases.openstack.org/constraints/upper/' ~ requirements_git_install_branch | default('master')) }}
swift_git_constraints:
- "--constraint {{ swift_upper_constraints_url }}"
@ -159,7 +164,8 @@ swift_operator_role: swiftoperator
swift_allow_versions: True
# This will allow all users to create containers and upload to swift if set to True
swift_allow_all_users: False
# If you want to regenerate the swift keys, on a run, for rsync purposes set this var to True otherwise keys will be generated on the first run and not regenerated each run.
# If you want to regenerate the swift keys, on a run, for rsync purposes set this var to True
# otherwise keys will be generated on the first run and not regenerated each run.
swift_recreate_keys: False
swift_sorting_method: shuffle
# Set the fallocate_reserve value which will reserve space and fail on PUTs above this value in bytes (Default 10GB)
@ -231,8 +237,8 @@ swift_oslomsg_notify_ssl_ca_file: "{{ oslomsg_notify_ssl_ca_file | default('') }
# value at 16 if the swift proxy is in a container and user did not define
# this variable.
swift_proxy_server_workers_max: 16
swift_proxy_server_workers_not_capped: "{{ [(ansible_facts['processor_vcpus']//ansible_facts['processor_threads_per_core'])|default(1), 1] | max * 2 }}"
swift_proxy_server_workers_capped: "{{ [swift_proxy_server_workers_max, swift_proxy_server_workers_not_capped|int] | min }}"
swift_proxy_server_workers_not_capped: "{{ [(ansible_facts['processor_vcpus'] // ansible_facts['processor_threads_per_core']) | default(1), 1] | max * 2 }}"
swift_proxy_server_workers_capped: "{{ [swift_proxy_server_workers_max, swift_proxy_server_workers_not_capped | int] | min }}"
swift_proxy_server_workers: "{{ (inventory_hostname == physical_host) | ternary(swift_proxy_server_workers_not_capped, swift_proxy_server_workers_capped) }}"
# These are the storage addresses used to define the networks for swift storage and replication
@ -405,7 +411,10 @@ swift_services:
swift-account-auditor:
group: swift_acc
service_name: swift-account-auditor
execstarts: "{{ swift_bin }}/swift-account-auditor {{ swift_dedicated_replication | ternary('/etc/swift/account-server/account-server-replicator.conf', '/etc/swift/account-server/account-server.conf') }}"
execstarts: >-
{{ swift_bin }}/swift-account-auditor {{ swift_dedicated_replication | ternary(
'/etc/swift/account-server/account-server-replicator.conf', '/etc/swift/account-server/account-server.conf'
) }}
init_config_overrides: "{{ swift_account_auditor_init_overrides }}"
start_order: 8
swift-account-reaper:
@ -417,14 +426,20 @@ swift_services:
swift-account-replicator:
group: swift_acc
service_name: swift-account-replicator
execstarts: "{{ swift_bin }}/swift-account-replicator {{ swift_dedicated_replication | ternary('/etc/swift/account-server/account-server-replicator.conf', '/etc/swift/account-server/account-server.conf') }}"
execstarts: >-
{{ swift_bin }}/swift-account-replicator {{ swift_dedicated_replication | ternary(
'/etc/swift/account-server/account-server-replicator.conf', '/etc/swift/account-server/account-server.conf'
) }}
init_config_overrides: "{{ swift_account_replicator_init_overrides }}"
start_order: 10
swift-container-auditor:
group: swift_cont
service_name: "swift-container-auditor"
execstarts: "{{ swift_bin }}/swift-container-auditor {{ swift_dedicated_replication | ternary('/etc/swift/container-server/container-server-replicator.conf', '/etc/swift/container-server/container-server.conf') }}"
execstarts: >-
{{ swift_bin }}/swift-container-auditor {{ swift_dedicated_replication | ternary(
'/etc/swift/container-server/container-server-replicator.conf', '/etc/swift/container-server/container-server.conf'
) }}
init_config_overrides: "{{ swift_container_auditor_init_overrides }}"
start_order: 11
swift-container-reconciler:
@ -436,7 +451,10 @@ swift_services:
swift-container-replicator:
group: swift_cont
service_name: "swift-container-replicator"
execstarts: "{{ swift_bin }}/swift-container-replicator {{ swift_dedicated_replication | ternary('/etc/swift/container-server/container-server-replicator.conf', '/etc/swift/container-server/container-server.conf') }}"
execstarts: >-
{{ swift_bin }}/swift-container-replicator {{ swift_dedicated_replication | ternary(
'/etc/swift/container-server/container-server-replicator.conf', '/etc/swift/container-server/container-server.conf'
) }}
init_config_overrides: "{{ swift_container_replicator_init_overrides }}"
start_order: 13
swift-container-sync:
@ -455,7 +473,10 @@ swift_services:
swift-object-auditor:
group: swift_obj
service_name: "swift-object-auditor"
execstarts: "{{ swift_bin }}/swift-object-auditor {{ swift_dedicated_replication | ternary('/etc/swift/object-server/object-server-replicator.conf', '/etc/swift/object-server/object-server.conf') }}"
execstarts: >-
{{ swift_bin }}/swift-object-auditor {{ swift_dedicated_replication | ternary(
'/etc/swift/object-server/object-server-replicator.conf', '/etc/swift/object-server/object-server.conf'
) }}
init_config_overrides: "{{ swift_object_auditor_init_overrides }}"
start_order: 16
swift-object-expirer:
@ -467,13 +488,19 @@ swift_services:
swift-object-reconstructor:
group: swift_obj
service_name: "swift-object-reconstructor"
execstarts: "{{ swift_bin }}/swift-object-reconstructor {{ swift_dedicated_replication | ternary('/etc/swift/object-server/object-server-replicator.conf', '/etc/swift/object-server/object-server.conf') }}"
execstarts: >-
{{ swift_bin }}/swift-object-reconstructor {{ swift_dedicated_replication | ternary(
'/etc/swift/object-server/object-server-replicator.conf', '/etc/swift/object-server/object-server.conf'
) }}
init_config_overrides: "{{ swift_object_reconstructor_init_overrides }}"
start_order: 18
swift-object-replicator:
group: swift_obj
service_name: "swift-object-replicator"
execstarts: "{{ swift_bin }}/swift-object-replicator {{ swift_dedicated_replication | ternary('/etc/swift/object-server/object-server-replicator.conf', '/etc/swift/object-server/object-server.conf') }}"
execstarts: >-
{{ swift_bin }}/swift-object-replicator {{ swift_dedicated_replication | ternary(
'/etc/swift/object-server/object-server-replicator.conf', '/etc/swift/object-server/object-server.conf'
) }}
init_config_overrides: "{{ swift_object_replicator_init_overrides }}"
start_order: 19
swift-object-updater:
@ -495,7 +522,7 @@ swift_pretend_min_part_hours_passed: False
swift_pypy_enabled: false
swift_pypy_archive:
url: "https://bitbucket.org/pypy/pypy/downloads/pypy2-v5.9.0-linux64.tar.bz2"
sha256: "790febd4f09e22d6e2f81154efc7dc4b2feec72712aaf4f82aa91b550abb4b48"
checksum: "sha256:790febd4f09e22d6e2f81154efc7dc4b2feec72712aaf4f82aa91b550abb4b48"
swift_pypy_version: "{{ swift_pypy_archive['url'] | basename | replace('.tar.bz2', '') }}"
swift_pypy_env: "/opt/pypy-runtime/{{ swift_pypy_version }}/bin/pypy"
# Set the Garbage Collection (GC) options for pypy if you would like to tune these
@ -569,5 +596,5 @@ swift_pki_install_certificates:
mode: "0600"
# Define user-provided SSL certificates
#swift_user_ssl_cert: <path to cert on ansible deployment host>
#swift_user_ssl_key: <path to cert on ansible deployment host>
# swift_user_ssl_cert: <path to cert on ansible deployment host>
# swift_user_ssl_key: <path to cert on ansible deployment host>

View File

@ -18,19 +18,21 @@ galaxy_info:
description: Installation and setup of swift
company: Rackspace
license: Apache2
min_ansible_version: 2.4
role_name: os_swift
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
- swift

View File

@ -44,60 +44,69 @@
- always
# Check the swift_hash_path_* variables haven't changed
- import_tasks: swift_check_hashes.yml
- name: Importing swift_check_hashes tasks
import_tasks: swift_check_hashes.yml
when:
- "not swift_force_change_hashes | bool"
tags:
- swift-config
- import_tasks: swift_pre_install.yml
- name: Importing swift_pre_install tasks
import_tasks: swift_pre_install.yml
when:
- "swift_do_setup | bool"
- "'swift_all' in group_names"
tags:
- swift-install
- import_tasks: swift_install.yml
- name: Importing swift_install tasks
import_tasks: swift_install.yml
when:
- "swift_do_setup | bool"
- "'swift_all' in group_names"
tags:
- swift-install
- import_tasks: swift_post_install.yml
- name: Importing swift_post_install tasks
import_tasks: swift_post_install.yml
when:
- "swift_do_setup | bool"
- "'swift_all' in group_names"
tags:
- swift-config
- import_tasks: swift_calculate_addresses.yml
- name: Importing swift_calculate_addresses tasks
import_tasks: swift_calculate_addresses.yml
when:
- "'swift_hosts' in group_names"
tags:
- always
- import_tasks: swift_storage_hosts.yml
- name: Importing swift_storage_hosts tasks
import_tasks: swift_storage_hosts.yml
when:
- "swift_do_setup | bool"
- "'swift_hosts' in group_names"
tags:
- swift-config
- import_tasks: swift_proxy_hosts.yml
- name: Importing swift_proxy_hosts tasks
import_tasks: swift_proxy_hosts.yml
when:
- "swift_do_setup | bool"
- "'swift_proxy' in group_names"
tags:
- swift-config
- import_tasks: swift_key_setup.yml
- name: Importing swift_key_setup tasks
import_tasks: swift_key_setup.yml
when:
- "swift_do_sync | bool"
tags:
- swift-config
- import_tasks: swift_rings.yml
- name: Importing swift_rings tasks
import_tasks: swift_rings.yml
when:
- "swift_do_sync | bool"
tags:
@ -113,10 +122,10 @@
systemd_tempd_prefix: openstack
systemd_slice_name: "{{ swift_system_slice_name }}"
systemd_lock_dir: "{{ swift_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: |-
{% set services = [] %}
{% for service in filtered_swift_services %}
@ -137,7 +146,8 @@
- swift-config
- systemd-service
- include_role:
- name: Including osa.mq_setup role
include_role:
name: openstack.osa.mq_setup
apply:
tags:
@ -155,7 +165,8 @@
tags:
- always
- include_role:
- name: Including osa.service_setup roled
include_role:
name: openstack.osa.service_setup
apply:
tags:

View File

@ -20,6 +20,7 @@
- name: Get value of swift_hash_path_suffix from file
command: "awk '/swift_hash_path_suffix/{ print $3 }' /etc/swift/swift.conf"
changed_when: false
register: swift_conf_hash_path_suffix
when:
- swift_conf.stat.exists | bool
@ -38,6 +39,7 @@
- name: Get value of swift_hash_path_prefix from file
command: "awk '/swift_hash_path_prefix/{ print $3 }' /etc/swift/swift.conf"
changed_when: false
register: swift_conf_hash_path_prefix
when:
- swift_conf.stat.exists | bool

View File

@ -19,6 +19,7 @@
section: "swift"
option: "install_method"
value: "{{ swift_install_method }}"
mode: "0644"
- name: Refresh local facts to ensure the swift section is present
setup:
@ -52,5 +53,6 @@
value: "{{ swift_venv_tag }}"
when: swift_install_method == 'source'
- include_tasks: swift_pypy_setup.yml
- name: Including swift_pypy_setup tasks
include_tasks: swift_pypy_setup.yml
when: swift_pypy_enabled | bool

View File

@ -21,4 +21,4 @@
- name: Register a fact for the swift pub key
set_fact:
swift_pubkey: "{{ swift_pub.content }}"
swift_pubkey: "{{ swift_pub.content }}"

View File

@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- include_tasks: swift_key_populate.yml
- name: Including swift_key_populate tasks
include_tasks: swift_key_populate.yml
- include_tasks: swift_key_distribute.yml
- name: Including swift_key_distribute tasks
include_tasks: swift_key_distribute.yml

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: "{{ swift_system_group_name }}"
state: "present"
@ -44,9 +44,9 @@
file:
path: "{{ item.path }}"
state: directory
owner: "{{ item.owner|default(swift_system_user_name) }}"
group: "{{ item.group|default(swift_system_group_name) }}"
mode: "{{ item.mode|default('0755') }}"
owner: "{{ item.owner | default(swift_system_user_name) }}"
group: "{{ item.group | default(swift_system_group_name) }}"
mode: "{{ item.mode | default('0755') }}"
with_items:
- { path: "/openstack/venvs", owner: "root", group: "root" }
- { path: "/etc/swift" }

View File

@ -33,7 +33,7 @@
tags:
- always
- name: swift proxy server configuration
- name: Swift proxy server configuration
openstack.config_template.config_template:
src: "proxy-server.conf.j2"
dest: "/etc/swift/proxy-server/proxy-server.conf"

View File

@ -16,14 +16,16 @@
- name: Download pre-built pypy
get_url:
url: "{{ swift_pypy_archive['url'] }}"
sha256sum: "{{ swift_pypy_archive['sha256'] }}"
checksum: "{{ swift_pypy_archive['checksum'] }}"
dest: "/var/cache/{{ swift_pypy_archive['url'] | basename }}"
force: yes
mode: "0644"
- name: Create pypy dir
file:
path: "/opt/pypy-runtime"
state: directory
mode: "0755"
- name: Unarchive pre-built pypy
unarchive:
@ -35,6 +37,7 @@
- name: Setup local pypy
command: "{{ item }}"
changed_when: false
with_items:
- "{{ swift_pypy_env }} /opt/get-pip.py"
- "{{ swift_pypy_env | dirname }}/pip install --upgrade virtualenv"
@ -62,7 +65,7 @@
virtualenv_command: "{{ swift_pypy_env | dirname }}/virtualenv"
extra_args: >-
{{ swift_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }}
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }}
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''), '') }}
{{ pip_install_options | default('') }}
register: install_packages
until: install_packages is success
@ -75,3 +78,4 @@
file:
path: "{{ swift_bin | dirname }}/{{ swift_pypy_version }}-inuse"
state: "touch"
mode: "0644"

View File

@ -13,17 +13,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- include_tasks: swift_rings_md5sum.yml
- name: Including swift_rings_md5sum tasks
include_tasks: swift_rings_md5sum.yml
- include_tasks: swift_rings_check.yml
- name: Including swift_rings_check tasks
include_tasks: swift_rings_check.yml
when: _swift_is_first_play_host
- include_tasks: swift_rings_build.yml
- name: Including swift_rings_build tasks
include_tasks: swift_rings_build.yml
when: _swift_is_first_play_host
- include_tasks: swift_rings_distribute.yml
- name: Including swift_rings_distribute tasks
include_tasks: swift_rings_distribute.yml
- include_tasks: swift_rings_md5sum.yml
- name: Including swift_rings_md5sum tasks
include_tasks: swift_rings_md5sum.yml
- include_tasks: swift_rings_post_distribution_check.yml
- name: Including swift_rings_post_distribution_check tasks
include_tasks: swift_rings_post_distribution_check.yml
when: _swift_is_first_play_host

View File

@ -29,6 +29,7 @@
dest: "/etc/swift/scripts/{{ item.type }}.contents"
owner: "{{ swift_system_user_name }}"
group: "{{ swift_system_group_name }}"
mode: "0640"
with_items:
- { item: "{{ swift.account | default({}) }}", port: "{{ swift_account_port }}", type: "account" }
- { item: "{{ swift.container | default({}) }}", port: "{{ swift_container_port }}", type: "container" }
@ -39,6 +40,7 @@
dest: "/etc/swift/scripts/object-{{ item[0].policy.index }}.contents"
owner: "{{ swift_system_user_name }}"
group: "{{ swift_system_group_name }}"
mode: "0640"
with_nested:
- "{{ swift.storage_policies }}"
- [{ type: 'object', port: "{{ swift_object_port }}" }]
@ -53,9 +55,11 @@
when: swift_install_method == 'distro'
- name: "Build rings for account/container from contents files"
command: "/etc/swift/scripts/swift_rings.py -f /etc/swift/scripts/{{ item[0] }}.contents{% if item[1] %} -r {{ item[1] }}{% endif %}{{ (swift_pretend_min_part_hours_passed | bool) | ternary(' -p', '') }}"
command: >-
/etc/swift/scripts/swift_rings.py -f /etc/swift/scripts/{{ item[0] }}.contents{% if item[1] %} -r {{ item[1] }}{% endif %}{{
(swift_pretend_min_part_hours_passed | bool) | ternary(' -p', '') }}
with_nested:
- [ 'account', 'container' ]
- ['account', 'container']
- "{{ swift_managed_regions | default([None]) }}"
register: swift_rings_create
become: yes
@ -66,7 +70,9 @@
chdir: /etc/swift/ring_build_files/
- name: "Build rings for storage policies from contents files"
command: "/etc/swift/scripts/swift_rings.py -f /etc/swift/scripts/object-{{ item[0].policy.index }}.contents{% if item[1] %} -r {{ item[1] }}{% endif %}{{ (swift_pretend_min_part_hours_passed | bool) | ternary(' -p', '') }}"
command: >-
/etc/swift/scripts/swift_rings.py -f /etc/swift/scripts/object-{{ item[0].policy.index }}.contents{%
if item[1] %} -r {{ item[1] }}{% endif %}{{ (swift_pretend_min_part_hours_passed | bool) | ternary(' -p', '') }}
with_nested:
- "{{ swift.storage_policies }}"
- "{{ swift_managed_regions | default([None]) }}"

View File

@ -43,7 +43,7 @@
command: "/etc/swift/scripts/swift_rings_check.py -f /etc/swift/scripts/{{ item[0] }}.contents{% if item[1] %} -r {{ item[1] }} {% endif %}"
changed_when: false
with_nested:
- [ 'account', 'container' ]
- ['account', 'container']
- "{{ swift_managed_regions | default([None]) }}"
become: yes
become_user: "{{ swift_system_user_name }}"
@ -51,7 +51,8 @@
chdir: /etc/swift/ring_build_files/
- name: "Ensure contents file matches ring after ring sync for storage policies"
command: "/etc/swift/scripts/swift_rings_check.py -f /etc/swift/scripts/object-{{ item[0].policy.index }}.contents{% if item[1] %} -r {{ item[1] }} {% endif %}"
command: >-
/etc/swift/scripts/swift_rings_check.py -f /etc/swift/scripts/object-{{ item[0].policy.index }}.contents{% if item[1] %} -r {{ item[1] }} {% endif %}
changed_when: false
with_nested:
- "{{ swift.storage_policies }}"

View File

@ -13,7 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- include_tasks: swift_storage_hosts_setup.yml
- include_tasks: swift_storage_hosts_object.yml
- include_tasks: swift_storage_hosts_account.yml
- include_tasks: swift_storage_hosts_container.yml
- name: Including swift_storage_hosts_setup tasks
include_tasks: swift_storage_hosts_setup.yml
- name: Including swift_storage_hosts_object tasks
include_tasks: swift_storage_hosts_object.yml
- name: Including swift_storage_hosts_account tasks
include_tasks: swift_storage_hosts_account.yml
- name: Including swift_storage_hosts_container tasks
include_tasks: swift_storage_hosts_container.yml

View File

@ -66,4 +66,5 @@
owner: "{{ swift_system_user_name }}"
group: "{{ swift_system_group_name }}"
state: "directory"
with_items: "{{ swift_vars.drives| default(swift.drives) | default([]) }}"
mode: "0755"
with_items: "{{ swift_vars.drives | default(swift.drives) | default([]) }}"

View File

@ -13,8 +13,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
_swift_proxy_is_first_play_host: "{{ (swift_services['swift-proxy-server']['group'] in group_names and inventory_hostname == (groups[swift_services['swift-proxy-server']['group']] | intersect(ansible_play_hosts)) | first) | bool }}"
_swift_is_first_play_host: "{{ ('swift_hosts' in group_names and inventory_hostname == (groups['swift_hosts'] | intersect(ansible_play_hosts)) | first) | bool }}"
_swift_proxy_is_first_play_host: >-
{{
(swift_services['swift-proxy-server']['group'] in group_names and
inventory_hostname == (groups[swift_services['swift-proxy-server']['group']] | intersect(ansible_play_hosts)) | first) | bool
}}
_swift_is_first_play_host: >-
{{ ('swift_hosts' in group_names and inventory_hostname == (groups['swift_hosts'] | intersect(ansible_play_hosts)) | first) | bool }}
filtered_swift_services: |-
{% set services = [] %}