@@ -77,47 +77,130 @@ jobs:
7777 echo ::group::list modules
7878 ls -l ./spec/fixtures/modules || true; echo
7979 echo ::endgroup::
80- echo ::group::update every 'ssh:' tag in ./inventory.yaml file to add 'native-ssh: true' under install_test_cluster and indent correctly
81- sed -i -e '/ssh:/a\ native-ssh: true' ./inventory.yaml || true; echo
82- # Also add additional SSH options for container environments
83- sed -i -e '/ssh:/a\ connect-timeout: 30' ./inventory.yaml || true; echo
84- sed -i -e '/ssh:/a\ host-key-check: false' ./inventory.yaml || true; echo
85- # Set root credentials if not already present
86- sed -i -e '/ssh:/a\ user: root' ./inventory.yaml || true; echo
87- sed -i -e '/ssh:/a\ password: root' ./inventory.yaml || true; echo
80+ echo ::group::show original inventory
81+ echo "=== Original inventory.yaml ==="
82+ cat ./inventory.yaml || echo "No inventory.yaml found"
8883 echo ::endgroup::
89- echo ::group::fix inventory credentials
90- # Backup original inventory
91- cp ./inventory.yaml ./ inventory.yaml.backup
84+ echo ::group::fix inventory credentials systematically
85+ # Create a completely new inventory file with correct structure
86+ echo "=== Creating corrected inventory file ==="
9287
93- # Remove any existing SSH user/password entries and add correct ones
94- sed -i '/user:/d' ./inventory.yaml
95- sed -i '/password:/d' ./inventory.yaml
96- sed -i '/host-key-check:/d' ./inventory.yaml
97- sed -i '/connect-timeout:/d' ./inventory.yaml
98- sed -i '/native-ssh:/d' ./inventory.yaml
88+ # Extract target names and their URIs from original inventory
89+ awk '
90+ BEGIN {
91+ print "targets:"
92+ in_targets = 0
93+ }
94+ /^targets:/ {
95+ in_targets = 1
96+ next
97+ }
98+ /^[a-zA-Z]/ && in_targets {
99+ in_targets = 0
100+ }
101+ in_targets && /- name:/ {
102+ target_name = $3
103+ getline
104+ if (/uri:/) {
105+ uri = $2
106+ print " - name: " target_name
107+ print " uri: " uri
108+ print " config:"
109+ print " transport: ssh"
110+ print " ssh:"
111+ print " user: root"
112+ print " password: root"
113+ print " host-key-check: false"
114+ print " connect-timeout: 30"
115+ print " native-ssh: true"
116+ }
117+ }
118+ ' ./inventory.yaml > ./inventory_fixed.yaml
99119
100- # Add correct SSH configuration after each 'ssh:' line
101- sed -i '/ssh:/a\ user: root' ./inventory.yaml
102- sed -i '/ssh:/a\ password: root' ./inventory.yaml
103- sed -i '/ssh:/a\ host-key-check: false' ./inventory.yaml
104- sed -i '/ssh:/a\ connect-timeout: 30' ./inventory.yaml
105- sed -i '/ssh:/a\ native-ssh: true' ./inventory.yaml
106-
107- echo "=== Updated inventory.yaml ==="
108- cat ./inventory.yaml
109- echo ::endgroup::
110- echo ::group::list contents of ./inventory.yaml
111- ls -l ./inventory.yaml || true; echo
112- cat ./inventory.yaml || true; echo
113- echo ::endgroup::
114- echo ::group::list contents of spec/docker/inventory.yaml
115- ls -l ./spec/docker/inventory.yaml || true; echo
116- cat ./spec/docker/inventory.yaml || true; echo
117- echo ::endgroup::
118- echo ::group::info:request
119- cat request.json || true; echo
120- echo ::endgroup::
120+ # If the awk approach didn't work, fall back to simpler method
121+ if [ ! -s ./inventory_fixed.yaml ] || ! grep -q "targets:" ./inventory_fixed.yaml; then
122+ echo "=== AWK approach failed, using simpler method ==="
123+
124+ # Get container names and ports
125+ container_info=$(docker ps --format "{{.Names}},{{.Ports}}" | grep ":22/tcp")
126+
127+ # Create new inventory manually
128+ cat > ./inventory_fixed.yaml << 'EOF'
129+ targets:
130+ EOF
131+
132+ # Add each container to inventory
133+ echo "$container_info" | while IFS=',' read -r container_name ports; do
134+ # Extract port number (format: 0.0.0.0:52123->22/tcp)
135+ port=$(echo "$ports" | grep -o '[0-9]*->22/tcp' | cut -d'-' -f1)
136+ echo " - name: $container_name" >> ./inventory_fixed.yaml
137+ echo " uri: localhost:$port" >> ./inventory_fixed.yaml
138+ echo " config:" >> ./inventory_fixed.yaml
139+ echo " transport: ssh" >> ./inventory_fixed.yaml
140+ echo " ssh:" >> ./inventory_fixed.yaml
141+ echo " user: root" >> ./inventory_fixed.yaml
142+ echo " password: root" >> ./inventory_fixed.yaml
143+ echo " host-key-check: false" >> ./inventory_fixed.yaml
144+ echo " connect-timeout: 30" >> ./inventory_fixed.yaml
145+ echo " native-ssh: true" >> ./inventory_fixed.yaml
146+ done
147+ fi
148+
149+ # Replace the original with the fixed version
150+ mv ./inventory_fixed.yaml ./inventory.yaml
151+
152+ echo "=== Final inventory.yaml ==="
153+ cat ./inventory.yaml
154+ echo ::endgroup::
155+ echo ::group::info:request
156+ cat request.json || true; echo
157+ echo ::endgroup::
158+
159+ # Remove the duplicate inventory fixing sections and keep the rest of your steps
160+ - name: Debug container setup
161+ run: |
162+ # ... keep your existing debug container setup ...
163+
164+ - name: Debug SSH connectivity
165+ run: |
166+ # ... keep your existing debug SSH connectivity ...
167+
168+ - name: Verify Bolt connectivity before PE installation
169+ run: |
170+ echo ::group::verify_bolt_connectivity
171+ echo "=== Final inventory check ==="
172+ cat ./inventory.yaml
173+
174+ echo "=== Testing Bolt connectivity ==="
175+ bundle exec bolt command run 'echo "Final Bolt connectivity test successful"' \
176+ --inventoryfile ./inventory.yaml \
177+ --targets all \
178+ --verbose
179+
180+ echo "=== Testing individual commands ==="
181+ bundle exec bolt command run 'whoami' \
182+ --inventoryfile ./inventory.yaml \
183+ --targets all
184+
185+ bundle exec bolt command run 'hostname' \
186+ --inventoryfile ./inventory.yaml \
187+ --targets all
188+ echo ::endgroup::
189+
190+ - name: Install PE on test cluster
191+ timeout-minutes: 120
192+ run: |
193+ echo "=== Starting PE installation ==="
194+ echo "Using inventory file:"
195+ cat ./inventory.yaml
196+
197+ bundle exec bolt plan run peadm_spec::install_test_cluster \
198+ --inventoryfile ./inventory.yaml \
199+ --modulepath spec/fixtures/modules \
200+ architecture=${{ matrix.architecture }} \
201+ version=${{ matrix.version }} \
202+ console_password=${{ secrets.CONSOLE_PASSWORD }} \
203+ --verbose
121204 - name : Debug container setup
122205 run : |
123206 echo ::group::debug_container_setup
0 commit comments