-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_latest_container_(image_mode).erb
113 lines (102 loc) · 3.31 KB
/
build_latest_container_(image_mode).erb
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<%#
name: Build latest container (Image Mode)
snippet: false
template_inputs:
- name: src_registry_repo_tag
required: true
input_type: user
description: Source registry - repository and tag in the right format
advanced: false
value_type: plain
resource_type: Katello::ActivationKey
hidden_value: false
- name: src_registry_user
required: true
input_type: user
description: Source rgistry username
advanced: false
value_type: plain
resource_type: Katello::ActivationKey
hidden_value: false
- name: container_file_absolute
required: true
input_type: user
description: Container file absolute path
advanced: false
value_type: plain
resource_type: Katello::ActivationKey
hidden_value: false
- name: src_registry_pass
required: true
input_type: user
description: Source registry password
advanced: false
value_type: plain
resource_type: Katello::ActivationKey
hidden_value: true
- name: dst_registry_repo_tag
required: true
input_type: user
description: Destination registry - repository and tag in the right format
advanced: false
value_type: plain
resource_type: Katello::ActivationKey
hidden_value: false
- name: dst_registry_user
required: true
input_type: user
description: Destination registry user name
advanced: false
value_type: plain
resource_type: Katello::ActivationKey
hidden_value: false
- name: dst_registry_pass
required: true
input_type: user
description: Destination registry password
advanced: false
value_type: plain
resource_type: Katello::ActivationKey
hidden_value: true
model: JobTemplate
job_category: RHEL Image Mode
provider_type: script
kind: job_template
organizations:
- home
locations:
- Default Location
%>
#!/bin/bash -x
## This script builds latest patch for systems that are already installed and registered with Satellite
## When the image for these systems is built, make sure the container image is consumed from Satellite (during a build with image builder)
## A separate job will address building latest image for Image Based Provisioning
## Path and filename where your container file is stored
export src_registry_repo_tag='<%= input("src_registry_repo_tag") -%>'
export src_registry_user='<%= input("src_registry_user") -%>'
export src_registry_pass='<%= input("src_registry_pass") -%>'
export container_file_absolute='<%= input("container_file_absolute") -%>'
export dst_registry_repo_tag='<%= input("dst_registry_repo_tag") -%>'
export dst_registry_user='<%= input("dst_registry_user") -%>'
export dst_registry_pass='<%= input("dst_registry_pass") -%>'
export repo_name='<%= input("repo_name") -%'
## Check if podman installed and if not, install it
if [ -z $podman_installed ]; then
dnf install -y podman
fi
## Login to source
podman login $(echo $src_registry_repo_tag | cut -d"/" -f1) -u="$src_registry_user" -p="$src_registry_pass"
## add check
## Login to destination
podman login $(echo $dst_registry_repo_tag | cut -d"/" -f1) -u="$dst_registry_user" -p="$dst_registry_pass"
## add check for success
## First let's pull latest content from registry
podman pull $src_registry_repo_tag
## Let's build latest image
podman build -f $container_file_absolute -t $dst_registry_repo_tag
## Wait a bit
#sleep 60
## Let's push latest to registry
podman push $dst_registry_repo_tag
## Ready
#ehco "All has been created successfully"