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

added pre-commit configuration for ansible-lint #93

Merged
merged 11 commits into from
Sep 25, 2023
8 changes: 8 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
---
profile: production
offline: false

skip_list:
- "galaxy[no-changelog]"

exclude_paths:
# would be better to move the roles here to the top-level roles directory
- collections/ansible_collections/demo/compliance/roles/
- roles/redhatofficial.*
- .github/
3 changes: 2 additions & 1 deletion .devfile.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
schemaVersion: 2.2.0
metadata:
name: product-demos
components:
- name: product-demos-ee
container:
image: quay.io/mloriedo/ansible-creator-ee:latest # workaround for https://github.com/eclipse/che/issues/21778
image: quay.io/mloriedo/ansible-creator-ee:latest # workaround for https://github.com/eclipse/che/issues/21778
memoryRequest: 256M
memoryLimit: 5Gi
cpuRequest: 250m
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@ on:
- pull_request_target

env:
ANSIBLE_GALAXY_SERVER_LIST: ah,galaxy
ANSIBLE_GALAXY_SERVER_AH_URL: https://console.redhat.com/api/automation-hub/
ANSIBLE_GALAXY_SERVER_AH_AUTH_URL: https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token
ANSIBLE_GALAXY_SERVER_AH_TOKEN: ${{ secrets.ANSIBLE_GALAXY_SERVER_AH_TOKEN }}
ANSIBLE_GALAXY_SERVER_GALAXY_URL: https://galaxy.ansible.com/

jobs:
build:
name: Ansible Lint
runs-on: ubuntu-latest

steps:
# Important: This sets up your GITHUB_WORKSPACE environment variable
- uses: actions/checkout@v3
with:
fetch-depth: 0 # needed for progressive mode to work

# this action implicitly calls actions/checkout
- name: Run ansible-lint
uses: ansible/ansible-lint-action@v6.11.0
uses: ansible/ansible-lint@v6.18.0
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/ansible/ansible-lint.git
# get latest release tag from https://github.com/ansible/ansible-lint/releases/
rev: v6.18.0
hooks:
- id: ansible-lint
additional_dependencies:
- jmespath

...
19 changes: 19 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
extends: default

rules:
line-length: disable
trailing-spaces: enable
colons:
max-spaces-before: 0
max-spaces-after: -1
indentation:
level: error
indent-sequences: true # consistent with ansible-lint
truthy:
level: error
allowed-values:
- 'true'
- 'false'

...
3 changes: 2 additions & 1 deletion ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ roles_path=./roles
server_list = ah,galaxy

[galaxy_server.ah]
url=https://console.redhat.com/api/automation-hub/
#url=https://cloud.redhat.com/api/automation-hub/
url=https://console.redhat.com/api/automation-hub/content/published/
auth_url=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token

[galaxy_server.galaxy]
Expand Down
58 changes: 29 additions & 29 deletions cloud/create_vpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,45 +46,45 @@
rules:
- proto: tcp
ports:
- 80 # HTTP
- 443 # HTTPS
- 22 # SSH
- 5986 # WinRM
- 3389 # RDP
- 9090 # Cockpit
- 80 # HTTP
- 443 # HTTPS
- 22 # SSH
- 5986 # WinRM
- 3389 # RDP
- 9090 # Cockpit
cidr_ip: 0.0.0.0/0
- proto: icmp
to_port: -1
from_port: -1
cidr_ip: 0.0.0.0/0
- proto: tcp
ports:
- 80 # HTTP
- 5986 # WinRM
- 3389 # RDP
- 53 # DNS
- 88 # Kerberos Authentication
- 135 # RPC
- 139 # Netlogon
- 389 # LDAP
- 445 # SMB
- 464 # Kerberos Authentication
- 5432 # PostgreSQL
- 636 # LDAPS (LDAP over TLS)
- 873 # Rsync
- 3268-3269 # Global Catalog
- 1024-65535 # Ephemeral RPC ports
- 80 # HTTP
- 5986 # WinRM
- 3389 # RDP
- 53 # DNS
- 88 # Kerberos Authentication
- 135 # RPC
- 139 # Netlogon
- 389 # LDAP
- 445 # SMB
- 464 # Kerberos Authentication
- 5432 # PostgreSQL
- 636 # LDAPS (LDAP over TLS)
- 873 # Rsync
- 3268-3269 # Global Catalog
- 1024-65535 # Ephemeral RPC ports
cidr_ip: "{{ aws_vpc_cidr_block }}"
- proto: udp
ports:
- 53 # DNS
- 88 # Kerberos Authentication
- 123 # NTP
- 137-138 # Netlogon
- 389 # LDAP
- 445 # SMB
- 464 # Kerberos Authentication
- 1024-65535 # Ephemeral RPC ports
- 53 # DNS
- 88 # Kerberos Authentication
- 123 # NTP
- 137-138 # Netlogon
- 389 # LDAP
- 445 # SMB
- 464 # Kerberos Authentication
- 1024-65535 # Ephemeral RPC ports
cidr_ip: "{{ aws_vpc_cidr_block }}"
rules_egress:
- proto: -1
Expand Down
44 changes: 22 additions & 22 deletions cloud/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ controller_credentials:
username: REPLACEME
password: REPLACEME

# - name: Azure
# credential_type: Microsoft Azure Resource Manager
# organization: Default
# update_secrets: false
# inputs:
# subscription: REPLACEME
# - name: Azure
# credential_type: Microsoft Azure Resource Manager
# organization: Default
# update_secrets: false
# inputs:
# subscription: REPLACEME

controller_inventory_sources:
- name: AWS Inventory
Expand All @@ -62,22 +62,22 @@ controller_inventory_sources:
- key: tags.owner
prefix: owner

# - name: Azure Inventory
# organization: Default
# source: azure_rm
# inventory: Demo Inventory
# credential: Azure
# execution_environment: Ansible Engine 2.9 execution environment
# overwrite: true
# source_vars:
# hostnames:
# - tags.Name
# - default
# keyed_groups:
# - key: os_profile.system
# prefix: os
# conditional_groups:
# cloud_azure: true
# - name: Azure Inventory
# organization: Default
# source: azure_rm
# inventory: Demo Inventory
# credential: Azure
# execution_environment: Ansible Engine 2.9 execution environment
# overwrite: true
# source_vars:
# hostnames:
# - tags.Name
# - default
# keyed_groups:
# - key: os_profile.system
# prefix: os
# conditional_groups:
# cloud_azure: true

controller_groups:
- name: cloud_aws
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,44 @@
rules:
- proto: tcp
ports:
- 80 # HTTP
- 443 # HTTPS
- 22 # SSH
- 5986 # WinRM
- 3389 # RDP
- 80 # HTTP
- 443 # HTTPS
- 22 # SSH
- 5986 # WinRM
- 3389 # RDP
cidr_ip: 0.0.0.0/0
- proto: icmp
to_port: -1
from_port: -1
cidr_ip: 0.0.0.0/0
- proto: tcp
ports:
- 80 # HTTP
- 5986 # WinRM
- 3389 # RDP
- 53 # DNS
- 88 # Kerberos Authentication
- 135 # RPC
- 139 # Netlogon
- 389 # LDAP
- 445 # SMB
- 464 # Kerberos Authentication
- 5432 # PostgreSQL
- 636 # LDAPS (LDAP over TLS)
- 873 # Rsync
- 3268-3269 # Global Catalog
- 1024-65535 # Ephemeral RPC ports
- 80 # HTTP
- 5986 # WinRM
- 3389 # RDP
- 53 # DNS
- 88 # Kerberos Authentication
- 135 # RPC
- 139 # Netlogon
- 389 # LDAP
- 445 # SMB
- 464 # Kerberos Authentication
- 5432 # PostgreSQL
- 636 # LDAPS (LDAP over TLS)
- 873 # Rsync
- 3268-3269 # Global Catalog
- 1024-65535 # Ephemeral RPC ports
cidr_ip: 10.0.0.0/16
- proto: udp
ports:
- 53 # DNS
- 88 # Kerberos Authentication
- 123 # NTP
- 137-138 # Netlogon
- 389 # LDAP
- 445 # SMB
- 464 # Kerberos Authentication
- 1024-65535 # Ephemeral RPC ports
- 53 # DNS
- 88 # Kerberos Authentication
- 123 # NTP
- 137-138 # Netlogon
- 389 # LDAP
- 445 # SMB
- 464 # Kerberos Authentication
- 1024-65535 # Ephemeral RPC ports
cidr_ip: 10.0.0.0/16
rules_egress:
- proto: -1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
# Set stat_snapshots with model:
# [
# {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Create web directory if it does not exist
ansible.builtin.file:
path: "{{ file_path }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
file_path: "{{ web_path | default('/var/www/html/reports') }}"
vendor:
ios: &my_value 'Cisco'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Create HTML report
ansible.builtin.template:
src: report.j2
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
---
file_path: /var/www/html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
email_from: [email protected]
to_emails: [email protected],[email protected]
to_emails_list: "{{ to_emails.split(',') }}"
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Create HTML report
ansible.builtin.template:
src: report.j2
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
---
file_path: /var/www/html
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
- name: Upgrade packages (yum)
ansible.builtin.yum:
name: '*'
state: latest # noqa: package-latest - Intended to update packages to latest
state: latest # noqa: package-latest - Intended to update packages to latest
exclude: "{{ exclude_packages }}"
when: ansible_pkg_mgr == "yum"
register: patchingresult_yum

- name: Upgrade packages (dnf)
ansible.builtin.dnf:
name: '*'
state: latest # noqa: package-latest - Intended to update packages to latest
state: latest # noqa: package-latest - Intended to update packages to latest
exclude: "{{ exclude_packages }}"
when: ansible_pkg_mgr == "dnf"
register: patchingresult_dnf
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Create HTML report
ansible.builtin.template:
src: report.j2
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
---
file_path: /var/www/html/reports
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
email_from: [email protected]
to_emails: [email protected],[email protected]
to_emails_list: "{{ to_emails.split(',') }}"
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Create HTML report
ansible.builtin.template:
src: report.j2
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
---
file_path: /var/www/html/reports
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Create HTML report
ansible.windows.win_template:
src: report.j2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
instance_name: "{{ inventory_hostname | regex_replace('_', '-') }}"
activation_key: "{{ 'RHEL' + ansible_distribution_major_version + '_' + env }}"
rex_user: root # "{{ ansible_user }}"
rex_user: root # "{{ ansible_user }}"
force_register: true
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
foreman_server_url: "{{ lookup('env', 'SATELLITE_SERVER') }}"
foreman_username: "{{ lookup('env', 'SATELLITE_USERNAME') }}"
foreman_password: "{{ lookup('env', 'SATELLITE_PASSWORD') }}"
Expand Down
Loading