Debian Codegraph @

test/integration/targets/rpm_key/tasks/main.yaml

raw
1 - when: ansible_os_family == "RedHat"
2 block:
3
4 - name: List the installed GPG keys
5 shell: rpm -q gpg-pubkey | sort
6 register: list_of_pubkeys
7
8 - name: Retrieve the installed GPG keys
9 command: rpm -q --qf %{description} gpg-pubkey
10 register: pubkeys
11
12 - name: Save the retrieved GPG keys to a file
13 copy:
14 content: "{{ pubkeys['stdout'] }}"
15 dest: "{{ remote_tmp_dir + '/pubkeys' }}"
16 mode: 0600
17
18 - include_tasks: rpm_key.yaml
19
20 always:
21
22 # This will fail if the tests leave no keys in the key store
23 - name: Remove all GPG keys from key ring
24 shell: rpm -q gpg-pubkey | xargs rpm -e
25 ignore_errors: yes
26
27 - name: Restore the previously installed GPG keys
28 command: rpm --import {{ (remote_tmp_dir + '/pubkeys') | quote }}
29
30 - name: List the installed GPG keys
31 shell: rpm -q gpg-pubkey | sort
32 register: new_list_of_pubkeys
33
34 - name: Verify the GPG keys have been restored
35 assert:
36 that: list_of_pubkeys["stdout"] == new_list_of_pubkeys["stdout"]