-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work around problems on some CI targets.
- Loading branch information
1 parent
f056b71
commit 7aa0ec4
Showing
9 changed files
with
106 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,55 +3,58 @@ | |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
- name: Create GPG key | ||
ansible.builtin.command: | ||
cmd: gpg --homedir "{{ remote_tmp_dir }}" --batch --generate-key | ||
stdin: | | ||
%echo Generating a basic OpenPGP key | ||
%no-ask-passphrase | ||
%no-protection | ||
Key-Type: RSA | ||
Key-Length: 4096 | ||
Name-Real: Foo Bar | ||
Name-Email: [email protected] | ||
Expire-Date: 0 | ||
%commit | ||
%echo done | ||
register: result | ||
|
||
- name: Extract fingerprint | ||
ansible.builtin.shell: gpg --homedir "{{ remote_tmp_dir }}" --with-colons --fingerprint [email protected] | grep '^fpr:' | ||
register: fingerprints | ||
|
||
- name: Show fingerprints | ||
ansible.builtin.debug: | ||
msg: "{{ fingerprints.stdout_lines | map('split', ':') }}" | ||
|
||
- name: Export public key | ||
ansible.builtin.command: gpg --homedir "{{ remote_tmp_dir }}" --export --armor [email protected] | ||
register: public_key | ||
|
||
- name: Export private key | ||
ansible.builtin.command: gpg --homedir "{{ remote_tmp_dir }}" --export-secret-key --armor [email protected] | ||
register: private_key | ||
|
||
- name: Write public key to disk | ||
ansible.builtin.copy: | ||
dest: "{{ remote_tmp_dir }}/public-key" | ||
content: "{{ public_key.stdout }}" | ||
|
||
- name: Write private key to disk | ||
ansible.builtin.copy: | ||
dest: "{{ remote_tmp_dir }}/private-key" | ||
content: "{{ private_key.stdout }}" | ||
|
||
- name: Gather fingerprints | ||
ansible.builtin.set_fact: | ||
public_key_fingerprint: "{{ lookup('community.crypto.gpg_fingerprint', remote_tmp_dir ~ '/public-key') }}" | ||
private_key_fingerprint: "{{ lookup('community.crypto.gpg_fingerprint', remote_tmp_dir ~ '/private-key') }}" | ||
|
||
- name: Check whether fingerprints match | ||
ansible.builtin.assert: | ||
that: | ||
- public_key_fingerprint == (fingerprints.stdout_lines[0] | split(':'))[9] | ||
- private_key_fingerprint == (fingerprints.stdout_lines[0] | split(':'))[9] | ||
- name: Run tests if GPG is available | ||
when: has_gnupg | ||
block: | ||
- name: Create GPG key | ||
ansible.builtin.command: | ||
cmd: gpg --homedir "{{ remote_tmp_dir }}" --batch --generate-key | ||
stdin: | | ||
%echo Generating a basic OpenPGP key | ||
%no-ask-passphrase | ||
%no-protection | ||
Key-Type: RSA | ||
Key-Length: 4096 | ||
Name-Real: Foo Bar | ||
Name-Email: [email protected] | ||
Expire-Date: 0 | ||
%commit | ||
%echo done | ||
register: result | ||
|
||
- name: Extract fingerprint | ||
ansible.builtin.shell: gpg --homedir "{{ remote_tmp_dir }}" --with-colons --fingerprint [email protected] | grep '^fpr:' | ||
register: fingerprints | ||
|
||
- name: Show fingerprints | ||
ansible.builtin.debug: | ||
msg: "{{ fingerprints.stdout_lines | map('split', ':') | list }}" | ||
|
||
- name: Export public key | ||
ansible.builtin.command: gpg --homedir "{{ remote_tmp_dir }}" --export --armor [email protected] | ||
register: public_key | ||
|
||
- name: Export private key | ||
ansible.builtin.command: gpg --homedir "{{ remote_tmp_dir }}" --export-secret-key --armor [email protected] | ||
register: private_key | ||
|
||
- name: Write public key to disk | ||
ansible.builtin.copy: | ||
dest: "{{ remote_tmp_dir }}/public-key" | ||
content: "{{ public_key.stdout }}" | ||
|
||
- name: Write private key to disk | ||
ansible.builtin.copy: | ||
dest: "{{ remote_tmp_dir }}/private-key" | ||
content: "{{ private_key.stdout }}" | ||
|
||
- name: Gather fingerprints | ||
ansible.builtin.set_fact: | ||
public_key_fingerprint: "{{ lookup('community.crypto.gpg_fingerprint', remote_tmp_dir ~ '/public-key') }}" | ||
private_key_fingerprint: "{{ lookup('community.crypto.gpg_fingerprint', remote_tmp_dir ~ '/private-key') }}" | ||
|
||
- name: Check whether fingerprints match | ||
ansible.builtin.assert: | ||
that: | ||
- public_key_fingerprint == (fingerprints.stdout_lines[0] | split(':'))[9] | ||
- private_key_fingerprint == (fingerprints.stdout_lines[0] | split(':'))[9] |
20 changes: 20 additions & 0 deletions
20
tests/integration/targets/prepare_jinja2_compat/filter_plugins/ansible_compatibility.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright (c) Ansible Project | ||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
from __future__ import (absolute_import, division, print_function) | ||
__metaclass__ = type | ||
|
||
|
||
# Added in ansible-core 2.11 | ||
def compatibility_split_filter(text, by_what): | ||
return text.split(by_what) | ||
|
||
|
||
class FilterModule: | ||
''' Jinja2 compat filters ''' | ||
|
||
def filters(self): | ||
return { | ||
'split': compatibility_split_filter, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
# Copyright (c) Ansible Project | ||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
has_gnupg: false | ||
# The GnuPG version included with CentOS 6 is too old, it doesn't understand --generate-key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
# Copyright (c) Ansible Project | ||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
# TODO Homebrew currently isn't happy when running as root, so assume we don't have GnuPG | ||
has_gnupg: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters