Fix ansible-lint config and migrate CentOS container to SSH-based testing
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
38
.github/workflows/ci-cd.yml
vendored
38
.github/workflows/ci-cd.yml
vendored
@@ -204,7 +204,7 @@ jobs:
|
||||
mkdir -p test-inventory
|
||||
cat > test-inventory/hosts <<EOF
|
||||
[wordpress_servers]
|
||||
test-centos ansible_connection=docker ansible_docker_extra_args="--user=root"
|
||||
test-centos ansible_host=localhost ansible_port=2223 ansible_user=testuser ansible_ssh_private_key_file=~/.ssh/id_rsa ansible_ssh_common_args='-o StrictHostKeyChecking=no'
|
||||
EOF
|
||||
|
||||
- name: Build CentOS test container
|
||||
@@ -212,27 +212,45 @@ jobs:
|
||||
docker build -t test-centos:stream9 -f- . <<EOF
|
||||
FROM quay.io/centos/centos:stream9
|
||||
RUN dnf update -y && dnf install -y \
|
||||
python3 python3-pip sudo openssh-server systemd \
|
||||
python3 python3-pip sudo openssh-server curl \
|
||||
&& dnf clean all
|
||||
RUN useradd -m -s /bin/bash testuser && \
|
||||
echo 'testuser ALL=(ALL) NOPASSWD:ALL' >> /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
|
||||
|
||||
Reference in New Issue
Block a user