Skip to content

Commit

Permalink
Merge pull request #590 from ja9fuchs/lint-fixes
Browse files Browse the repository at this point in the history
fix: ansible-lint 6.22
  • Loading branch information
berndfinger authored Jan 12, 2024
2 parents e320dd4 + 7583da3 commit 576e6db
Show file tree
Hide file tree
Showing 31 changed files with 76 additions and 89 deletions.
3 changes: 2 additions & 1 deletion .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ exclude_paths:
#- roles/sap_hana_preconfigure
- roles/sap_hostagent
- roles/sap_hypervisor_node_preconfigure
- roles/sap_install_media_detect
#- roles/sap_install_media_detect
#- roles/sap_netweaver_preconfigure
#- roles/sap_storage_setup
#- roles/sap_swpm
- roles/sap_vm_preconfigure
- tests/

enable_list:
- yaml
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
# types: [file, yaml]
# entry: yamllint --strict
- repo: https://github.com/ansible-community/ansible-lint.git
rev: v6.8.6 # put latest release tag from https://github.com/ansible-community/ansible-lint/releases/
rev: v6.22.1 # put latest release tag from https://github.com/ansible-community/ansible-lint/releases/
hooks:
- id: ansible-lint
files: \.(yaml|yml)$
2 changes: 0 additions & 2 deletions roles/sap_anydb_install_oracle/meta/runtime.yml

This file was deleted.

2 changes: 0 additions & 2 deletions roles/sap_general_preconfigure/meta/runtime.yml

This file was deleted.

3 changes: 3 additions & 0 deletions roles/sap_ha_install_hana_hsr/.ansible-lint
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---
exclude_paths:
- tests/
enable_list:
- yaml
skip_list:
- meta-runtime[unsupported-version] # We don't want to enforce new Ansible versions for Galaxy
- ignore-errors # We use ignore_errors for all the assert tasks, which should be acceptable
- schema # We want to allow single digit version numbers in a role's meta/main.yml file. This is allowed as per https://galaxy.ansible.com/docs/contributing/creating_role.html and https://galaxy.ansible.com/api/v1/platforms/?page=6.
- name[template] # Allow templating inside name. During dev and qa, it should be possible to identify cases where it doesn't work
2 changes: 1 addition & 1 deletion roles/sap_ha_install_hana_hsr/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ sap_ha_install_hana_hsr_fqdn: "{{ sap_domain }}"
sap_ha_install_hana_hsr_rep_mode: sync
sap_ha_install_hana_hsr_oper_mode: logreplay

sap_ha_install_hana_hsr_update_etchosts: yes
sap_ha_install_hana_hsr_update_etchosts: true
2 changes: 0 additions & 2 deletions roles/sap_ha_install_hana_hsr/meta/runtime.yml

This file was deleted.

4 changes: 2 additions & 2 deletions roles/sap_ha_install_hana_hsr/tasks/pki_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

- name: "SAP HSR - Authorize pub key on primary node"
ansible.builtin.lineinfile:
backup: yes
create: yes
backup: true
create: true
line: "{{ __sap_ha_install_hana_hsr_pubkey.stdout }}"
mode: "0600"
path: ~/.ssh/authorized_keys
Expand Down
6 changes: 4 additions & 2 deletions roles/sap_ha_install_hana_hsr/tasks/update_etchosts.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
- name: "SAP HSR - Check /etc/hosts for conflicting entries"
ansible.builtin.shell: |
awk '(/{{ "( |\t)" + item.node_name + "($| |\t)" }}/ && !/^{{ item.node_ip + "( |\t)" }}/) || (/^{{ item.node_ip + "( |\t)" }}/ && !/{{ "( |\t)" + item.node_name + "($| |\t)" }}/)' /etc/hosts
awk '(/{{ "( |\t)" + item.node_name + "($| |\t)" }}/ && !/^{{ item.node_ip + "( |\t)" }}/) \
|| (/^{{ item.node_ip + "( |\t)" }}/ \
&& !/{{ "( |\t)" + item.node_name + "($| |\t)" }}/)' /etc/hosts
register: etchosts_conflict
changed_when: false
failed_when: etchosts_conflict.stdout != ''
Expand All @@ -17,7 +19,7 @@
create: true
mode: '0644'
state: present
backup: yes
backup: true
line: "{{ item.node_ip }}\t{{ item.node_name.split('.')[0] }}.{{ item.node_name.split('.')[1:] | join('.') or sap_ha_install_hana_hsr_fqdn }}\t{{ item.node_name.split('.')[0] }}"
regexp: (?i)^\s*{{ item.node_ip }}\s+{{ item.node_name.split('.')[0] }}
loop: "{{ sap_ha_install_hana_hsr_cluster_nodes }}"
Expand Down
3 changes: 3 additions & 0 deletions roles/sap_ha_pacemaker_cluster/.ansible-lint
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---
exclude_paths:
- tests/
enable_list:
- yaml
skip_list:
- meta-runtime[unsupported-version] # We don't want to enforce new Ansible versions for Galaxy
- ignore-errors # We use ignore_errors for all the assert tasks, which should be acceptable
- schema # We want to allow single digit version numbers in a role's meta/main.yml file. This is allowed as per https://galaxy.ansible.com/docs/contributing/creating_role.html and https://galaxy.ansible.com/api/v1/platforms/?page=6.
- name[template] # Allow templating inside name. During dev and qa, it should be possible to identify cases where it doesn't work
2 changes: 0 additions & 2 deletions roles/sap_ha_pacemaker_cluster/meta/runtime.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ansible.builtin.assert:
that:
- sap_ha_pacemaker_cluster_hana_sid | length == 3
- sap_ha_pacemaker_cluster_hana_sid not in __sap_sid_prohibited
- sap_ha_pacemaker_cluster_hana_sid not in __sap_ha_pacemaker_cluster_sid_prohibited
fail_msg: |
Host type = {{ sap_ha_pacemaker_cluster_host_type }}
Requires 'sap_ha_pacemaker_cluster_hana_sid' to be defined!
Expand Down Expand Up @@ -37,7 +37,7 @@
ansible.builtin.assert:
that:
- sap_ha_pacemaker_cluster_nwas_abap_sid | length == 3
- sap_ha_pacemaker_cluster_nwas_abap_sid not in __sap_sid_prohibited
- sap_ha_pacemaker_cluster_nwas_abap_sid not in __sap_ha_pacemaker_cluster_sid_prohibited
fail_msg: |
Host type = {{ sap_ha_pacemaker_cluster_host_type }}
Requires 'sap_ha_pacemaker_cluster_nwas_abap_sid' to be defined!
Expand Down
18 changes: 9 additions & 9 deletions roles/sap_ha_pacemaker_cluster/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
# SAP System IDs that are reserved and must not be used
# Reference: SAP Note 1979280
__sap_sid_prohibited: ['ADD', 'ADM', 'ALL', 'AMD', 'AND', 'ANY', 'ARE', 'ASC',
'AUX', 'AVG', 'BIN', 'BIT', 'CDC', 'COM', 'CON', 'DAA',
'DBA', 'DBM', 'DBO', 'DTD', 'ECO', 'END', 'EPS', 'EXE',
'FOR', 'GET', 'GID', 'IBM', 'INT', 'KEY', 'LIB', 'LOG',
'LPT', 'MAP', 'MAX', 'MEM', 'MIG', 'MIN', 'MON', 'NET',
'NIX', 'NOT', 'NUL', 'OFF', 'OLD', 'OMS', 'OUT', 'PAD',
'PRN', 'RAW', 'REF', 'ROW', 'SAP', 'SET', 'SGA', 'SHG',
'SID', 'SQL', 'SUM', 'SYS', 'TMP', 'TOP', 'TRC', 'UID',
'USE', 'USR', 'VAR']
__sap_ha_pacemaker_cluster_sid_prohibited: ['ADD', 'ADM', 'ALL', 'AMD', 'AND', 'ANY', 'ARE', 'ASC',
'AUX', 'AVG', 'BIN', 'BIT', 'CDC', 'COM', 'CON', 'DAA',
'DBA', 'DBM', 'DBO', 'DTD', 'ECO', 'END', 'EPS', 'EXE',
'FOR', 'GET', 'GID', 'IBM', 'INT', 'KEY', 'LIB', 'LOG',
'LPT', 'MAP', 'MAX', 'MEM', 'MIG', 'MIN', 'MON', 'NET',
'NIX', 'NOT', 'NUL', 'OFF', 'OLD', 'OMS', 'OUT', 'PAD',
'PRN', 'RAW', 'REF', 'ROW', 'SAP', 'SET', 'SGA', 'SHG',
'SID', 'SQL', 'SUM', 'SYS', 'TMP', 'TOP', 'TRC', 'UID',
'USE', 'USR', 'VAR']

# ansible_facts required by the role
__sap_ha_pacemaker_cluster_required_facts:
Expand Down
2 changes: 0 additions & 2 deletions roles/sap_hana_install/meta/runtime.yml

This file was deleted.

2 changes: 0 additions & 2 deletions roles/sap_hana_preconfigure/meta/runtime.yml

This file was deleted.

2 changes: 0 additions & 2 deletions roles/sap_hostagent/meta/runtime.yml

This file was deleted.

2 changes: 0 additions & 2 deletions roles/sap_hypervisor_node_preconfigure/meta/runtime.yml

This file was deleted.

2 changes: 0 additions & 2 deletions roles/sap_install_media_detect/meta/runtime.yml

This file was deleted.

2 changes: 0 additions & 2 deletions roles/sap_maintain_etc_hosts/meta/runtime.yml

This file was deleted.

2 changes: 0 additions & 2 deletions roles/sap_netweaver_preconfigure/meta/runtime.yml

This file was deleted.

3 changes: 3 additions & 0 deletions roles/sap_storage_setup/.ansible-lint
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---
exclude_paths:
- tests/
enable_list:
- yaml
skip_list:
- meta-runtime[unsupported-version] # We don't want to enforce new Ansible versions for Galaxy
- ignore-errors # We use ignore_errors for all the assert tasks, which should be acceptable
- schema # We want to allow single digit version numbers in a role's meta/main.yml file. This is allowed as per https://galaxy.ansible.com/docs/contributing/creating_role.html and https://galaxy.ansible.com/api/v1/platforms/?page=6.
- name[template] # Allow templating inside name. During dev and qa, it should be possible to identify cases where it doesn't work
16 changes: 8 additions & 8 deletions roles/sap_storage_setup/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,23 @@ sap_storage_setup_cloud_type: 'generic'

# Azure variables

sap_storage_az_imds_json:
sap_storage_az_imds_url: 'http://169.254.169.254/metadata/instance/compute?api-version=2020-09-01'
sap_storage_az_vmsize_url: 'http://169.254.169.254/metadata/instance/compute/vmSize?api-version=2017-08-01&format=text'
sap_storage_setup_az_imds_json:
sap_storage_setup_az_imds_url: 'http://169.254.169.254/metadata/instance/compute?api-version=2020-09-01'
sap_storage_setup_az_vmsize_url: 'http://169.254.169.254/metadata/instance/compute/vmSize?api-version=2017-08-01&format=text'

sap_storage_az_vmsize:
sap_storage_setup_az_vmsize:

sap_storage_az_lun: '/dev/disk/azure/scsi1/lun'
sap_storage_setup_az_lun: '/dev/disk/azure/scsi1/lun'

# AWS variables

# should probably put into a platform specific vars file, to be included and overwriting the default
#sap_storage_setup_aws_nfs_options: 'nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport,acl'

sap_storage_aws_imds_url:
sap_storage_aws_vmsize_url:
sap_storage_setup_aws_imds_url:
sap_storage_setup_aws_vmsize_url:

sap_storage_aws_vmsize:
sap_storage_setup_aws_vmsize:

# IBM Cloud variables
#
2 changes: 0 additions & 2 deletions roles/sap_storage_setup/meta/runtime.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- name: SAP Storage Setup - (swap file) Allocate space
ansible.builtin.shell: |
fallocate -l {{ swap_file.disk_size | int * 1024 }}MB {{ swap_file.swap_path }}
changed_when: true
when:
- not check_swapfile.stat.exists

Expand All @@ -41,6 +42,7 @@
ansible.builtin.shell: |
mkswap {{ swap_file.swap_path }}
swapon {{ swap_file.swap_path }}
changed_when: true
when:
- not check_swapfile.stat.exists

Expand Down Expand Up @@ -80,7 +82,7 @@

- name: SAP Storage Setup - Check if swap partition exists
ansible.builtin.shell: |
lsblk | grep SWAP || echo "no active swap"
set -o pipefail && lsblk | grep SWAP || echo "no active swap"
register: check_swap_partition
changed_when: false

Expand All @@ -95,6 +97,7 @@
- name: SAP Storage Setup - Enable swap
ansible.builtin.shell: |
swapon /dev/{{ swap_volume.lvm_vg_name | default('vg_swap') }}/{{ swap_volume.lvm_lv_name | default('lv_swap') }}
changed_when: true
when:
- not ansible_check_mode
- swap_volume.lvm_lv_name | default("lv_swap") not in check_swap_partition.stdout
Expand Down
10 changes: 5 additions & 5 deletions roles/sap_storage_setup/tasks/generic_tasks/remove_storage.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
---

## Unmount Filesystem
#- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }} Unmount Filesystem
#- name: SAP Storage Preparation - {{ sap_storage_setup_cloud_type | upper }} - {{ item.value.name }} Unmount Filesystem
# mount:
# path: "{{ item.value.directory }}"
# state: absent
#
## INFO:
## this only works right using community Ansible Galaxy filesystem module
## only interested with native Ansible modules for now
## - name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }} Filesystem
## - name: SAP Storage Preparation - {{ sap_storage_setup_cloud_type | upper }} - {{ item.value.name }} Filesystem
## filesystem:
## dev: "/dev/mapper/{{ item.value.vg }}/{{ item.value.lv }}"
## state: absent
#
## Remove Filesystem
#- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }} Remove Filesystem
#- name: SAP Storage Preparation - {{ sap_storage_setup_cloud_type | upper }} - {{ item.value.name }} Remove Filesystem
# shell: |
# /sbin/wipefs --all -f /dev/mapper/{{ item.value.vg }}-{{ item.value.lv }}
# ignore_errors: yes
#
## Remove Logical Volume
#- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }} Remove Logical Volume
#- name: SAP Storage Preparation - {{ sap_storage_setup_cloud_type | upper }} - {{ item.value.name }} Remove Logical Volume
# lvol:
# lv: "{{ item.value.lv }}"
# vg: "{{ item.value.vg }}"
# state: absent
# force: yes
#
## Remove Volume Group
#- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - {{ item.value.name }} Remove Volume Group
#- name: SAP Storage Preparation - {{ sap_storage_setup_cloud_type | upper }} - {{ item.value.name }} Remove Volume Group
# lvg:
# vg: "{{ item.value.vg }}"
# state: absent
Expand Down
6 changes: 3 additions & 3 deletions roles/sap_storage_setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
label: "{{ new_mounts_item.name }}"


# TODO: Cloud Specific Pre-Tasks - call cloud specific pre tasks thru {{ sap_storage_cloud_type }}_main.yml
#- name: SAP Storage Setup - Preparation for '{{ sap_storage_cloud_type }}'
# include_tasks: "{{ sap_storage_cloud_type }}_main.yml"
# TODO: Cloud Specific Pre-Tasks - call cloud specific pre tasks thru {{ sap_storage_setup_cloud_type }}_main.yml
#- name: SAP Storage Setup - Preparation for '{{ sap_storage_setup_cloud_type }}'
# include_tasks: "{{ sap_storage_setup_cloud_type }}_main.yml"

# TODO: verify that the number of disks matches the fs definition
# TODO: add functionality to work with existing LVM volumes and skip disk assignment
Expand Down
16 changes: 8 additions & 8 deletions roles/sap_storage_setup/tasks/platform_tasks/az_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@

## Create json format of IMDS
## Todo: Ansibilize this
#- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - Create json format of IMDS
#- name: SAP Storage Preparation - {{ sap_storage_setup_cloud_type | upper }} - Create json format of IMDS
# shell: |
# curl -H Metadata:true --noproxy "*" "{{ sap_storage_az_imds_url }}" | python3 -mjson.tool
# curl -H Metadata:true --noproxy "*" "{{ sap_storage_setup_az_imds_url }}" | python3 -mjson.tool
# register: az_imds_reg
# args:
# executable: /bin/bash
## If this fails, that means this VM is not Azure?
#
#- set_fact:
# sap_storage_az_imds_json: "{{ az_imds_reg.stdout }}"
# sap_storage_setup_az_imds_json: "{{ az_imds_reg.stdout }}"
#
## Pull VMSize
## Todo: Ansibilize this
#- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - Pull VMSize
#- name: SAP Storage Preparation - {{ sap_storage_setup_cloud_type | upper }} - Pull VMSize
# shell: |
# curl -H Metadata:true --noproxy "*" "{{ sap_storage_az_vmsize_url }}"
# curl -H Metadata:true --noproxy "*" "{{ sap_storage_setup_az_vmsize_url }}"
# register: az_vmsize_reg
# args:
# executable: /bin/bash
Expand All @@ -33,8 +33,8 @@
# - "{{ az_vmsize_reg.stdout }}"
#
#- set_fact:
# sap_storage_az_vmsize: "{{ az_vmsize_reg.stdout }}"
# sap_storage_setup_az_vmsize: "{{ az_vmsize_reg.stdout }}"
#
## Include vars depending on VM Size
#- name: SAP Storage Preparation - {{ sap_storage_cloud_type | upper }} - Load Variables for {{ sap_storage_az_vmsize }}
# include_vars: "{{ sap_storage_cloud_type }}_tasks/vmsizes/{{ sap_storage_az_vmsize }}.yml"
#- name: SAP Storage Preparation - {{ sap_storage_setup_cloud_type | upper }} - Load Variables for {{ sap_storage_setup_az_vmsize }}
# include_vars: "{{ sap_storage_setup_cloud_type }}_tasks/vmsizes/{{ sap_storage_setup_az_vmsize }}.yml"
Loading

0 comments on commit 576e6db

Please sign in to comment.