Fix ssh-agent tests (#493)

* Work around stupid ssh-agent output format.

* Workaround for Ansible 2.9.

* Old jinja2...

* Jinja2 on CentOS 6 is really annoying.
pull/495/head
Felix Fontein 2022-07-22 13:54:15 +02:00 committed by GitHub
parent 6bf3ef47e1
commit e4ebca0945
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -5,3 +5,4 @@
dependencies:
- setup_ssh_keygen
- prepare_jinja2_compat

View File

@ -9,13 +9,22 @@
####################################################################
- name: Start an ssh agent to use for tests
shell: eval $(ssh-agent)>/dev/null&&echo "${SSH_AGENT_PID};${SSH_AUTH_SOCK}"
register: openssh_agent_env_vars
shell: ssh-agent -c | grep "^setenv"
register: openssh_agent_stdout
- name: Convert output to dictionary
set_fact:
openssh_agent_env: >-
{{
openssh_agent_stdout.stdout_lines | map('regex_replace', '^setenv ([^ ]+) ([^ ]+);', '\1')
| zip(openssh_agent_stdout.stdout_lines | map('regex_replace', '^setenv ([^ ]+) ([^ ]+);', '\2'))
| list | items2dict(key_name=0, value_name=1)
}}
- name: Register ssh agent facts
set_fact:
openssh_agent_pid: "{{ openssh_agent_env_vars.stdout.split(';')[0] }}"
openssh_agent_sock: "{{ openssh_agent_env_vars.stdout.split(';')[1] }}"
openssh_agent_pid: "{{ openssh_agent_env.SSH_AGENT_PID }}"
openssh_agent_sock: "{{ openssh_agent_env.SSH_AUTH_SOCK }}"
- name: stat agent socket
stat: