Skip to content

Commit

Permalink
feat(ansible): Add a sidecar with Ansible tooling installed inside
Browse files Browse the repository at this point in the history
related to eclipse-che/che#11877

Change-Id: Ifc1af877a797fd1b0043ed3574a5adac0e204e1d
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
  • Loading branch information
benoitf committed May 19, 2021
1 parent 48c5ed1 commit 3a8e367
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
26 changes: 26 additions & 0 deletions sidecars/ansible/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (c) 2021 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation

FROM quay.io/ansible/toolset:3.4.0

ENV HOME=/home/theia

RUN apt-get update && apt-get -y install ansible-lint && apt-get clean && apt-get -y autoremove && rm -rf /var/lib/apt/lists/* && \
mkdir /projects ${HOME} && \
# Change permissions to let any arbitrary user
for f in "${HOME}" "/etc/passwd" "/projects"; do \
echo "Changing permissions on ${f}" && chgrp -R 0 ${f} && \
chmod -R g+rwX ${f}; \
done

ADD etc/entrypoint.sh /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]
CMD ${PLUGIN_REMOTE_ENDPOINT_EXECUTABLE}
1 change: 1 addition & 0 deletions sidecars/ansible/PLATFORMS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
linux/amd64
31 changes: 31 additions & 0 deletions sidecars/ansible/etc/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
#
# Copyright (c) 2021 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#

set -e
set -x

USER_ID=$(id -u)
export USER_ID
GROUP_ID=$(id -g)
export GROUP_ID

if ! whoami >/dev/null 2>&1; then
echo "${USER_NAME:-user}:x:${USER_ID}:0:${USER_NAME:-user} user:${HOME}:/bin/sh" >> /etc/passwd
fi

# Grant access to projects volume in case of non root user with sudo rights
if [ "${USER_ID}" -ne 0 ] && command -v sudo >/dev/null 2>&1 && sudo -n true > /dev/null 2>&1; then
sudo chown "${USER_ID}:${GROUP_ID}" /projects
fi

exec "$@"

0 comments on commit 3a8e367

Please sign in to comment.