Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP webui: Allow embedding a webui service #1477

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions agent/05_agent_create_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,24 @@ function create_image() {
"${openshift_install}" --dir="${asset_dir}" --log-level=debug agent create image
}

function get_agent_iso() {
declare agent_iso

agent_iso="${OCP_DIR}/agent.$(uname -p).iso"
if [ ! -f "$agent_iso" -a -f "${OCP_DIR}/agent.iso" ]; then
agent_iso="${OCP_DIR}/agent.iso"
fi
echo "$agent_iso"
}

function attach_agent_iso() {

# This is required to allow qemu opening the disk image
if [ "${OPENSHIFT_CI}" == true ]; then
setfacl -m u:qemu:rx /root
fi

local agent_iso="${OCP_DIR}/agent.$(uname -p).iso"
if [ ! -f "${agent_iso}" -a -f "${OCP_DIR}/agent.iso" ]; then
agent_iso="${OCP_DIR}/agent.iso"
fi
local agent_iso=$(get_agent_iso)

for (( n=0; n<${2}; n++ ))
do
Expand Down Expand Up @@ -149,6 +156,10 @@ function mce_complete_deployment() {

create_image

if [ ! -z "${AGENT_EMBED_GUI:-}" ]; then
ansible-playbook "${SCRIPTDIR}/agent/assets/webui/webui-playbook.yaml"
fi

attach_agent_iso master $NUM_MASTERS
attach_agent_iso worker $NUM_WORKERS

Expand Down
30 changes: 30 additions & 0 deletions agent/assets/webui/ui.bu.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
variant: openshift
version: 4.12
systemd:
units:
- name: assisted-web-ui.service
enabled: true
contents: |
[Unit]
Description=Assisted Service web-ui
Wants=network.target
RequiresMountsFor=%t/containers
Requires=assisted-service.service
BindsTo=assisted-service-pod.service
After=network-online.target assisted-service-pod.service
ConditionPathExists=/etc/assisted-service/node0

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStartSec=500
TimeoutStopSec=300
ExecStartPre=/bin/rm -f %t/%n.ctr-id
ExecStart=/usr/bin/podman run --net host --cidfile=%t/%n.ctr-id --cgroups=no-conmon --log-driver=journald --rm --pod-id-file=%t/assisted-service-pod.pod-id --sdnotify=conmon --replace -d --name=webui {{ webui_image }}
ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all

[Install]
WantedBy=multi-user.target
87 changes: 87 additions & 0 deletions agent/assets/webui/webui-playbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
- name: Create webui content for Agent ISO
hosts: localhost
collections:
- community.general
gather_facts: no
vars:
- webui_image: "{{ lookup('env', 'WEBUI_IMAGE') }}"
- ocp_dir: "{{ loopkup('env', 'OCP_DIR') }}"

tasks:
- name: Check agent iso
ansible.builtin.file:
state: file
path: "{{ ocp_dir }}/agent.{{ ansible_architecture }}.iso"
register: agent_iso

- name: Create webui temp dir
ansible.builtin.tempfile:
state: directory
suffix: webui
register: ui_tempdir

- name: write UI butane
template:
src: "ui.bu.j2"
dest: "{{ ui_tempdir.path }}/ui.bu"

- name: Generate UI ignition
containers.podman.podman_container:
name: butane
state: started
detach: no
rm: yes
volume:
- "{{ ui_tempdir.path }}:/data"
image: quay.io/coreos/butane:release
command: "--pretty --strict /data/ui.bu -o /data/ui.ign"


- name: Extract Agent ISO ignition
containers.podman.podman_container:
name: coreos-installer
state: started
detach: no
rm: yes
volume:
- "{{ agent_iso.path }}:/data/agent.iso"
image: quay.io/coreos/coreos-installer:release
command: "iso ignition show /data/agent.iso"
register: iso_ignition

- name: save ISO ignition
ansible.builtin.copy:
content: "{{ iso_ignition.stdout }}"
dest: "{{ ui_tempdir.path }}/iso.ign"

- name: Get kcli ignition merger tool
ansible.builtin.get_url:
url: https://raw.githubusercontent.com/karmab/kcli/master/extras/ignitionmerger.py
dest: "{{ ui_tempdir.path }}/ignitionmerger.py"
mode: "0755"

- name: Merge ignition
ansible.builtin.command:
argv:
- python
- "{{ ui_tempdir.path }}/ignitionmerger.py"
- "{{ ui_tempdir.path }}/iso.ign"
- "{{ ui_tempdir.path }}/ui.ign"
register: ignitionmerger

- name: save merged ignition
ansible.builtin.copy:
content: "{{ ignitionmerger.stdout }}"
dest: "{{ ui_tempdir.path }}/merged.ign"

- name: Embedding merged ignition
containers.podman.podman_container:
name: coreos-installer
state: started
detach: no
rm: yes
volume:
- "{{ ui_tempdir.path }}/merged.ign:/data/merged.ign"
- "{{ agent_iso.path }}:/data/agent.iso"
image: quay.io/coreos/coreos-installer:release
command: "iso ignition embed -f -i /data/merged.ign /data/agent.iso"
5 changes: 5 additions & 0 deletions config_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -667,3 +667,8 @@ set -x

# Uncomment the following line to deploy the MCE operator, and to automatically import the current cluster as the hub cluster
# export AGENT_DEPLOY_MCE=true

# If you want to run the assisted service UI, you must set the following environment variables:
# AGENT_EMBED_GUI=true
# WEBUI_IMAGE="quay.io/edge-infrastructure/assisted-installer-ui:latest"
# Note that if you can put a different WEBUI_IMAGE