forked from redhat-partner-tech/automated-smart-management
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcentos_gpg_key_import.yml
67 lines (58 loc) · 2.06 KB
/
centos_gpg_key_import.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
- hosts: all
tasks:
- name: Create gpg key directory for importing keys
file:
path: "{{ item }}"
state: directory
mode: 0755
with_items:
- /etc/pki/rpm-gpg/import
- name: Pull down CentOS 7 GPG key
get_url:
url: https://www.centos.org/keys/RPM-GPG-KEY-CentOS-7
dest: /etc/pki/rpm-gpg/import
mode: '0440'
register: getcentos7gpgkey
until: getcentos7gpgkey is succeeded
- name: Pull down CentOS 8 GPG key
get_url:
url: https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official
dest: /etc/pki/rpm-gpg/import
mode: '0440'
register: getcentos8gpgkey
until: getcentos8gpgkey is succeeded
- name: hammer org list
command: >-
hammer --output json organization list
register: hammer_org_list_result
ignore_errors: true
- name: set the Organization Id from specific org selection via "{{ organization }}" variable and .Id
set_fact: sat_org_id={{ hammer_org_list_result.stdout | from_json | json_query(my_query) }}
vars:
my_query: "[?Name=='{{ organization }}'].Id"
- name: What is the Org Id?
debug:
msg: "The Org Id selected is: {{ sat_org_id[0] }}"
- name: hammer create RPM-GPG-KEY-CentOS-7 key
command: >-
hammer content-credentials create --organization-id {{ sat_org_id[0] }}
--key "/etc/pki/rpm-gpg/import/RPM-GPG-KEY-CentOS-7"
--name "RPM-GPG-KEY-CentOS-7"
--content-type gpg_key
register: hammer_centos7_gpgkey_result
ignore_errors: true
- name: RPM-GPG-KEY-CentOS-7 key creation output
debug:
msg: "{{ hammer_centos7_gpgkey_result.stdout }}"
- name: hammer create RPM-GPG-KEY-CentOS-8 key
command: >-
hammer content-credentials create --organization-id {{ sat_org_id[0] }}
--key "/etc/pki/rpm-gpg/import/RPM-GPG-KEY-CentOS-Official"
--name "RPM-GPG-KEY-CentOS-8"
--content-type gpg_key
register: hammer_centos8_gpgkey_result
ignore_errors: true
- name: RPM-GPG-KEY-CentOS-8 key creation output
debug:
msg: "{{ hammer_centos8_gpgkey_result.stdout }}"