From 3e61be570fb8721761842b528d80e5d956ea5f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Palencs=C3=A1r?= Date: Thu, 19 Jun 2025 05:38:27 +0200 Subject: [PATCH] Fix ansible-lint config and migrate CentOS container to SSH-based testing --- .ansible-lint | 4 ---- .github/workflows/ci-cd.yml | 38 +++++++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.ansible-lint b/.ansible-lint index 6230649..33cc5ff 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -39,10 +39,6 @@ rules: comments: min-spaces-from-content: 1 -# Use specific Ansible version for linting -supported_ansible_versions: - - ">=6.0" - # Offline mode (don't check for newer ansible-lint versions) offline: false diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 4912451..24ff891 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -204,7 +204,7 @@ jobs: mkdir -p test-inventory cat > test-inventory/hosts <> /etc/sudoers - CMD ["/sbin/init"] + # Configure SSH + RUN mkdir /var/run/sshd + RUN echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config + RUN echo 'PasswordAuthentication no' >> /etc/ssh/sshd_config + RUN echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config + RUN ssh-keygen -A + EXPOSE 22 + # Start SSH service in foreground to keep container running + CMD ["/usr/sbin/sshd", "-D"] EOF - name: Run CentOS test container run: | + # Generate SSH key (reuse from Ubuntu test) + mkdir -p ~/.ssh + if [ ! -f ~/.ssh/id_rsa ]; then + ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa -N "" + fi + + # Start container docker run -d --name test-centos \ - --privileged \ - --tmpfs /tmp \ - --tmpfs /run \ - --tmpfs /run/lock \ - -v /sys/fs/cgroup:/sys/fs/cgroup:ro \ + -p 2223:22 \ test-centos:stream9 - # Wait for container to be ready + # Wait for SSH to be ready sleep 10 - # Check if container is running + # Copy SSH key to container + docker exec test-centos mkdir -p /home/testuser/.ssh + docker cp ~/.ssh/id_rsa.pub test-centos:/home/testuser/.ssh/authorized_keys + docker exec test-centos chown -R testuser:testuser /home/testuser/.ssh + docker exec test-centos chmod 700 /home/testuser/.ssh + docker exec test-centos chmod 600 /home/testuser/.ssh/authorized_keys + + # Test if container is running if ! docker ps | grep -q test-centos; then echo "CentOS container failed to start, checking logs:" docker logs test-centos