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"
# or by providing the full path to a local file containing all of the variables
# needed to prepare a container.
#lxc_user_defined_container: null
# lxc_user_defined_container: null
# Dictionary of settings for containers
properties: {}

View File

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

View File

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

View File

@ -38,6 +38,7 @@
file:
path: "{{ item['host_directory'] }}"
state: "directory"
mode: "0755"
with_items: "{{ lxc_container_default_bind_mounts | union(_lxc_container_bind_mounts) | union(lxc_container_bind_mounts) }}"
delegate_to: "{{ physical_host }}"
@ -126,7 +127,7 @@
# NOTE(cloudnull): To dynamically set the mac address "facts" Ansible line
# format is being used
- 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:
- "{{ macs.results }}"
@ -210,7 +211,8 @@
changed_when: wiring_script.rc == 3
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
@ -263,6 +265,7 @@
file:
path: "/var/lib/dbus"
state: "directory"
mode: "0755"
- name: Create dbus machine-id
copy:
@ -310,6 +313,7 @@
file:
path: /etc/ansible/facts.d/
state: directory
mode: "0755"
tags:
- always
@ -319,6 +323,7 @@
section: lxc
option: variant
value: "{{ properties['lxc_container_variant'] | default(lxc_container_variant) }}"
mode: "0644"
tags:
- always
# SET CONTAINER FACTS

View File

@ -17,6 +17,7 @@
file:
path: "{{ item }}"
state: "directory"
mode: "0755"
with_items:
- "/openstack/{{ inventory_hostname }}"
- "/openstack/backup/{{ inventory_hostname }}"
@ -34,7 +35,8 @@
delegate_to: "{{ physical_host }}"
# 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
command: "lxc-info -n {{ inventory_hostname }} --state"
@ -58,6 +60,7 @@
delegate_to: "{{ physical_host }}"
register: _lxc_container_create
until: _lxc_container_create is success
changed_when: false
retries: 3
delay: 5
when:

View File

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

View File

@ -31,6 +31,7 @@
- lxc_container_backing_store == 'lvm'
- 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:
- lxc_container_backing_method == 'copy-on-write'

View File

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

View File

@ -15,7 +15,7 @@
lxc_container_map:
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'] }}"
lxc_container_default_config_list: