Skip to content

Commit f891ed7

Browse files
committed
feat: add yamlfmt support
added pre-commit check to catch shellcheck and yamlfmt errors added pre-commit install and uninstall tasks to Makefile added yamlfmt script and config to format and verify yaml files Signed-off-by: ehila <ehila@redhat.com>
1 parent 1ee4474 commit f891ed7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+237
-144
lines changed

.yamlfmt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
formatter:
2+
type: basic
3+
include_document_start: true
4+
trim_trailing_whitespace: true
5+
retain_line_breaks_single: true
6+
scan_folded_as_literal: true
7+
output_format: line

Makefile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11

22
shellcheck:
3-
@./hack/shellcheck.sh
3+
@./hack/shellcheck.sh
4+
5+
yamlfmt:
6+
@./hack/yamlfmt.sh
7+
8+
verify:
9+
VALIDATE_ONLY=true $(MAKE) shellcheck
10+
VALIDATE_ONLY=true $(MAKE) yamlfmt
11+
12+
install-pre-commit:
13+
@echo "Installing pre-commit hook..."
14+
@ln -sf ../../hack/pre-commit .git/hooks/pre-commit
15+
@echo "Pre-commit hook installed successfully!"
16+
17+
uninstall-pre-commit:
18+
@echo "Uninstalling pre-commit hook..."
19+
@rm -f .git/hooks/pre-commit
20+
@echo "Pre-commit hook uninstalled successfully!"

deploy/openshift-clusters/clean.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
- hosts: metal_machine
23
roles:
34
- dev-scripts/clean

deploy/openshift-clusters/collections/requirements.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ collections:
88
- name: kubernetes.core
99
version: ">=2.4.0"
1010
- name: containers.podman
11-
version: ">=1.10.0"
11+
version: ">=1.10.0"
1212
- name: ansible.posix
1313
version: ">=2.0"
1414
- name: community.general
15-
version: ">=5.0.0"
15+
version: ">=5.0.0"

deploy/openshift-clusters/init-host.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
# --- Variable Definitions ---
1111
vars_files:
1212
- vars/init-host.yml
13-
- vars/init-host.yml.local # Optional override file (ignored by git)
13+
- vars/init-host.yml.local # Optional override file (ignored by git)
1414

1515
vars:
16-
# Additional variables can be defined here or overridden via command line
16+
# Additional variables can be defined here or overridden via command line
1717

1818
# --- Pre-flight Checks ---
1919
pre_tasks:
@@ -47,7 +47,7 @@
4747
register: rhsm_key_prompt
4848
delegate_to: localhost
4949
run_once: true
50-
when:
50+
when:
5151
- not rhsm_already_registered
5252
- interactive_mode | bool
5353
- rhsm_activation_key is not defined
@@ -233,7 +233,7 @@
233233
post_tasks:
234234
- name: Host initialization completed
235235
ansible.builtin.debug:
236-
msg: |
236+
msg: |-
237237
Host initialization completed successfully:
238238
- Hostname set to: {{ hostname_prefix }}
239239
- User '{{ init_user }}' configured with sudo access

deploy/openshift-clusters/kcli-install.yml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
collections:
1212
- community.libvirt
1313
- kubernetes.core
14-
14+
1515
# --- Variable Definitions ---
1616
vars:
1717
# Default to non-interactive mode to prevent prompts during automated runs
1818
# Set interactive_mode: true to enable prompts for manual execution
1919
interactive_mode: false
20-
20+
2121
# Default topology is fencing (can be overridden to 'arbiter' if needed, not supported at the moment)
2222
# This default ensures no prompt is triggered when interactive_mode is false
2323
topology: fencing
@@ -85,34 +85,34 @@
8585
- vars/main.yml
8686

8787
tasks:
88-
# Setup proxy access as a separate step after cluster deployment
89-
- name: Setup proxy access
90-
include_role:
91-
name: proxy-setup
92-
vars:
93-
kubeconfig_path: "{{ ansible_user_dir }}/.kcli/clusters/{{ test_cluster_name }}/auth/kubeconfig"
94-
kubeadmin_password_path: "{{ ansible_user_dir }}/.kcli/clusters/{{ test_cluster_name }}/auth/kubeadmin-password"
95-
96-
- name: Update inventory with cluster VMs
97-
include_tasks: roles/common/tasks/update-cluster-inventory.yml
98-
99-
# Configure stonith fencing after cluster installation
100-
- name: Configure Redfish BMC simulation for fencing topology
101-
shell: ansible-playbook kcli-redfish.yml -i {{ inventory_file | default('inventory.ini') }}
102-
args:
103-
chdir: "{{ playbook_dir }}"
104-
delegate_to: localhost
105-
run_once: true
106-
when: topology == "fencing"
107-
108-
- name: "Final verification message"
109-
ansible.builtin.debug:
110-
msg: |
111-
Installation tasks have completed for {{ topology }} topology.
112-
113-
Next steps:
114-
1. Source the proxy environment from anywhere:
115-
source {{ playbook_dir }}/proxy.env
116-
(or from openshift-clusters directory: source proxy.env)
117-
2. Verify cluster access: oc get nodes
118-
3. Access the cluster console if needed
88+
# Setup proxy access as a separate step after cluster deployment
89+
- name: Setup proxy access
90+
include_role:
91+
name: proxy-setup
92+
vars:
93+
kubeconfig_path: "{{ ansible_user_dir }}/.kcli/clusters/{{ test_cluster_name }}/auth/kubeconfig"
94+
kubeadmin_password_path: "{{ ansible_user_dir }}/.kcli/clusters/{{ test_cluster_name }}/auth/kubeadmin-password"
95+
96+
- name: Update inventory with cluster VMs
97+
include_tasks: roles/common/tasks/update-cluster-inventory.yml
98+
99+
# Configure stonith fencing after cluster installation
100+
- name: Configure Redfish BMC simulation for fencing topology
101+
shell: ansible-playbook kcli-redfish.yml -i {{ inventory_file | default('inventory.ini') }}
102+
args:
103+
chdir: "{{ playbook_dir }}"
104+
delegate_to: localhost
105+
run_once: true
106+
when: topology == "fencing"
107+
108+
- name: "Final verification message"
109+
ansible.builtin.debug:
110+
msg: |-
111+
Installation tasks have completed for {{ topology }} topology.
112+
113+
Next steps:
114+
1. Source the proxy environment from anywhere:
115+
source {{ playbook_dir }}/proxy.env
116+
(or from openshift-clusters directory: source proxy.env)
117+
2. Verify cluster access: oc get nodes
118+
3. Access the cluster console if needed

deploy/openshift-clusters/kcli-redfish.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
- name: Proxy environment configuration used
5959
debug:
6060
msg: |
61-
61+
6262
Using proxy.env file for cluster access configuration.
6363
Proxy settings have been applied to the kcli-redfish role.
6464
@@ -69,10 +69,10 @@
6969
- name: No proxy environment detected
7070
debug:
7171
msg: |
72-
72+
7373
proxy.env file not found. Assuming direct cluster access.
7474
The kcli-redfish role will run without proxy configuration.
75-
75+
7676
Note: Ensure your current environment has:
7777
- Valid KUBECONFIG environment variable or ~/.kube/config
7878
- Direct network access to the OpenShift cluster API
@@ -87,15 +87,15 @@
8787
rescue:
8888
- name: Handle kcli-redfish configuration errors
8989
debug:
90-
msg: |
90+
msg: |-
9191
An error occurred while running kcli-redfish configuration.
9292
Error details: {{ ansible_failed_result.msg | default('Unknown error') }}
93-
93+
9494
Common issues:
9595
1. Ensure cluster is deployed with kcli and fencing topology
9696
2. Verify ksushy BMC simulator is running on the hypervisor
9797
3. Check that kcli clusters are running: kcli list cluster
9898
4. Verify you're running this on the correct inventory host (hypervisor)
99-
99+
100100
You can override auto-detection with explicit variables:
101-
ansible-playbook kcli-redfish.yml -e "test_cluster_name=your-cluster"
101+
ansible-playbook kcli-redfish.yml -e "test_cluster_name=your-cluster"

deploy/openshift-clusters/redeploy.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
- hosts: metal_machine
23
gather_facts: no
34
force_handlers: yes
@@ -36,7 +37,7 @@
3637
- Recovers from incomplete/failed deployment state
3738
3839
3. COMPLETE REBUILD (different topology):
39-
- Two-node with fencing ↔ Two-node with arbiter
40+
- Two-node with fencing ↔ Two-node with arbiter
4041
- Uses make realclean + full installation from scratch
4142
- Slower but guarantees clean state with correct topology
4243
@@ -81,7 +82,7 @@
8182
REASON: Cluster topology change detected
8283
NOTE: Ensures completely clean state but takes longest time
8384
{% elif clean_needed | bool %}
84-
STRATEGY: Clean deployment (make clean + full install)
85+
STRATEGY: Clean deployment (make clean + full install)
8586
REASON: Previous deployment incomplete or status unknown
8687
NOTE: Recovers from incomplete state, faster than complete rebuild
8788
{% else %}
@@ -97,7 +98,7 @@
9798
prompt: |-
9899
Please verify the information above is correct. Press Enter to proceed with:
99100
{% if vm_cleanup_needed | bool %}COMPLETE REBUILD
100-
{% elif clean_needed | bool %}CLEAN DEPLOYMENT
101+
{% elif clean_needed | bool %}CLEAN DEPLOYMENT
101102
{% else %}FAST REDEPLOY
102103
{% endif %}
103104
delegate_to: localhost
@@ -123,14 +124,14 @@
123124
chdir: "{{ dev_scripts_path }}"
124125
target: clean
125126
register: clean_result
126-
when:
127+
when:
127128
- clean_needed | bool
128-
- not (vm_cleanup_needed | bool) # Don't clean if we already did realclean
129+
- not (vm_cleanup_needed | bool) # Don't clean if we already did realclean
129130

130131
- name: Display clean completion
131132
ansible.builtin.debug:
132133
msg: "Clean completed - ready for fresh installation to recover from incomplete state"
133-
when:
134+
when:
134135
- clean_needed | bool
135136
- not (vm_cleanup_needed | bool)
136137

@@ -141,5 +142,4 @@
141142
post_tasks:
142143
- name: Update inventory with cluster VMs
143144
include_tasks: roles/common/tasks/update-cluster-inventory.yml
144-
145-
# Cluster state management is now handled by the install-dev role
145+
# Cluster state management is now handled by the install-dev role

deploy/openshift-clusters/redfish.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
- name: Proxy environment configuration used
5757
debug:
5858
msg: |
59-
59+
6060
Using proxy.env file for cluster access configuration.
6161
Proxy settings have been applied to the redfish role.
6262
@@ -67,10 +67,10 @@
6767
- name: No proxy environment detected
6868
debug:
6969
msg: |
70-
70+
7171
proxy.env file not found. Assuming direct cluster access.
7272
The redfish role will run without proxy configuration.
73-
73+
7474
Note: Ensure your current environment has:
7575
- Valid KUBECONFIG environment variable or ~/.kube/config
7676
- Direct network access to the OpenShift cluster API
@@ -84,9 +84,9 @@
8484
rescue:
8585
- name: Handle redfish configuration errors
8686
debug:
87-
msg: |
87+
msg: |-
8888
An error occurred while running redfish configuration.
8989
Error details: {{ ansible_failed_result.msg | default('Unknown error') }}
90-
90+
9191
You can try running manually:
92-
source proxy.env && ansible-playbook -i localhost, roles/redfish/tasks/main.yml
92+
source proxy.env && ansible-playbook -i localhost, roles/redfish/tasks/main.yml

deploy/openshift-clusters/roles/common/tasks/cluster-state.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
force: yes
3838
delegate_to: localhost
3939
run_once: true
40-
when:
40+
when:
4141
- ansible_check_mode == false
4242
- cluster_state_phase is defined and cluster_state_phase == 'deploying'
4343

@@ -71,7 +71,7 @@
7171
force: yes
7272
delegate_to: localhost
7373
run_once: true
74-
when:
74+
when:
7575
- ansible_check_mode == false
7676
- cluster_state_phase is defined and cluster_state_phase == 'deployed'
7777

@@ -106,7 +106,7 @@
106106
force: yes
107107
delegate_to: localhost
108108
run_once: true
109-
when:
109+
when:
110110
- install_dev_mode is defined and install_dev_mode == 'redeploy'
111111
- ansible_check_mode == false
112112
- cluster_state_phase is defined and cluster_state_phase == 'deployed'
@@ -120,6 +120,6 @@
120120
- Status: DEPLOYED (cluster successfully redeployed)
121121
- Redeployed at: {{ now(utc=True).isoformat() }}
122122
run_once: true
123-
when:
123+
when:
124124
- install_dev_mode is defined and install_dev_mode == 'redeploy'
125-
- cluster_state_phase is defined and cluster_state_phase == 'deployed'
125+
- cluster_state_phase is defined and cluster_state_phase == 'deployed'

0 commit comments

Comments
 (0)