Skip to content
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
7 changes: 7 additions & 0 deletions .yamlfmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
formatter:
type: basic
include_document_start: true
trim_trailing_whitespace: true
retain_line_breaks_single: true
scan_folded_as_literal: true
output_format: line
19 changes: 18 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@

shellcheck:
@./hack/shellcheck.sh
@./hack/shellcheck.sh

yamlfmt:
@./hack/yamlfmt.sh

verify:
VALIDATE_ONLY=true $(MAKE) shellcheck
VALIDATE_ONLY=true $(MAKE) yamlfmt

install-pre-commit:
@echo "Installing pre-commit hook..."
@ln -sf ../../hack/pre-commit .git/hooks/pre-commit
@echo "Pre-commit hook installed successfully!"

uninstall-pre-commit:
@echo "Uninstalling pre-commit hook..."
@rm -f .git/hooks/pre-commit
@echo "Pre-commit hook uninstalled successfully!"
1 change: 1 addition & 0 deletions deploy/openshift-clusters/clean.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- hosts: metal_machine
roles:
- dev-scripts/clean
Expand Down
4 changes: 2 additions & 2 deletions deploy/openshift-clusters/collections/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ collections:
- name: kubernetes.core
version: ">=2.4.0"
- name: containers.podman
version: ">=1.10.0"
version: ">=1.10.0"
- name: ansible.posix
version: ">=2.0"
- name: community.general
version: ">=5.0.0"
version: ">=5.0.0"
8 changes: 4 additions & 4 deletions deploy/openshift-clusters/init-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
# --- Variable Definitions ---
vars_files:
- vars/init-host.yml
- vars/init-host.yml.local # Optional override file (ignored by git)
- vars/init-host.yml.local # Optional override file (ignored by git)

vars:
# Additional variables can be defined here or overridden via command line
# Additional variables can be defined here or overridden via command line

# --- Pre-flight Checks ---
pre_tasks:
Expand Down Expand Up @@ -47,7 +47,7 @@
register: rhsm_key_prompt
delegate_to: localhost
run_once: true
when:
when:
- not rhsm_already_registered
- interactive_mode | bool
- rhsm_activation_key is not defined
Expand Down Expand Up @@ -233,7 +233,7 @@
post_tasks:
- name: Host initialization completed
ansible.builtin.debug:
msg: |
msg: |-
Host initialization completed successfully:
- Hostname set to: {{ hostname_prefix }}
- User '{{ init_user }}' configured with sudo access
Expand Down
66 changes: 33 additions & 33 deletions deploy/openshift-clusters/kcli-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
collections:
- community.libvirt
- kubernetes.core

# --- Variable Definitions ---
vars:
# Default to non-interactive mode to prevent prompts during automated runs
# Set interactive_mode: true to enable prompts for manual execution
interactive_mode: false

# Default topology is fencing (can be overridden to 'arbiter' if needed, not supported at the moment)
# This default ensures no prompt is triggered when interactive_mode is false
topology: fencing
Expand Down Expand Up @@ -85,34 +85,34 @@
- vars/main.yml

tasks:
# Setup proxy access as a separate step after cluster deployment
- name: Setup proxy access
include_role:
name: proxy-setup
vars:
kubeconfig_path: "{{ ansible_user_dir }}/.kcli/clusters/{{ test_cluster_name }}/auth/kubeconfig"
kubeadmin_password_path: "{{ ansible_user_dir }}/.kcli/clusters/{{ test_cluster_name }}/auth/kubeadmin-password"

- name: Update inventory with cluster VMs
include_tasks: roles/common/tasks/update-cluster-inventory.yml

# Configure stonith fencing after cluster installation
- name: Configure Redfish BMC simulation for fencing topology
shell: ansible-playbook kcli-redfish.yml -i {{ inventory_file | default('inventory.ini') }}
args:
chdir: "{{ playbook_dir }}"
delegate_to: localhost
run_once: true
when: topology == "fencing"

- name: "Final verification message"
ansible.builtin.debug:
msg: |
Installation tasks have completed for {{ topology }} topology.
Next steps:
1. Source the proxy environment from anywhere:
source {{ playbook_dir }}/proxy.env
(or from openshift-clusters directory: source proxy.env)
2. Verify cluster access: oc get nodes
3. Access the cluster console if needed
# Setup proxy access as a separate step after cluster deployment
- name: Setup proxy access
include_role:
name: proxy-setup
vars:
kubeconfig_path: "{{ ansible_user_dir }}/.kcli/clusters/{{ test_cluster_name }}/auth/kubeconfig"
kubeadmin_password_path: "{{ ansible_user_dir }}/.kcli/clusters/{{ test_cluster_name }}/auth/kubeadmin-password"

- name: Update inventory with cluster VMs
include_tasks: roles/common/tasks/update-cluster-inventory.yml

# Configure stonith fencing after cluster installation
- name: Configure Redfish BMC simulation for fencing topology
shell: ansible-playbook kcli-redfish.yml -i {{ inventory_file | default('inventory.ini') }}
args:
chdir: "{{ playbook_dir }}"
delegate_to: localhost
run_once: true
when: topology == "fencing"

- name: "Final verification message"
ansible.builtin.debug:
msg: |-
Installation tasks have completed for {{ topology }} topology.

Next steps:
1. Source the proxy environment from anywhere:
source {{ playbook_dir }}/proxy.env
(or from openshift-clusters directory: source proxy.env)
2. Verify cluster access: oc get nodes
3. Access the cluster console if needed
14 changes: 7 additions & 7 deletions deploy/openshift-clusters/kcli-redfish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
- name: Proxy environment configuration used
debug:
msg: |

Using proxy.env file for cluster access configuration.
Proxy settings have been applied to the kcli-redfish role.

Expand All @@ -69,10 +69,10 @@
- name: No proxy environment detected
debug:
msg: |

proxy.env file not found. Assuming direct cluster access.
The kcli-redfish role will run without proxy configuration.

Note: Ensure your current environment has:
- Valid KUBECONFIG environment variable or ~/.kube/config
- Direct network access to the OpenShift cluster API
Expand All @@ -87,15 +87,15 @@
rescue:
- name: Handle kcli-redfish configuration errors
debug:
msg: |
msg: |-
An error occurred while running kcli-redfish configuration.
Error details: {{ ansible_failed_result.msg | default('Unknown error') }}

Common issues:
1. Ensure cluster is deployed with kcli and fencing topology
2. Verify ksushy BMC simulator is running on the hypervisor
3. Check that kcli clusters are running: kcli list cluster
4. Verify you're running this on the correct inventory host (hypervisor)

You can override auto-detection with explicit variables:
ansible-playbook kcli-redfish.yml -e "test_cluster_name=your-cluster"
ansible-playbook kcli-redfish.yml -e "test_cluster_name=your-cluster"
16 changes: 8 additions & 8 deletions deploy/openshift-clusters/redeploy.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- hosts: metal_machine
gather_facts: no
force_handlers: yes
Expand Down Expand Up @@ -36,7 +37,7 @@
- Recovers from incomplete/failed deployment state

3. COMPLETE REBUILD (different topology):
- Two-node with fencing ↔ Two-node with arbiter
- Two-node with fencing ↔ Two-node with arbiter
- Uses make realclean + full installation from scratch
- Slower but guarantees clean state with correct topology

Expand Down Expand Up @@ -81,7 +82,7 @@
REASON: Cluster topology change detected
NOTE: Ensures completely clean state but takes longest time
{% elif clean_needed | bool %}
STRATEGY: Clean deployment (make clean + full install)
STRATEGY: Clean deployment (make clean + full install)
REASON: Previous deployment incomplete or status unknown
NOTE: Recovers from incomplete state, faster than complete rebuild
{% else %}
Expand All @@ -97,7 +98,7 @@
prompt: |-
Please verify the information above is correct. Press Enter to proceed with:
{% if vm_cleanup_needed | bool %}COMPLETE REBUILD
{% elif clean_needed | bool %}CLEAN DEPLOYMENT
{% elif clean_needed | bool %}CLEAN DEPLOYMENT
{% else %}FAST REDEPLOY
{% endif %}
delegate_to: localhost
Expand All @@ -123,14 +124,14 @@
chdir: "{{ dev_scripts_path }}"
target: clean
register: clean_result
when:
when:
- clean_needed | bool
- not (vm_cleanup_needed | bool) # Don't clean if we already did realclean
- not (vm_cleanup_needed | bool) # Don't clean if we already did realclean

- name: Display clean completion
ansible.builtin.debug:
msg: "Clean completed - ready for fresh installation to recover from incomplete state"
when:
when:
- clean_needed | bool
- not (vm_cleanup_needed | bool)

Expand All @@ -141,5 +142,4 @@
post_tasks:
- name: Update inventory with cluster VMs
include_tasks: roles/common/tasks/update-cluster-inventory.yml

# Cluster state management is now handled by the install-dev role
# Cluster state management is now handled by the install-dev role
12 changes: 6 additions & 6 deletions deploy/openshift-clusters/redfish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
- name: Proxy environment configuration used
debug:
msg: |

Using proxy.env file for cluster access configuration.
Proxy settings have been applied to the redfish role.

Expand All @@ -67,10 +67,10 @@
- name: No proxy environment detected
debug:
msg: |

proxy.env file not found. Assuming direct cluster access.
The redfish role will run without proxy configuration.

Note: Ensure your current environment has:
- Valid KUBECONFIG environment variable or ~/.kube/config
- Direct network access to the OpenShift cluster API
Expand All @@ -84,9 +84,9 @@
rescue:
- name: Handle redfish configuration errors
debug:
msg: |
msg: |-
An error occurred while running redfish configuration.
Error details: {{ ansible_failed_result.msg | default('Unknown error') }}

You can try running manually:
source proxy.env && ansible-playbook -i localhost, roles/redfish/tasks/main.yml
source proxy.env && ansible-playbook -i localhost, roles/redfish/tasks/main.yml
10 changes: 5 additions & 5 deletions deploy/openshift-clusters/roles/common/tasks/cluster-state.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
force: yes
delegate_to: localhost
run_once: true
when:
when:
- ansible_check_mode == false
- cluster_state_phase is defined and cluster_state_phase == 'deploying'

Expand Down Expand Up @@ -71,7 +71,7 @@
force: yes
delegate_to: localhost
run_once: true
when:
when:
- ansible_check_mode == false
- cluster_state_phase is defined and cluster_state_phase == 'deployed'

Expand Down Expand Up @@ -106,7 +106,7 @@
force: yes
delegate_to: localhost
run_once: true
when:
when:
- install_dev_mode is defined and install_dev_mode == 'redeploy'
- ansible_check_mode == false
- cluster_state_phase is defined and cluster_state_phase == 'deployed'
Expand All @@ -120,6 +120,6 @@
- Status: DEPLOYED (cluster successfully redeployed)
- Redeployed at: {{ now(utc=True).isoformat() }}
run_once: true
when:
when:
- install_dev_mode is defined and install_dev_mode == 'redeploy'
- cluster_state_phase is defined and cluster_state_phase == 'deployed'
- cluster_state_phase is defined and cluster_state_phase == 'deployed'
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@
- name: Build cluster_vms section
set_fact:
cluster_vms_section: |

[cluster_vms]
{% for entry in parsed_vm_entries %}
{{ entry.name }} ansible_host='{{ entry.ip }}'
Expand Down Expand Up @@ -172,6 +171,6 @@
- name: No cluster VMs found
when: not (has_cluster_vms | bool)
debug:
msg: |
msg: |-
No cluster VMs found for cluster '{{ test_cluster_name }}'.
Inventory will not be updated with cluster VMs.
4 changes: 2 additions & 2 deletions deploy/openshift-clusters/roles/config/tasks/copy_auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@

- name: Display auth files location
debug:
msg: |
msg: |-
Cluster authentication files copied to ~/auth/:
- kubeconfig: ~/auth/kubeconfig
{% if kubeadmin_password_path is defined %}
- kubeadmin-password: ~/auth/kubeadmin-password
{% endif %}
- Default kubeconfig symlink: ~/.kube/config -> ~/auth/kubeconfig
- Default kubeconfig symlink: ~/.kube/config -> ~/auth/kubeconfig
1 change: 1 addition & 0 deletions deploy/openshift-clusters/roles/config/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Check if instance.env exists
stat:
path: "{{ playbook_dir }}/../aws-hypervisor/instance.env"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
dev_scripts_path: openshift-metal3/dev-scripts
dev_scripts_branch: master
dev_scripts_src_repo: https://github.com/openshift-metal3/dev-scripts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Check for dev_scripts_path
fail:
msg: dev_scripts_path must be defined
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
dev_scripts_path: openshift-metal3/dev-scripts
dev_scripts_branch: master
dev_scripts_src_repo: https://github.com/openshift-metal3/dev-scripts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
---
- name: Set OCP project
command: oc --kubeconfig="{{kubeconfig_path}}" project openshift-machine-api
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- import_tasks: teardown.yml
- import_tasks: config.yml
- import_tasks: create.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
- name: Check for dev_scripts_path
fail:
msg: dev_scripts_path must be defined
Expand Down
Loading