Skip to content

Commit 305bb25

Browse files
committed
Move discovery_hosts to cloud_infra.yaml
- Introduce config/cloud_infra.yaml as a mandatory config file for discovery_hosts, separating it from global.yaml - Add config/cloud_infra.example.yaml template - Remove discovery_hosts from config/global.example.yaml - Add named --global-vars --certs-vars params to bootstrap.sh and validations.sh, replacing positional arguments
1 parent 997e4ce commit 305bb25

14 files changed

Lines changed: 192 additions & 71 deletions

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ Check [Topo.png](docs/Topo.png) for expected hardware setup and [ArchMap.png](do
1515
```bash
1616
cp config/global.example.yaml config/global.yaml
1717
cp config/certificates.example.yaml config/certificates.yaml
18+
cp config/cloud_infra.example.yaml config/cloud_infra.yaml
1819
vim config/global.yaml # Fill in your cluster, network, and hardware settings
1920
vim config/certificates.yaml # Fill in your SSL certificates
21+
vim config/cloud_infra.yaml # Fill in your discovery hosts (or leave discovery_hosts: [])
2022
```
2123

2224
2. Run the bootstrap script:
@@ -280,6 +282,7 @@ ssh cloud-user@<landing-zone-ip>
280282
ls -la /home/cloud-user/enclave
281283
cat /home/cloud-user/enclave/config/global.yaml
282284
cat /home/cloud-user/enclave/config/certificates.yaml
285+
cat /home/cloud-user/enclave/config/cloud_infra.yaml
283286
```
284287

285288
#### Test Only Cluster Deployment

bootstrap.sh

Lines changed: 57 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,73 @@
22
set -o pipefail
33
set -e
44

5+
usage() {
6+
echo "Usage: $0 [OPTIONS]"
7+
echo ""
8+
echo "Options:"
9+
echo " --global-vars FILE Path to global vars file (default: config/global.yaml)"
10+
echo " --certs-vars FILE Path to certificates vars file (default: config/certificates.yaml)"
11+
echo " -h, --help Show this help message"
12+
exit 0
13+
}
14+
15+
global_vars=config/global.yaml
16+
certs_vars=config/certificates.yaml
17+
cloud_infra_vars=config/cloud_infra.yaml
18+
19+
while [[ $# -gt 0 ]]; do
20+
case $1 in
21+
--global-vars)
22+
global_vars="$2"
23+
shift 2
24+
;;
25+
--certs-vars)
26+
certs_vars="$2"
27+
shift 2
28+
;;
29+
-h|--help)
30+
usage
31+
;;
32+
*)
33+
echo "Error: Unknown option '$1'"
34+
usage
35+
;;
36+
esac
37+
done
38+
39+
echo " "
40+
echo " ██████╗░███████╗██████╗░ ██╗░░██╗░█████╗░████████╗"
41+
echo " ██╔══██╗██╔════╝██╔══██╗ ██║░░██║██╔══██╗╚══██╔══╝"
42+
echo " ██████╔╝█████╗░░██║░░██║ ███████║███████║░░░██║░░░"
43+
echo " ██╔══██╗██╔══╝░░██║░░██║ ██╔══██║██╔══██║░░░██║░░░"
44+
echo " ██║░░██║███████╗██████╔╝ ██║░░██║██║░░██║░░░██║░░░"
45+
echo " ╚═╝░░╚═╝╚══════╝╚═════╝░ ╚═╝░░╚═╝╚═╝░░╚═╝░░░╚═╝░░░"
46+
echo " "
47+
echo "This script is designed to be re-run on demand "
48+
echo "NOTE: Every run will destroy the entire cloud "
49+
echo " Some functions will reuse local caches "
50+
echo ""
51+
552
getValue(){
653
python -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin)))' < $global_vars \
754
| jq -r $1
855
}
956

10-
global_vars=${1:-config/global.yaml}
11-
certs_vars=${2:-config/certificates.yaml}
12-
1357
if [ ! -f "$global_vars" ]; then
1458
echo "Error: $global_vars not found."
15-
if [ -z "$1" ]; then
16-
echo "Copy config/global.example.yaml to $global_vars and fill in your values."
17-
fi
59+
echo "Copy config/global.example.yaml to $global_vars and fill in your values."
1860
exit 1
1961
fi
2062

2163
if [ ! -f "$certs_vars" ]; then
2264
echo "Error: $certs_vars not found."
23-
if [ -z "$2" ]; then
24-
echo "Copy config/certificates.example.yaml to $certs_vars and fill in your values."
25-
fi
65+
echo "Copy config/certificates.example.yaml to $certs_vars and fill in your values."
66+
exit 1
67+
fi
68+
69+
if [ ! -f "$cloud_infra_vars" ]; then
70+
echo "Error: $cloud_infra_vars not found."
71+
echo "Copy config/cloud_infra.example.yaml to $cloud_infra_vars and fill in your values."
2672
exit 1
2773
fi
2874

@@ -36,19 +82,6 @@ _cleanup(){
3682
rm -fr "${lck}"
3783
}
3884

39-
40-
echo " "
41-
echo " ██████╗░███████╗██████╗░  ██╗░░██╗░█████╗░████████╗"
42-
echo " ██╔══██╗██╔════╝██╔══██╗  ██║░░██║██╔══██╗╚══██╔══╝"
43-
echo " ██████╔╝█████╗░░██║░░██║  ███████║███████║░░░██║░░░"
44-
echo " ██╔══██╗██╔══╝░░██║░░██║  ██╔══██║██╔══██║░░░██║░░░"
45-
echo " ██║░░██║███████╗██████╔╝  ██║░░██║██║░░██║░░░██║░░░"
46-
echo " ╚═╝░░╚═╝╚══════╝╚═════╝░  ╚═╝░░╚═╝╚═╝░░╚═╝░░░╚═╝░░░"
47-
echo " "
48-
echo "This script is designed to be re-run on demand "
49-
echo "NOTE: Every run will destroy the entire cloud "
50-
echo " Some functions will reuse local caches "
51-
5285
read -rp "Press Enter to start .. " -n1 -s
5386

5487
if [ -e ${lck} ]; then
@@ -72,7 +105,7 @@ date > "$log"
72105

73106
echo -p "Check Config .. " -n1 -s | tee -a ${log}
74107
FList="ansible.cfg bootstrap.sh playbooks/main.yaml playbooks/ \
75-
setup_ansible.sh setup_env.sh $global_vars $certs_vars"
108+
setup_ansible.sh setup_env.sh $global_vars $certs_vars $cloud_infra_vars"
76109
for x in $FList; do
77110
if [ -e $x ]; then
78111
echo "file check passed ..." $x | tee -a ${log}
@@ -90,7 +123,7 @@ echo -e "\e[38;5;10m Done...\033[0m"; date
90123

91124
echo -p "Validating Config .. " -n1 -s | tee -a ${log}
92125
ansible-playbook playbooks/validate-schema.yaml -e@$global_vars -e@$certs_vars --tags schema-validation 2>&1 | tee -a ${log}
93-
bash ./validations.sh $global_vars $certs_vars 2>&1 | tee -a ${log}
126+
bash ./validations.sh --global-vars $global_vars --certs-vars $certs_vars 2>&1 | tee -a ${log}
94127
echo -e "\e[38;5;10m Done...\033[0m"; date
95128

96129
echo -p "Downloading Deps Content .. " -n1 -s

config/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ This directory contains the configuration files needed for your enclave deployme
99
cd config/
1010
cp global.example.yaml global.yaml
1111
cp certificates.example.yaml certificates.yaml
12+
cp cloud_infra.example.yaml cloud_infra.yaml
1213
```
1314

1415
2. **Fill in `global.yaml` with your environment details**
1516
3. **Fill in `certificates.yaml` with your SSL certificates**
17+
4. **Fill in `cloud_infra.yaml` with your discovery hosts (or leave `discovery_hosts: []` if not needed)**
1618

1719
## Configuration Files
1820

@@ -22,8 +24,11 @@ Contains all cluster and infrastructure configuration.
2224
### `certificates.yaml` (required)
2325
Contains SSL certificates for the cluster.
2426

27+
### `cloud_infra.yaml` (required)
28+
Contains cloud infrastructure configuration, including the list of worker nodes to be discovered and added to the cluster. Set `discovery_hosts: []` if no discovery hosts are needed.
29+
2530
## Security
26-
- **Never commit `global.yaml` or `certificates.yaml` to version control**
31+
- **Never commit `global.yaml`, `certificates.yaml` or `cloud_infra.yaml` to version control**
2732
- These files contain sensitive credentials and private keys
2833
- The `.gitignore` is configured to exclude them
2934

config/cloud_infra.example.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
##############################################################################
2+
# CLOUD INFRASTRUCTURE CONFIGURATION TEMPLATE
3+
# Instructions: Copy this file to 'cloud_infra.yaml' and fill in your values
4+
##############################################################################
5+
6+
# ============================================================================
7+
# Discovery Hosts Configuration
8+
# ============================================================================
9+
# Discovery hosts for cloud infrastructure (CaaS)
10+
# These are worker nodes that will be discovered and added to the cluster
11+
# Set to an empty list if no discovery hosts are needed:
12+
# discovery_hosts: []
13+
#
14+
# Or add hosts to discover:
15+
discovery_hosts:
16+
- name: YOUR_NODE_NAME # Example: node01
17+
macAddress: YOUR_MAC_ADDRESS # Example: 0c:c4:7a:62:fe:ec
18+
ipAddress: YOUR_IP_ADDRESS # Should be in machineNetwork
19+
redfish: YOUR_REDFISH_IP # IPMI/Redfish management IP
20+
rootDisk: YOUR_ROOT_DISK_PATH # Example: /dev/disk/by-path/pci-0000:00:11.4-ata-1.0
21+
redfishUser: YOUR_REDFISH_USER
22+
redfishPassword: YOUR_REDFISH_PASSWORD
23+
# Add more hosts as needed

config/global.example.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,3 @@ agent_hosts:
120120
# instead of the macAddress and ipAddress parameters
121121
# See docs/CONFIGURATION_REFERENCE.md for reference
122122

123-
# ============================================================================
124-
# Discovery Hosts Configuration
125-
# ============================================================================
126-
# Discovery hosts for cloud infrastructure (CaaS)
127-
# These are worker nodes that will be discovered and added to the cluster
128-
discovery_hosts:
129-
- name: YOUR_NODE_NAME # Example: node01
130-
macAddress: YOUR_MAC_ADDRESS # Example: 0c:c4:7a:62:fe:ec
131-
ipAddress: YOUR_IP_ADDRESS # Shoul be in machineNetwork
132-
redfish: YOUR_REDFISH_IP # IPMI/Redfish management IP
133-
rootDisk: YOUR_ROOT_DISK_PATH # Example: /dev/disk/by-path/pci-0000:00:11.4-ata-1.0
134-
redfishUser: YOUR_REDFISH_USER
135-
redfishPassword: YOUR_REDFISH_PASSWORD
136-
# Add more hosts as needed

docs/CONFIGURATION_REFERENCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ curl -k -u user:pass https://<redfish-ip>/redfish/v1/Systems/1/EthernetInterface
499499

500500
## Discovery Hosts Configuration
501501

502-
The discovery hosts configuration is defined in `config/global.yaml` for discovering new nodes after the initial cluster deployment. This configuration uses the same network settings (defaultDNS, defaultGateway, defaultPrefix, lzBmcIP) as the main cluster deployment.
502+
The discovery hosts configuration is defined in `config/cloud_infra.yaml` for discovering new nodes after the initial cluster deployment. This configuration uses the same network settings (defaultDNS, defaultGateway, defaultPrefix, lzBmcIP) as the main cluster deployment.
503503

504504
### Discovery Hosts Settings
505505

docs/DEPLOYMENT_GUIDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ After the initial cluster deployment, you can discover and add new bare metal no
741741

742742
### Configuration
743743

744-
Add or edit the `discovery_hosts` section in `config/global.yaml` with the details of the nodes you want to discover:
744+
Add or edit the `discovery_hosts` section in `config/cloud_infra.yaml` with the details of the nodes you want to discover:
745745

746746
```yaml
747747
# Discovery hosts for cloud infrastructure (CaaS)
@@ -780,9 +780,9 @@ Each node in `discovery_hosts` requires:
780780

781781
### Running Discovery
782782

783-
1. **Edit the configuration** in `config/global.yaml`:
783+
1. **Edit the configuration** in `config/cloud_infra.yaml`:
784784
```bash
785-
vim config/global.yaml
785+
vim config/cloud_infra.yaml
786786
# Add or update the discovery_hosts section
787787
```
788788

must-gather/gather_lz.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,32 @@ PYTHON_SCRIPT
175175

176176
log_info " OK Collected configuration (sanitized)"
177177
fi
178+
179+
CLOUD_INFRA_FILE="${ENCLAVE_DIR}/config/cloud_infra.yaml"
180+
if [ -f "${CLOUD_INFRA_FILE}" ]; then
181+
python3 <<PYTHON_SCRIPT > "${COLLECTION_DIR}/config/cloud_infra.yaml" 2>/dev/null || true
182+
import sys
183+
import yaml
184+
185+
with open('${CLOUD_INFRA_FILE}', 'r') as f:
186+
data = yaml.safe_load(f)
187+
188+
if 'discovery_hosts' in data and isinstance(data['discovery_hosts'], list):
189+
for host in data['discovery_hosts']:
190+
if isinstance(host, dict):
191+
if 'redfishPassword' in host:
192+
host['redfishPassword'] = 'REDACTED'
193+
if 'password' in host:
194+
host['password'] = 'REDACTED'
195+
196+
yaml.dump(data, sys.stdout, default_flow_style=False, sort_keys=False)
197+
PYTHON_SCRIPT
198+
199+
if [ ! -s "${COLLECTION_DIR}/config/cloud_infra.yaml" ]; then
200+
log_warning "Python sanitization failed for cloud_infra.yaml, using sed fallback"
201+
sed -e 's/\(redfishPassword:\).*/\1 REDACTED/' \
202+
"${CLOUD_INFRA_FILE}" > "${COLLECTION_DIR}/config/cloud_infra.yaml" 2>/dev/null || true
203+
fi
204+
205+
log_info " OK Collected cloud infra configuration (sanitized)"
206+
fi

playbooks/07-configure-discovery.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
- name: Load common variables
77
ansible.builtin.include_tasks: common/load-vars.yaml
88

9-
- name: Set discovery_hosts default
10-
ansible.builtin.set_fact:
11-
discovery_hosts: []
12-
when: discovery_hosts is not defined
13-
149
- name: Deploy Metal3 common resources
1510
ansible.builtin.include_tasks: "../playbooks/tasks/deploy_metal3_common.yaml"
1611

playbooks/common/load-vars.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
- name: Include certificate vars
1010
ansible.builtin.include_vars: ../../config/certificates.yaml
1111

12+
- name: Include cloud infra vars
13+
ansible.builtin.include_vars: ../../config/cloud_infra.yaml
14+
1215
- name: Include common configuration
1316
ansible.builtin.include_vars: "../../defaults/{{ config_file }}"
1417
loop:

0 commit comments

Comments
 (0)