Skip to content

Commit

Permalink
Allow current user to join os/osd group during deb/rpm test (#4548)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Zhu <[email protected]>
  • Loading branch information
peterzhuamazon authored Mar 20, 2024
1 parent ee7db28 commit d54b205
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ RUN dnf install -y sudo && \
usermod -a -G opensearch $CONTAINER_USER && \
usermod -a -G opensearch-dashboards $CONTAINER_USER && \
id && \
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which dnf`, `which yum`, `which rpm`, `which chmod`, `which kill`, `which curl`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which usermod`, `which dnf`, `which yum`, `which rpm`, `which chmod`, `which kill`, `which curl`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER

# Copy from Stage0
COPY --from=linux_stage_0 --chown=$CONTAINER_USER:$CONTAINER_USER $CONTAINER_USER_HOME $CONTAINER_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ RUN apt-get install -y sudo && \
usermod -a -G opensearch $CONTAINER_USER && \
usermod -a -G opensearch-dashboards $CONTAINER_USER && \
id && \
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which apt`, `which apt-get`, `which apt-key`, `which dpkg`, `which chmod`, `which kill`, `which curl`, `which tee`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which usermod`, `which apt`, `which apt-get`, `which apt-key`, `which dpkg`, `which chmod`, `which kill`, `which curl`, `which tee`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER

# Copy from Stage0
COPY --from=linux_stage_0 --chown=$CONTAINER_USER:$CONTAINER_USER $CONTAINER_USER_HOME $CONTAINER_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ RUN dnf install -y sudo && \
usermod -a -G opensearch $CONTAINER_USER && \
usermod -a -G opensearch-dashboards $CONTAINER_USER && \
id && \
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which dnf`, `which yum`, `which rpm`, `which chmod`, `which kill`, `which curl`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER
echo "$CONTAINER_USER ALL=(root) NOPASSWD:`which systemctl`, `which env`, `which usermod`, `which dnf`, `which yum`, `which rpm`, `which chmod`, `which kill`, `which curl`, /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin" >> /etc/sudoers.d/$CONTAINER_USER

# Copy from Stage0
COPY --from=linux_stage_0 --chown=$CONTAINER_USER:$CONTAINER_USER $CONTAINER_USER_HOME $CONTAINER_USER_HOME
Expand Down
4 changes: 3 additions & 1 deletion src/test_workflow/integ_test/distribution_deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def install(self, bundle_name: str) -> None:
'&&',
f'sudo chmod 0666 {self.config_path}',
'&&',
f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}'
f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}',
'&&',
f'sudo usermod -a -G {self.filename} `whoami`'
]
)
subprocess.check_call(deb_install_cmd, cwd=self.work_dir, shell=True)
Expand Down
4 changes: 3 additions & 1 deletion src/test_workflow/integ_test/distribution_rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def install(self, bundle_name: str) -> None:
'&&',
f'sudo chmod 0666 {self.config_path}',
'&&',
f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}'
f'sudo chmod 0755 {os.path.dirname(self.config_path)} {self.log_dir}',
'&&',
f'sudo usermod -a -G {self.filename} `whoami`'
]
)
subprocess.check_call(rpm_install_cmd, cwd=self.work_dir, shell=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def test_install(self, check_call_mock: Mock) -> None:
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! "
"dpkg --install opensearch.deb && "
f"sudo chmod 0666 {self.distribution_deb.config_path} && "
f"sudo chmod 0755 {os.path.dirname(self.distribution_deb.config_path)} {self.distribution_deb.log_dir}"
f"sudo chmod 0755 {os.path.dirname(self.distribution_deb.config_path)} {self.distribution_deb.log_dir} && "
f"sudo usermod -a -G opensearch `whoami`"
),
args_list[0][0][0],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def test_install(self, check_call_mock: Mock) -> None:
"sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123! "
"yum install -y opensearch.rpm && "
f"sudo chmod 0666 {self.distribution_rpm.config_path} && "
f"sudo chmod 0755 {os.path.dirname(self.distribution_rpm.config_path)} {self.distribution_rpm.log_dir}"
f"sudo chmod 0755 {os.path.dirname(self.distribution_rpm.config_path)} {self.distribution_rpm.log_dir} && "
f"sudo usermod -a -G opensearch `whoami`"
),
args_list[0][0][0],
)
Expand Down

0 comments on commit d54b205

Please sign in to comment.