Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Ansible FreeIPA
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
Ansible FreeIPA
Commits
50ba326e
Commit
50ba326e
authored
8 months ago
by
Thomas Woerner
Browse files
Options
Downloads
Patches
Plain Diff
infra/image/build.sh: Use new shcontainer
This removes a lot of duplicate code from the script.
parent
691e5915
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
infra/image/build.sh
+20
-48
20 additions, 48 deletions
infra/image/build.sh
with
20 additions
and
48 deletions
infra/image/build.sh
+
20
−
48
View file @
50ba326e
...
@@ -3,6 +3,9 @@
...
@@ -3,6 +3,9 @@
BASEDIR
=
"
$(
readlink
-f
"
$(
dirname
"
$0
"
)
"
)
"
BASEDIR
=
"
$(
readlink
-f
"
$(
dirname
"
$0
"
)
"
)
"
TOPDIR
=
"
$(
readlink
-f
"
${
BASEDIR
}
/../.."
)
"
TOPDIR
=
"
$(
readlink
-f
"
${
BASEDIR
}
/../.."
)
"
# shellcheck disable=SC1091
.
"
${
BASEDIR
}
/shcontainer"
# shellcheck disable=SC1091
.
"
${
TOPDIR
}
/utils/shfun"
.
"
${
TOPDIR
}
/utils/shfun"
valid_distro
()
{
valid_distro
()
{
...
@@ -56,7 +59,7 @@ distro=${1:-}
...
@@ -56,7 +59,7 @@ distro=${1:-}
[
-f
"
${
BASEDIR
}
/dockerfile/
${
distro
}
"
]
\
[
-f
"
${
BASEDIR
}
/dockerfile/
${
distro
}
"
]
\
||
die
"
${
distro
}
is not a valid distro target.
\n
Use one of:
$(
valid_distro
)
"
||
die
"
${
distro
}
is not a valid distro target.
\n
Use one of:
$(
valid_distro
)
"
[
-n
"
$(
command
-v
"podman"
)
"
]
||
die
"podman is required."
container_check
if
[
"
${
deploy_server
}
"
==
"Y"
]
if
[
"
${
deploy_server
}
"
==
"Y"
]
then
then
...
@@ -69,77 +72,46 @@ then
...
@@ -69,77 +72,46 @@ then
[
-f
"
${
inventory_file
}
"
]
||
die
"Can't find inventory '
${
inventory_file
}
'"
[
-f
"
${
inventory_file
}
"
]
||
die
"Can't find inventory '
${
inventory_file
}
'"
fi
fi
container_state
=
"
$(
podman ps
-q
--all
--format
"{{.State}}"
--filter
"name=
${
name
}
"
)
"
container_state
=
$(
container_get_state
"
${
name
}
"
)
tag
=
"
${
distro
}
-base"
tag
=
"
${
distro
}
-base"
server_tag
=
"
${
distro
}
-server"
server_tag
=
"
${
distro
}
-server"
# in older (as in Ubuntu 22.04) podman versions,
container_remove_image_if_exists
"
${
tag
}
"
# 'podman image rm --force' fails if the image
[
"
${
deploy_server
}
"
==
"Y"
]
&&
\
# does not exist.
container_remove_image_if_exists
"
${
server_tag
}
"
remove_image_if_exists
()
{
local
tag_to_remove
tag_to_remove
=
"
${
1
}
"
if
podman image exists
"
${
tag_to_remove
}
"
then
log info
"= Cleanup
${
tag_to_remove
}
="
podman image
rm
"
${
tag_to_remove
}
"
--force
echo
fi
}
remove_image_if_exists
"
${
tag
}
"
container_build
"
${
tag
}
"
"
${
BASEDIR
}
/dockerfile/
${
distro
}
"
"
${
BASEDIR
}
"
[
"
${
deploy_server
}
"
==
"Y"
]
&&
remove_image_if_exists
"
${
server_tag
}
"
container_create
"
${
name
}
"
"
${
tag
}
"
"
${
hostname
}
"
"
${
memory
}
"
container_commit
"
${
name
}
"
"
${
quayname
}
:
${
tag
}
"
log info
"= Building
${
tag
}
="
podman build
-t
"
${
tag
}
"
-f
"
${
BASEDIR
}
/dockerfile/
${
distro
}
"
\
"
${
BASEDIR
}
"
echo
log info
"= Creating
${
name
}
="
podman create
--privileged
--name
"
${
name
}
"
--hostname
"
${
hostname
}
"
\
--network
bridge:interface_name
=
eth0
--systemd
true
\
--memory
"
${
memory
}
"
--memory-swap
-1
--no-hosts
\
--replace
"
${
tag
}
"
echo
log info
"= Committing
\"
${
quayname
}
:
${
tag
}
\"
="
podman commit
"
${
name
}
"
"
${
quayname
}
:
${
tag
}
"
echo
if
[
"
${
deploy_server
}
"
==
"Y"
]
if
[
"
${
deploy_server
}
"
==
"Y"
]
then
then
deployed
=
false
deployed
=
false
log info
"= Starting
${
name
}
=
"
[
"
${
container_state
}
"
!=
"running"
]
&&
container_start
"
${
name
}
"
[
"
${
container_state
}
"
==
"running"
]
||
podman start
"
${
name
}
"
echo
container_wait_for_journald
"
${
name
}
"
log info
"= Deploying IPA ="
log info
"= Deploying IPA ="
if
ansible-playbook
-i
"
${
inventory_file
}
"
"
${
deploy_playbook
}
"
if
ansible-playbook
-u
root
-i
"
${
inventory_file
}
"
"
${
deploy_playbook
}
"
then
then
deployed
=
true
deployed
=
true
fi
fi
echo
echo
if
$deployed
;
then
if
$deployed
;
then
log info
"= Enabling
additional
services ="
log info
"= Enabling services ="
podman
exec
"
${
name
}
"
systemctl
enable
fixnet
container_
exec
"
${
name
}
"
systemctl
enable
fixnet
podman
exec
"
${
name
}
"
systemctl
enable
fixipaip
container_
exec
"
${
name
}
"
systemctl
enable
fixipaip
echo
echo
fi
fi
log info
"= Stopping container
${
name
}
="
container_stop
"
${
name
}
"
podman stop
"
${
name
}
"
echo
$deployed
||
die
"Deployment failed"
$deployed
||
die
"Deployment failed"
log info
"= Committing
\"
${
quayname
}
:
${
server_tag
}
\"
="
container_commit
"
${
name
}
"
"
${
quayname
}
:
${
server_tag
}
"
podman commit
"
${
name
}
"
"
${
quayname
}
:
${
server_tag
}
"
echo
fi
fi
log info
"= DONE: Image created. ="
log info
"= DONE: Image created. ="
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment