Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ansible-lint issues without rule var-naming[no-role-prefix] on skip_list #574

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ rulesdir:
- ./.ansible-lint-rules/
skip_list:
- galaxy[no-changelog]
- var-naming[no-role-prefix]
- package-latest
# DO NOT DELETE THE WARNLIST
warn_list:
Expand Down
6 changes: 3 additions & 3 deletions molecule/delegated/tests/configuration/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def test_sshkey(host):
f = host.file(f"{path}")
assert f.exists
assert f.is_file
assert f.user == get_variable(host, "operator_user")
assert f.group == get_variable(host, "operator_group")
assert f.user == get_variable(host, "configuration_operator_user")
assert f.group == get_variable(host, "configuration_operator_group")
assert f.mode == 0o600

with host.sudo(get_variable(host, "operator_user")):
with host.sudo(get_variable(host, "configuration_operator_user")):
private_key_content = host.check_output(f"cat {path}")
assert private_key == private_key_content

Expand Down
4 changes: 2 additions & 2 deletions molecule/delegated/tests/configuration/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def check_file_attributes(host, path):
f = host.file(f"{path}")
assert f.exists
assert f.is_directory
assert f.user == get_variable(host, "operator_user")
assert f.group == get_variable(host, "operator_group")
assert f.user == get_variable(host, "configuration_operator_user")
assert f.group == get_variable(host, "configuration_operator_group")
assert f.mode == 0o750


Expand Down
2 changes: 1 addition & 1 deletion molecule/delegated/tests/facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_custom_facts_directory(host):


def test_fact_files(host):
fact_files = get_variable(host, "fact_files")
fact_files = get_variable(host, "facts_files")

assert type(fact_files) is list

Expand Down
2 changes: 1 addition & 1 deletion molecule/delegated/tests/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_firewall_config_file(host):


def test_firewall_service(host):
service_name = get_variable(host, "ufw_service_name")
service_name = get_variable(host, "firewall_service_name")
service = host.service(service_name)

assert service.is_running
Expand Down
4 changes: 2 additions & 2 deletions molecule/delegated/tests/kernel_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def test_kernel_modules_in_etc_modules(host):
kernel_modules_default = get_variable(host, "kernel_modules_default")
kernel_modules_extra = get_variable(host, "kernel_modules_extra")
kernel_modules = get_variable(host, "kernel_modules")
kernel_modules = get_variable(host, "kernel_modules_all")
kernel_modules = jinja_list_concat(
kernel_modules, [kernel_modules_default, kernel_modules_extra]
)
Expand All @@ -21,7 +21,7 @@ def test_kernel_modules_in_etc_modules(host):
def test_loaded_kernel_modules(host):
kernel_modules_default = get_variable(host, "kernel_modules_default")
kernel_modules_extra = get_variable(host, "kernel_modules_extra")
kernel_modules = get_variable(host, "kernel_modules")
kernel_modules = get_variable(host, "kernel_modules_all")
kernel_modules = jinja_list_concat(
kernel_modules, [kernel_modules_default, kernel_modules_extra]
)
Expand Down
10 changes: 5 additions & 5 deletions molecule/delegated/tests/known_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@


def test_known_hosts_file_permissions(host):
operator_user = get_variable(host, "operator_user")
operator_group = get_variable(host, "operator_group")
operator_user = get_variable(host, "known_hosts_operator_user")
operator_group = get_variable(host, "known_hosts_operator_group")

known_hosts_destination = get_variable(host, "known_hosts_destination")
known_hosts_destination = jinja_replacement(
known_hosts_destination, {"operator_user": operator_user}
known_hosts_destination, {"known_hosts_operator_user": operator_user}
)
known_hosts_destination += "/known_hosts"

Expand All @@ -27,11 +27,11 @@ def test_known_hosts_file_permissions(host):


def test_known_hosts_file_content(host):
operator_user = get_variable(host, "operator_user")
operator_user = get_variable(host, "known_hosts_operator_user")

known_hosts_destination = get_variable(host, "known_hosts_destination")
known_hosts_destination = jinja_replacement(
known_hosts_destination, {"operator_user": operator_user}
known_hosts_destination, {"known_hosts_operator_user": operator_user}
)
known_hosts_destination += "/known_hosts"

Expand Down
2 changes: 1 addition & 1 deletion molecule/delegated/tests/motd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_motd_content(host):


def test_issue_content(host):
issue_path = get_variable(host, "issue_path")
issue_path = get_variable(host, "motd_issue_path")
expected_issue_content = get_variable(host, "motd_content")

issue_file = host.file(issue_path)
Expand Down
4 changes: 2 additions & 2 deletions molecule/delegated/tests/packages/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ def check_ansible_os_family(host):
def test_package_upgrade(host):
check_ansible_os_family(host)

upgrade_packages = get_variable(host, "upgrade_packages")
upgrade_packages = get_variable(host, "packages_upgrade")

if not upgrade_packages:
pytest.skip("upgrade_packages is not True")
pytest.skip("packages_upgrade is not True")

upgradable = host.check_output("apt list --upgradable 2>/dev/null | wc -l")
# subtract 1 to account for the header line
Expand Down
8 changes: 4 additions & 4 deletions molecule/delegated/tests/packages/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@


def test_required_packages_installed(host):
required_packages = get_variable(host, "required_packages")
required_packages_default = get_variable(host, "required_packages_default")
required_packages_extra = get_variable(host, "required_packages_extra")
required_packages = get_variable(host, "packages_required")
required_packages_default = get_variable(host, "packages_required_default")
required_packages_extra = get_variable(host, "packages_required_extra")
required_packages_distribution = get_os_role_variable(
host, "required_packages_distribution"
host, "packages_required_distribution"
)

required_packages = jinja_list_concat(
Expand Down
4 changes: 2 additions & 2 deletions molecule/delegated/tests/packages/redhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ def check_ansible_os_family(host):
def test_package_upgrade(host):
check_ansible_os_family(host)

upgrade_packages = get_variable(host, "upgrade_packages")
upgrade_packages = get_variable(host, "packages_upgrade")

if not upgrade_packages:
pytest.skip("upgrade_packages is not True")
pytest.skip("packages_upgrade is not True")

upgradable = host.check_output("dnf list upgrades --quiet | wc -l")
num_upgradable = int(upgradable.strip())
Expand Down
2 changes: 1 addition & 1 deletion molecule/delegated/tests/repository/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_sources(host):
assert f.mode == 0o644
assert "DO NOT EDIT THIS FILE BY HAND" in f.content_string

repositories = get_variable(host, "repositories")
repositories = get_variable(host, "repository_dictionary")

if len(repositories) <= 0:
repositories = get_os_role_variable(host, "repository_default", "Ubuntu.yml")
Expand Down
15 changes: 8 additions & 7 deletions molecule/delegated/tests/sshconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@


def test_sshconfig_directory(host):
operator_user_name = get_variable(host, "operator_user")
operator_user_name = get_variable(host, "sshconfig_operator_user")
operator_user = host.user(operator_user_name)

ssh_config_d = host.file(f"{operator_user.home}/.ssh/config.d")
assert ssh_config_d.is_directory
assert ssh_config_d.user == operator_user_name
assert ssh_config_d.group == get_variable(host, "operator_group")
assert ssh_config_d.group == get_variable(host, "sshconfig_operator_group")
assert ssh_config_d.mode == 0o700


def test_sshconfig_host_files(host):
operator_user_name = get_variable(host, "operator_user")
operator_user_name = get_variable(host, "sshconfig_operator_user")
operator_user = host.user(operator_user_name)
sshconfig_order = get_variable(host, "sshconfig_order")
inventory_hostname_short = get_variable(host, "inventory_hostname").split(".")[0]
Expand All @@ -28,7 +28,8 @@ def test_sshconfig_host_files(host):

with host.sudo(operator_user_name):
sshconfig_user = jinja_replacement(
get_variable(host, "sshconfig_user"), {"operator_user": operator_user_name}
get_variable(host, "sshconfig_user"),
{"sshconfig_operator_user": operator_user_name},
)
config_content = host.check_output(f"cat {config_file_path}")
assert f"Host {inventory_hostname_short}" in config_content
Expand All @@ -41,11 +42,11 @@ def test_sshconfig_host_files(host):


def test_sshconfig_assembled(host):
operator_user_name = get_variable(host, "operator_user")
operator_user_name = get_variable(host, "sshconfig_operator_user")
operator_user = host.user(operator_user_name)

assembled_config = host.file(f"{operator_user.home}/.ssh/config")
assert assembled_config.exists
assert assembled_config.user == get_variable(host, "operator_user")
assert assembled_config.group == get_variable(host, "operator_group")
assert assembled_config.user == get_variable(host, "sshconfig_operator_user")
assert assembled_config.group == get_variable(host, "sshconfig_operator_group")
assert assembled_config.mode == 0o600
2 changes: 1 addition & 1 deletion molecule/delegated/tests/systohc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def test_systohc_sync(host):
"""Check if the system clock is synchronized with the hardware clock."""
# Use the utility function to retrieve the systohc variable
systohc = get_variable(host, "systohc")
systohc = get_variable(host, "systohc_system")

# If systohc is true, then verify synchronization
if not systohc:
Expand Down
4 changes: 2 additions & 2 deletions molecule/delegated/vars/configuration.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
operator_user: zuul
operator_group: zuul
configuration_operator_user: zuul
configuration_operator_group: zuul

configuration_git_port: 443
configuration_git_protocol: https
Expand Down
4 changes: 2 additions & 2 deletions molecule/delegated/vars/known_hosts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
##########################
# operator user

operator_user: zuul
operator_group: zuul
known_hosts_operator_user: zuul
known_hosts_operator_group: zuul

##########################
# known_hosts
Expand Down
4 changes: 2 additions & 2 deletions molecule/delegated/vars/packages.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
apt_cache_valid_time: 0
upgrade_packages: false
packages_apt_cache_valid_time: 0
packages_upgrade: false
4 changes: 2 additions & 2 deletions molecule/delegated/vars/sosreport.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
operator_user: zuul
operator_group: zuul
sosreport_operator_user: zuul
sosreport_operator_group: zuul
4 changes: 2 additions & 2 deletions molecule/delegated/vars/sshconfig.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
operator_user: zuul
operator_group: zuul
sshconfig_operator_user: zuul
sshconfig_operator_group: zuul
2 changes: 1 addition & 1 deletion roles/clevis/tasks/create-tangcrypt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- name: Remove dropbear ssh initramfs packages
become: true
ansible.builtin.apt:
name: "{{ dropbear_packages }}"
name: "{{ clevis_dropbear_packages }}"
state: absent
lock_timeout: "{{ apt_lock_timeout | default(300) }}"
notify:
Expand Down
2 changes: 1 addition & 1 deletion roles/clevis/vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ clevis_packages:
- clevis-initramfs
- clevis-luks

dropbear_packages:
clevis_dropbear_packages:
- dropbear-bin
- dropbear-initramfs
6 changes: 3 additions & 3 deletions roles/configuration/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ Install the configuration directory.

**Generic Role Variables**

.. zuul:rolevar:: operator_user
.. zuul:rolevar:: configuration_operator_user
:default: dragon

The user that will own the configuration directory.

.. zuul:rolevar:: operator_group
:default: "{{ operator_user }}"
.. zuul:rolevar:: configuration_operator_group
:default: "{{ configuration_operator_user }}"

The group that will own the configuration directory.

Expand Down
4 changes: 2 additions & 2 deletions roles/configuration/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
##########################
# generic

operator_user: dragon
operator_group: "{{ operator_user }}"
configuration_operator_user: dragon
configuration_operator_group: "{{ configuration_operator_user }}"

##########################
# generic
Expand Down
4 changes: 2 additions & 2 deletions roles/configuration/tasks/git.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
ansible.builtin.template:
src: config-git-private-key.j2
dest: "{{ configuration_git_private_key_file }}"
owner: "{{ operator_user }}"
group: "{{ operator_group }}"
owner: "{{ configuration_operator_user }}"
group: "{{ configuration_operator_group }}"
mode: 0600
when: (configuration_git_protocol == 'ssh' and configuration_git_private_key is defined and configuration_git_private_key | length)
no_log: true
Expand Down
4 changes: 2 additions & 2 deletions roles/configuration/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
become: true
ansible.builtin.file:
path: "{{ item }}"
owner: "{{ operator_user }}"
group: "{{ operator_group }}"
owner: "{{ configuration_operator_user }}"
group: "{{ configuration_operator_group }}"
state: directory
mode: 0750
with_items:
Expand Down
2 changes: 1 addition & 1 deletion roles/facts/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Install custom ansible facts.

**Role Variables**

.. zuul:rolevar:: fact_files
.. zuul:rolevar:: facts_files

List of facts to install.
2 changes: 1 addition & 1 deletion roles/facts/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
fact_files: []
facts_files: []
2 changes: 1 addition & 1 deletion roles/facts/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
owner: root
group: root
mode: 0755
loop: "{{ fact_files }}"
loop: "{{ facts_files }}"
2 changes: 1 addition & 1 deletion roles/firewall/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
ufw_service_name: ufw
firewall_service_name: ufw
4 changes: 2 additions & 2 deletions roles/firewall/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: "Restart service {{ ufw_service_name }}"
- name: "Restart service {{ firewall_service_name }}"
become: true
ansible.builtin.service:
name: "{{ ufw_service_name }}"
name: "{{ firewall_service_name }}"
state: restarted
6 changes: 3 additions & 3 deletions roles/firewall/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
src: ufw.conf.j2
dest: /etc/ufw/ufw.conf
mode: 0644
notify: "Restart service {{ ufw_service_name }}"
notify: "Restart service {{ firewall_service_name }}"

- name: "Start service {{ ufw_service_name }}"
- name: "Start service {{ firewall_service_name }}"
become: true
ansible.builtin.service:
name: "{{ ufw_service_name }}"
name: "{{ firewall_service_name }}"
state: started
enabled: true
2 changes: 1 addition & 1 deletion roles/kernel_modules/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Default list of kernel modules to install.

List of extra modules to install.

.. zuul:rolevar:: kernel_modules
.. zuul:rolevar:: kernel_modules_all
:default: kernel_modules_default + kernel_modules_extra

All modules which you want to install.
2 changes: 1 addition & 1 deletion roles/kernel_modules/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ kernel_modules_default:
- bonding
- 8021q
kernel_modules_extra: []
kernel_modules: "{{ kernel_modules_default + kernel_modules_extra }}"
kernel_modules_all: "{{ kernel_modules_default + kernel_modules_extra }}"
4 changes: 2 additions & 2 deletions roles/kernel_modules/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
dest: /etc/modules
mode: 0644
state: present
loop: "{{ kernel_modules }}"
loop: "{{ kernel_modules_all }}"

- name: Load kernel module
become: true
community.general.modprobe:
name: "{{ item }}"
state: present
loop: "{{ kernel_modules }}"
loop: "{{ kernel_modules_all }}"
Loading