collage for ansible wid

This commit is contained in:
bluxmit 2021-09-13 18:00:33 +00:00
parent ce371d7d95
commit a912c32827
4 changed files with 157 additions and 9 deletions

View file

@ -20,7 +20,7 @@ This project was created to share dockerized workspaces, and to set an example o
## What is workspace In Docker
***TLDR: Workspaces are toolsets designed for a specific project and packaged as docker images. They make it easy to switch between projects;
can be moved between laptops, PCs and cloud servers; can run in cloud and be used from any device; have versions and
can be moved between laptops, PCs, and cloud servers; can run in the cloud and be used from any device; have versions and
backups; can be used by several users and make collaboration easier.***
@ -145,10 +145,10 @@ You cannot keep your laptop running all the time. You need to quickly move to th
docker images, create CI/CD, configure servers, you can simply move your workspace to the cloud as-is. Depending on the situation, such "rapid" deployment might
be well-justified for proofs-of-concept, experiments, scheduling supporting tasks, etc.
**Yo need an environment fto isolate an experiment.** You want to try a new framework, library, package, or simply update your dependencies to the latest version. Try to do it in
**Yo need an environment to isolate an experiment.** You want to try a new framework, library, package, or simply update your dependencies to the latest version. Try to do it in
a self-contained isolated environment first.
**You require backups and versions of the entire workspace.** Your work may go well beyond the development-debugging-testing-deployment cycle.
**You require backups and versions for the entire workspace.** Your work may go well beyond the development-debugging-testing-deployment cycle.
For example, if you are a data analyst, data scientist, researcher you make experiments, simulations, train ML models. Such work often involves
frequent changes to your environment (updating packages, install new applications, change datasets, etc.). To reproduce analytics,
experiment, or ML model training you need to have an exact version of your environment at a specific point in time. Dockerized workspaces in docker
@ -185,14 +185,14 @@ Together with your publication, it will greatly help people who struggle with th
## How to make your own workspace
This repo was created with the idea in mind - to set up basics for building custom workspaces. The workspaces, shared in this project
are build based on each other. Some of the workspaces are highly customized, have a narrow scope, and focuse on a specific task.
Other workspaces are more general, and intended to be used for further customization.
are build based on each other. Some of the workspaces are highly customized, have a narrow scope, and focus on a specific task.
Other workspaces are more general and intended to be used for further customization.
The most general workspace - is [`Ubuntu-workspace`](./workspaces/ubuntu-workspace/README.md). It sets the basics for using docker
in order to run multiple processes, adds cron, zsh and other applications that will be used in most workspaces.
in order to run multiple processes, adds cron, zsh, and other applications that will be used in most workspaces.
Other general workspaces are the [`Base-Workspace`](./workspaces/base-workspace/README.md), that adds several browser-based applications,
like task scheduler, file browser, documentation framowork and workspace own page. [`Workspace-in-docker`](./workspaces/workspace-in-docker/README.md)
Other general workspaces are the [`Base-Workspace`](./workspaces/base-workspace/README.md), which adds several browser-based applications,
like task scheduler, file browser, documentation framework and workspace own page. [`Workspace-in-docker`](./workspaces/workspace-in-docker/README.md)
adds [Eclipse Theia](https://theia-ide.org/) to the Base-Workspace. Theia - is an open-source browser-based VS-Code version, making
Workspace-in-docker to be a general base workspace, to be used in order to create workspaces for specific tasks (like Python workspace, or
Ansible workspace).

View file

@ -2,8 +2,13 @@
This workspace - is a "dockerized" development environment with [Ansible](https://docs.ansible.com/)
and [Terraform](https://www.terraform.io/) and lots of other stuff installed,
so that you don't need to do it yourself. Create infrastructures with Terraform, and configure it with Ansible
so that you don't need to do it yourself. Create infrastructures with Terraform, and configure it with Ansible.
Workspace will help to code and develop; visualize infrastructures and planned terraform changes;
display ansible hosts plays; schedule and observe executions and more!
<p align="center">
<img src="./img/ansible-terraform-wid-collage.svg" alt="Collage">
</p>
Try it out

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 17 MiB

View file

@ -0,0 +1,140 @@
FROM ubuntu:18.04
COPY unified-supervisord.conf supervisord.conf /etc/supervisord/
COPY mc.ini /home/abc/.config/mc/ini
COPY zsh-in-docker.sh /tmp/zsh-in-docker.sh
# Systemctl within Docker and Python 3.9
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
&& apt-get install -y wget \
&& wget https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl.py -O /usr/local/bin/systemctl \
&& chmod 0777 /usr/local/bin/systemctl \
&& apt-get install -y software-properties-common \
&& apt-get install -y apache2-utils \
&& apt-get install -y zip gzip tar \
&& echo "------------------------------------------------------ User" \
&& useradd -u 8877 abc \
&& chmod -R 777 /home \
&& mkdir -p /home/abc \
&& chown -R abc /home/abc \
&& echo "------------------------------------------------------ Python" \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get install -y python3.9 \
&& update-alternatives --install /usr/bin/python python /usr/bin/python3.9 10 \
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 10 \
&& apt-get install -y python3-distutils \
&& apt-get install -y python3.9-distutils \
&& apt-get install -y python3-pip \
&& apt-get install python3.9-venv \
&& pip3 install --upgrade pip \
&& pip3 install --upgrade setuptools \
&& pip3 install --upgrade distlib \
&& update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 \
&& echo "------------------------------------------------------ Common Packages" \
&& apt-get install -y sudo git curl wget telnet jq \
&& apt-get install -y mc ncdu htop \
&& apt-get install -y nano vim \
&& apt-get install -y git git-flow \
&& echo "# Allow non-admin users to install packages" >> /etc/sudoers \
&& echo "abc ALL = NOPASSWD : /usr/bin/apt, /usr/bin/apt-get, /usr/bin/aptitude, /usr/local/bin/pip, /usr/local/bin/systemctl, /usr/bin/dpkg, /usr/sbin/dpkg-reconfigure" >> /etc/sudoers \
&& echo "------------------------------------------------------ Nodeenv" \
&& pip install nodeenv \
&& apt-get install -y yarn \
&& echo "------------------------------------------------------ Cron" \
&& apt-get install -y cron \
&& mkdir -p /var/log/supervisord/ \
&& chmod -R 777 /var/spool/cron/crontabs \
&& chmod -R 777 /var/log \
&& chmod gu+rw /var/run \
&& chmod gu+s /usr/sbin/cron \
&& echo "# Allow cron for user abc" >> /etc/sudoers \
&& echo "abc ALL = NOPASSWD : /usr/sbin/cron " >> /etc/sudoers \
&& echo "------------------------------------------------------ Supervisor" \
&& apt-get remove -y cmdtest \
&& apt-get install -y supervisor \
&& pip3 install supervisor==4.2.2 \
&& apt-get update \
&& apt-get install -y systemd \
&& chmod -R 777 /etc/supervisord/ \
&& chmod -R 777 /var/log/supervisord/ \
&& echo "------------------------------------------------------ ZSH root" \
&& HOME=/root \
&& chmod +x /tmp/zsh-in-docker.sh \
&& /tmp/zsh-in-docker.sh \
-t https://github.com/pascaldevink/spaceship-zsh-theme \
-a 'SPACESHIP_PROMPT_ADD_NEWLINE="false"' \
-a 'SPACESHIP_PROMPT_SEPARATE_LINE="false"' \
-a 'export LS_COLORS="$LS_COLORS:ow=1;34:tw=1;34:"' \
-a 'SPACESHIP_USER_SHOW="false"' \
-a 'SPACESHIP_TIME_SHOW="true"' \
-a 'SPACESHIP_TIME_COLOR="grey"' \
-a 'SPACESHIP_DIR_COLOR="cyan"' \
-a 'SPACESHIP_GIT_SYMBOL="⇡"' \
-a 'SPACESHIP_BATTERY_SHOW="false"' \
-a 'if [[ $(pwd) != /root ]]; then cd /root; fi # Set starting dir to /root ' \
-a 'hash -d r=/root' \
-p git \
-p https://github.com/zsh-users/zsh-autosuggestions \
-p https://github.com/zsh-users/zsh-completions \
-p https://github.com/zsh-users/zsh-history-substring-search \
-p https://github.com/zsh-users/zsh-syntax-highlighting \
-p 'history-substring-search' \
-p https://github.com/bobthecow/git-flow-completion \
-a 'bindkey "\$terminfo[kcuu1]" history-substring-search-up' \
-a 'bindkey "\$terminfo[kcud1]" history-substring-search-down' \
&& printf '%s\n%s\n' "export ZSH_DISABLE_COMPFIX=true" "$(cat /root/.zshrc)" > /root/.zshrc \
&& echo "------------------------------------------------------ ZSH abc" \
&& mkdir -p /home/project \
&& HOME=/home/abc \
&& /tmp/zsh-in-docker.sh \
-t https://github.com/pascaldevink/spaceship-zsh-theme \
-a 'SPACESHIP_PROMPT_ADD_NEWLINE="false"' \
-a 'SPACESHIP_PROMPT_SEPARATE_LINE="false"' \
-a 'export LS_COLORS="$LS_COLORS:ow=1;34:tw=1;34:"' \
-a 'SPACESHIP_USER_SHOW="true"' \
-a 'SPACESHIP_TIME_SHOW="true"' \
-a 'SPACESHIP_TIME_COLOR="grey"' \
-a 'SPACESHIP_DIR_COLOR="cyan"' \
-a 'SPACESHIP_GIT_SYMBOL="⇡"' \
-a 'SPACESHIP_BATTERY_SHOW="false"' \
-a 'if [[ $(pwd) != /home/project ]]; then cd /home/project; fi # Set starting dir to /home/project ' \
-a 'hash -d p=/home/project' \
-p git \
-p https://github.com/zsh-users/zsh-autosuggestions \
-p https://github.com/zsh-users/zsh-completions \
-p https://github.com/zsh-users/zsh-history-substring-search \
-p https://github.com/zsh-users/zsh-syntax-highlighting \
-p 'history-substring-search' \
-p https://github.com/bobthecow/git-flow-completion \
-a 'bindkey "\$terminfo[kcuu1]" history-substring-search-up' \
-a 'bindkey "\$terminfo[kcud1]" history-substring-search-down' \
&& rm /tmp/zsh-in-docker.sh \
&& printf '%s\n%s\n' "export ZSH_DISABLE_COMPFIX=true" "$(cat /home/abc/.zshrc)" > /home/abc/.zshrc \
&& echo "------------------------------------------------------ User" \
&& chown abc /home/project \
&& chmod 777 /etc/supervisord/ \
&& mkdir -p /home/abc/.local/bin \
&& chmod 755 /home/abc/.local && chmod 755 /home/abc/.local/bin \
&& chown abc /home/abc/.local && chown abc /home/abc/.local/bin \
&& find /home -type d | xargs -I{} chown -R abc {} \
&& find /home -type f | xargs -I{} chown abc {} \
&& echo "------------------------------------------------------ Clean" \
&& apt-get -y autoremove \
&& apt-get -y clean \
&& apt-get -y autoclean
USER abc
ENV PATH="/home/abc/.local/bin:${PATH}"
###### ENTRY
# note! this will have consequences only when started as root (docker run ... --user root ...)
# systemctl start systemd-journald
# this entrypoint should be the same for all images that are built on top of this one
ENTRYPOINT /etc/init.d/cron start; systemctl start systemd-journald; supervisord -c "/etc/supervisord/unified-supervisord.conf"