Skip to content
Open
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
11 changes: 9 additions & 2 deletions playbooks/imports/play-github-cli-multi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@
register: ssh_test
changed_when: false
failed_when: ssh_test.rc not in [0, 1, 124, 255]
# Live SSH auth cannot run under --check: the passphrase file and
# any generated keys are side-effect tasks that are skipped in check
# mode, leaving this probe with empty stdout. Skip it (and the assert
# below) rather than fail spuriously on a dry run.
when: not ansible_check_mode
loop: "{{ github_accounts | default({}) | dict2items }}"
loop_control:
label: "{{ item.key }}"
Expand All @@ -458,11 +463,13 @@
msg: >
github_{{ item.item.key }} (expects {{ item.item.value }}):
{{ item.stdout | regex_search('Hi [^!]+!') | default('NOT AUTHENTICATED', true) }}
loop: "{{ ssh_test.results }}"
when: not ansible_check_mode
loop: "{{ ssh_test.results | default([]) }}"
loop_control:
label: "{{ item.item.key }}"

- name: Assert SSH access and identity match for all accounts
when: not ansible_check_mode
ansible.builtin.assert:
that:
- "'successfully authenticated' in item.stdout"
Expand All @@ -483,7 +490,7 @@
rm ~/.ssh/github_{{ item.item.key }} ~/.ssh/github_{{ item.item.key }}.pub
# then re-run this playbook
success_msg: "{{ item.item.key }} -> {{ item.item.value }} OK"
loop: "{{ ssh_test.results }}"
loop: "{{ ssh_test.results | default([]) }}"
loop_control:
label: "{{ item.item.key }}"

Expand Down