Skip to content

Commit 589ea4c

Browse files
author
Tong Li
committed
[CE-393]Ansible agent container does not allow sudo
ansible agent container does not have sudo installed, when playbooks try to switch to sudo, it fails. This patch set fixed that issue and also removed an unused package from the container to reduce the size of the container. Change-Id: I2250a165c1f675a9a6ca10e20781d89263ee6cc6 Signed-off-by: Tong Li <litong01@us.ibm.com>
1 parent 5162a2b commit 589ea4c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

docker/ansible-agent/Dockerfile.in

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ ARG uid=1000
1111
ARG gid=1000
1212

1313
RUN apt-get update && \
14-
apt-get install -y bash curl python-dev sshpass \
14+
apt-get install -y bash curl python-dev sshpass sudo \
1515
python-pip build-essential openssh-client libffi-dev \
16-
libssl-dev && \
16+
libssl-dev && \
1717
pip install --upgrade pip ansible boto boto3 shade \
18-
pyyaml openshift && \
18+
pyyaml && \
1919
groupadd -g ${gid} ${user} && \
2020
useradd -d /opt/agent -u ${uid} -g ${user} ${user} && \
2121
usermod -a -G root ${user} && \
22+
echo "${user} ALL=(ALL) NOPASSWD: ALL"|tee /etc/sudoers.d/${user} && \
2223
mkdir -p /opt/agent/.ssh && \
2324
cd /opt/agent/.ssh && \
2425
echo "host *" > config && \

dockerhub/latest/ansible-agent/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ ARG uid=1000
1919
ARG gid=1000
2020

2121
RUN apt-get update && \
22-
apt-get install -y bash sshpass python-pip openssh-client && \
22+
apt-get install -y bash sshpass python-pip openssh-client sudo && \
2323
pip install --upgrade pip ansible boto boto3 shade \
24-
pyyaml openshift && \
24+
pyyaml && \
2525
groupadd -g ${gid} ${user} && \
2626
useradd -d /opt/agent -u ${uid} -g ${user} ${user} && \
2727
usermod -a -G root ${user} && \
28+
echo "${user} ALL=(ALL) NOPASSWD: ALL"|tee /etc/sudoers.d/${user} && \
2829
mkdir -p /opt/agent/.ssh && \
2930
cd /opt/agent/.ssh && \
3031
echo "host *" > config && \

0 commit comments

Comments
 (0)