Fix linters issue 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.

Change-Id: I6a9986cd948dbeaf2847ea4dd04deed974f80d20
This commit is contained in:
Dmitriy Rabotyagov 2023-07-11 21:43:23 +02:00
parent d2a3a22a58
commit 3cdcb1115f
9 changed files with 47 additions and 29 deletions

View File

@ -164,7 +164,7 @@ lxc_container_enable_resolved: true
# "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}-container.yml" # "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}-container.yml"
# or by providing the full path to a local file containing all of the variables # or by providing the full path to a local file containing all of the variables
# needed to prepare a container. # needed to prepare a container.
#lxc_user_defined_container: null # lxc_user_defined_container: null
# Dictionary of settings for containers # Dictionary of settings for containers
properties: {} properties: {}

View File

@ -43,6 +43,7 @@
--logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log --logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log
--logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }} --logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }}
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
changed_when: false
register: container_start register: container_start
until: container_start is success until: container_start is success
retries: 3 retries: 3

View File

@ -18,19 +18,21 @@ galaxy_info:
description: Create an LXC container description: Create an LXC container
company: Rackspace company: Rackspace
license: Apache2 license: Apache2
min_ansible_version: 2.4 min_ansible_version: "2.10"
role_name: lxc_containers_create
namespace: openstack
platforms: platforms:
- name: Debian - name: Debian
versions: versions:
- buster - bullseye
- name: Ubuntu - name: Ubuntu
versions: versions:
- bionic
- focal - focal
- jammy
- name: EL - name: EL
versions: versions:
- 8 - "9"
categories: galaxy_tags:
- cloud - cloud
- lxc - lxc
- container - container

View File

@ -38,6 +38,7 @@
file: file:
path: "{{ item['host_directory'] }}" path: "{{ item['host_directory'] }}"
state: "directory" state: "directory"
mode: "0755"
with_items: "{{ lxc_container_default_bind_mounts | union(_lxc_container_bind_mounts) | union(lxc_container_bind_mounts) }}" with_items: "{{ lxc_container_default_bind_mounts | union(_lxc_container_bind_mounts) | union(lxc_container_bind_mounts) }}"
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
@ -126,7 +127,7 @@
# NOTE(cloudnull): To dynamically set the mac address "facts" Ansible line # NOTE(cloudnull): To dynamically set the mac address "facts" Ansible line
# format is being used # format is being used
- name: Set fixed hardware address fact - name: Set fixed hardware address fact
set_fact: "{{ item.item.value.interface }}_mac_address={{ item.content | b64decode }}" set_fact: "{{ item.item.value.interface }}_mac_address={{ item.content | b64decode }}" # noqa: no-free-form
with_items: with_items:
- "{{ macs.results }}" - "{{ macs.results }}"
@ -210,7 +211,8 @@
changed_when: wiring_script.rc == 3 changed_when: wiring_script.rc == 3
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
- include_tasks: "lxc_container_network.yml" - name: Including lxc_container_network tasks
include_tasks: "lxc_container_network.yml"
# VETH AND CONNECTIVITY SETTINGS # VETH AND CONNECTIVITY SETTINGS
@ -263,6 +265,7 @@
file: file:
path: "/var/lib/dbus" path: "/var/lib/dbus"
state: "directory" state: "directory"
mode: "0755"
- name: Create dbus machine-id - name: Create dbus machine-id
copy: copy:
@ -310,6 +313,7 @@
file: file:
path: /etc/ansible/facts.d/ path: /etc/ansible/facts.d/
state: directory state: directory
mode: "0755"
tags: tags:
- always - always
@ -319,6 +323,7 @@
section: lxc section: lxc
option: variant option: variant
value: "{{ properties['lxc_container_variant'] | default(lxc_container_variant) }}" value: "{{ properties['lxc_container_variant'] | default(lxc_container_variant) }}"
mode: "0644"
tags: tags:
- always - always
# SET CONTAINER FACTS # SET CONTAINER FACTS

View File

@ -17,6 +17,7 @@
file: file:
path: "{{ item }}" path: "{{ item }}"
state: "directory" state: "directory"
mode: "0755"
with_items: with_items:
- "/openstack/{{ inventory_hostname }}" - "/openstack/{{ inventory_hostname }}"
- "/openstack/backup/{{ inventory_hostname }}" - "/openstack/backup/{{ inventory_hostname }}"
@ -34,7 +35,8 @@
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
# Run the lxc container creation process based on the backend store type # Run the lxc container creation process based on the backend store type
- include_tasks: "lxc_container_create_{{ lxc_container_backing_store }}.yml" - name: "Including lxc_container_create tasks for {{ lxc_container_backing_store }}"
include_tasks: "lxc_container_create_{{ lxc_container_backing_store }}.yml"
- name: Check container state - name: Check container state
command: "lxc-info -n {{ inventory_hostname }} --state" command: "lxc-info -n {{ inventory_hostname }} --state"
@ -58,6 +60,7 @@
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
register: _lxc_container_create register: _lxc_container_create
until: _lxc_container_create is success until: _lxc_container_create is success
changed_when: false
retries: 3 retries: 3
delay: 5 delay: 5
when: when:

View File

@ -37,6 +37,7 @@
--logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log --logfile {{ lxc_container_log_path }}/lxc-{{ inventory_hostname }}.log
--logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }} --logpriority {{ (debug | bool) | ternary('DEBUG', 'INFO') }}
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
changed_when: false
when: when:
- lxc_container_info.rc != 0 - lxc_container_info.rc != 0

View File

@ -31,6 +31,7 @@
- lxc_container_backing_store == 'lvm' - lxc_container_backing_store == 'lvm'
- lxc_container_backing_method != 'copy-on-write' - lxc_container_backing_method != 'copy-on-write'
- include_tasks: lxc_container_create_cow.yml - name: Including lxc_container_create_cow tasks
include_tasks: lxc_container_create_cow.yml
when: when:
- lxc_container_backing_method == 'copy-on-write' - lxc_container_backing_method == 'copy-on-write'

View File

@ -18,6 +18,7 @@
file: file:
path: /etc/ansible/facts.d/ path: /etc/ansible/facts.d/
state: directory state: directory
mode: "0755"
delegate_to: "{{ physical_host }}" delegate_to: "{{ physical_host }}"
tags: tags:
- always - always
@ -39,38 +40,42 @@
# NOTE(cloudnull): Check for the LXC volume group when creating LVM backed # NOTE(cloudnull): Check for the LXC volume group when creating LVM backed
# containers. # containers.
- block: - name: Verify LVM VG
- name: Check for lxc volume group block:
shell: "(which vgs > /dev/null && vgs | grep -o '{{ lxc_container_vg_name }}') || false" - name: Check for lxc volume group
register: vg_result shell: "(which vgs > /dev/null && vgs | grep -o '{{ lxc_container_vg_name }}') || false"
failed_when: false register: vg_result
changed_when: vg_result.rc != 0 failed_when: false
delegate_to: "{{ physical_host }}" changed_when: vg_result.rc != 0
- name: LXC VG check delegate_to: "{{ physical_host }}"
fail: - name: LXC VG check
msg: >- fail:
The "lxc_container_backing_store" option was set to "lvm" but no LXC msg: >-
volume group was found on the physical host. Please check your settings The "lxc_container_backing_store" option was set to "lvm" but no LXC
and host setup. volume group was found on the physical host. Please check your settings
when: and host setup.
- vg_result.rc != 0 when:
- vg_result.rc != 0
when: when:
- lxc_container_backing_store == 'lvm' - lxc_container_backing_store == 'lvm'
tags: tags:
- always - always
- include_tasks: lxc_container_destroy.yml - name: Including lxc_container_destroy tasks
include_tasks: lxc_container_destroy.yml
when: when:
- physical_host != inventory_hostname - physical_host != inventory_hostname
- lxc_container_recreate | bool - lxc_container_recreate | bool
- include_tasks: lxc_container_create.yml - name: Including lxc_container_create tasks
include_tasks: lxc_container_create.yml
when: when:
- physical_host != inventory_hostname - physical_host != inventory_hostname
tags: tags:
- lxc-create - lxc-create
- include_tasks: lxc_container_config.yml - name: Including lxc_container_config tasks
include_tasks: lxc_container_config.yml
when: when:
- physical_host != inventory_hostname - physical_host != inventory_hostname
tags: tags:

View File

@ -15,7 +15,7 @@
lxc_container_map: lxc_container_map:
distro: "{{ hostvars[physical_host]['ansible_facts']['distribution'] | lower }}" distro: "{{ hostvars[physical_host]['ansible_facts']['distribution'] | lower }}"
arch: "{{ lxc_architecture_mapping.get( hostvars[physical_host]['ansible_facts']['architecture'] | lower ) }}" arch: "{{ lxc_architecture_mapping.get(hostvars[physical_host]['ansible_facts']['architecture'] | lower) }}"
release: "{{ hostvars[physical_host]['ansible_facts']['distribution_major_version'] }}" release: "{{ hostvars[physical_host]['ansible_facts']['distribution_major_version'] }}"
lxc_container_default_config_list: lxc_container_default_config_list: