Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

[WIP] Refactoring configuration mechanism #118

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.pyo
__pycache__
*.egg-info
*.swp
data
venv
Expand Down
27 changes: 13 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,27 @@ RUN mkdir -p /deps/python /deps/ansible; \
COPY version.txt /version.txt
COPY requirements.txt /deps/python_requirements.txt
COPY requirements.yml /deps/ansible_requirements.yml
RUN microdnf update; \
COPY home /root
COPY pre /pre

RUN set -ex; \
microdnf update; \
microdnf install python3 jq openssh-clients tar sshpass findutils telnet less ncurses; \
pip3 install --user -r /deps/python_requirements.txt; \
ansible-galaxy collection install -r /deps/ansible_requirements.yml; \
microdnf clean all; \
rm -rf /var/cache/yum /tmp/* /root/.cache /usr/lib/python3.8/site-packages /usr/lib64/python3.8/__pycache__;

# Install application
WORKDIR /app
COPY app /app
COPY data.skel /data.skel
COPY home /root

# Initialize application
RUN rpm -i /app/tmp/ilorest-3.0.1-7.x86_64.rpm; \
chmod -Rv g-rwx /root/.ssh; chmod -Rv o-rwx /root/.ssh; \
rm -rf /app/tmp; \
rpm -i /pre/ilorest-3.0.1-7.x86_64.rpm; \
rm -rf /pre /var/cache/dnf /var/cache/yum /tmp/* /root/.cache /usr/lib/python3.8/site-packages /usr/lib64/python3.8/__pycache__; \
chmod -Rv g-rwx,o-rwx /root/.ssh; \
cd /usr/local/bin; \
curl https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz | tar xvzf -; \
curl https://raw.githubusercontent.com/project-faros/farosctl/master/bin/farosctl > farosctl; \
chmod 755 farosctl;

# Install application
COPY data.skel /data.skel
COPY app /app
WORKDIR /app

ENTRYPOINT ["/app/bin/entry.sh"]
CMD ["/app/bin/run.sh"]

3 changes: 0 additions & 3 deletions app/bin/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ if [ "$1" != "cat" ] && [ "$1" != "ls" ] && [ "$1" != "type" ]; then
source /app/bin/shim-check.sh
fi

if [ -e /data/config.sh ]; then
source /data/config.sh
fi
if [ -e /data/proxy.sh ]; then
source /data/proxy.sh
fi
Expand Down
5 changes: 2 additions & 3 deletions app/bin/run.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/bash

# data directory initialization
if [ ! -e /data/config.sh ]; then
cp /data.skel/config.sh /data/config.sh
if [ ! -e /data/config.yml ]; then
cp /data.skel/config.yml /data/config.yml
fi
mkdir -p /data/ansible

1 change: 1 addition & 0 deletions app/cli/detect
1 change: 0 additions & 1 deletion app/cli/shutdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

## PREPARE ENVIRONMENT
cd /app
source /data/config.sh

## EXECUTE
ansible-playbook /app/playbooks/shutdown.yml || exit 1
1 change: 0 additions & 1 deletion app/cli/ssh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ if [ $# -ne 1 ]; then
exit 1
fi

source /data/config.sh
cd /app

HOST_DATA=$(ansible-inventory --host $1)
Expand Down
1 change: 0 additions & 1 deletion app/cli/startup
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

## PREPARE ENVIRONMENT
cd /app
source /data/config.sh

## EXECUTE
ansible-playbook /app/playbooks/startup.yml || exit 1
1 change: 1 addition & 0 deletions app/cli/validate
Loading