Skip to content

Commit c4bc054

Browse files
authored
Merge pull request #17 from stackhpc/multi_ssh_keys
multinode: support multiple ssh keys
2 parents e6de11d + f30afee commit c4bc054

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

.github/workflows/multinode.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ on:
6868
type: number
6969
default: 60
7070
ssh_key:
71-
description: SSH public key to authorise on Ansible control host
71+
description: DEPRECATED single SSH public key to authorise on Ansible control host (plain text or empty) DEPRECATED
72+
type: string
73+
ssh_keys:
74+
description: SSH public keys to authorise on Ansible control host (JSON string array or empty if none)
7275
type: string
7376
enable_slack_alert:
7477
description: Whether to send a Slack message to a channel if the job fails
@@ -112,9 +115,21 @@ jobs:
112115

113116
- name: Fail if no SSH key is provided for break_on
114117
run: |
115-
echo "break_on is set to ${{ inputs.break_on }} but an SSH public key has not been provided"
118+
echo "break_on is set to ${{ inputs.break_on }} but no SSH public key has been provided"
116119
exit 1
117-
if: ${{ inputs.break_on != 'never' && inputs.ssh_key == '' }}
120+
if: ${{ inputs.break_on != 'never' && inputs.ssh_keys == '' && inputs.ssh_key == '' }}
121+
122+
- name: Merge ssh_key and ssh_keys input
123+
id: ssh_keys
124+
run: |
125+
if ${{ inputs.ssh_keys == '' && inputs.ssh_key != '' }}; then
126+
echo "WARNING: using DEPRECATED input ssh_key instead of ssh_keys"
127+
# single string to JSON array
128+
ssh_keys="$(jq --raw-input --compact-output '.|[.]' <<<"${{ inputs.ssh_key }}")"
129+
else
130+
ssh_keys=${{ toJSON(inputs.ssh_keys) }}
131+
fi
132+
echo "ssh_keys=${ssh_keys}" >> "$GITHUB_OUTPUT"
118133
119134
- name: Install Package
120135
uses: ConorMacBride/install-package@main
@@ -238,7 +253,7 @@ jobs:
238253
instance_tags = ["gh-actions-multinode"]
239254
EOF
240255
241-
if [[ "${{ inputs.ssh_key }}" != "" ]]; then
256+
if ${{ steps.ssh_keys.outputs.ssh_keys != '' }}; then
242257
cat << EOF >> terraform.tfvars
243258
add_ansible_control_fip = true
244259
ansible_control_fip_pool = "${{ env.MULTINODE_FIP_POOL }}"
@@ -287,18 +302,16 @@ jobs:
287302
kolla_enable_ovn: ${{ env.ENABLE_OVN }}
288303
EOF
289304
290-
if [[ "${{ env.SSH_KEY }}" != "" ]]; then
305+
if ${{ steps.ssh_keys.outputs.ssh_keys != '' }}; then
291306
cat << EOF >> ansible/vars/defaults.yml
292-
extra_ssh_public_keys:
293-
- "${{ env.SSH_KEY }}"
307+
extra_ssh_public_keys: ${{ steps.ssh_keys.outputs.ssh_keys }}
294308
EOF
295309
fi
296310
working-directory: ${{ github.workspace }}/terraform-kayobe-multinode
297311
env:
298312
ENABLE_OVN: ${{ inputs.neutron_plugin == 'ovn' }}
299313
OS_DISTRIBUTION: ${{ inputs.os_distribution }}
300314
OS_RELEASE: ${{ inputs.os_release }}
301-
SSH_KEY: ${{ inputs.ssh_key }}
302315

303316
- name: Terraform Plan
304317
run: terraform plan -input=false

0 commit comments

Comments
 (0)