-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathsatellite_repository_sync.yml
More file actions
69 lines (56 loc) · 2.42 KB
/
satellite_repository_sync.yml
File metadata and controls
69 lines (56 loc) · 2.42 KB
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
68
69
---
- hosts: all
tasks:
- 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 repo list
command: >-
hammer --output json repository list --organization-id {{ sat_org_id[0] }}
register: hammer_repo_list_result
ignore_errors: true
- name: set the Repo Id from specific repo selection via "{{ repository }}" variable and .Id
set_fact: sat_repo_id={{ hammer_repo_list_result.stdout | from_json | json_query(my_query) }}
vars:
my_query: "[?Name=='{{ repository }}'].Id"
- fail: msg="The repo {{ repository }} does not exist in this organization"
when: sat_repo_id |length == 0
- name: What is the Repo Id?
debug:
msg: "The Repo Id selected is: {{ sat_repo_id[0] }}"
- name: set the Product Name via "{{ repository }}" variable and .Product
set_fact: sat_product_name={{ hammer_repo_list_result.stdout | from_json | json_query(my_query) }}
vars:
my_query: "[?Name=='{{ repository }}'].Product"
- name: What is the Product Name?
debug:
msg: "The Product Name is: {{ sat_product_name[0] }}"
- name: hammer product list
command: >-
hammer --output json product list --organization-id {{ sat_org_id[0] }}
register: hammer_product_list_result
ignore_errors: true
- name: set the Product Id from specific Product Name selection via "{{ sat_product_name[0] }}" variable and .Name
set_fact: sat_product_id={{ hammer_product_list_result.stdout | from_json | json_query(my_query) }}
vars:
my_query: "[?Name=='{{ sat_product_name[0] }}'].ID"
- name: What is the Product Id?
debug:
msg: "The Product Id is: {{ sat_product_id[0] }}"
- name: hammer repository synchronize
command: >-
hammer repository synchronize --async --id {{ sat_repo_id[0] }} --organization-id {{ sat_org_id[0] }} --product-id {{ sat_product_id[0] }}
register: hammer_repo_sync_result
ignore_errors: true
- name: Repo sync output
debug:
msg: "{{ hammer_repo_sync_result.stdout }}"